* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Roboto', sans-serif;
}

body {
    background:
        radial-gradient(circle at 20% 0%,  rgba(186, 104, 200, 0.25), transparent 50%),
        radial-gradient(circle at 80% 100%, rgba(77, 182, 172, 0.22), transparent 50%),
        linear-gradient(135deg, #15131f 0%, #1c1a2b 60%, #1a1a2e 100%);
    height: 100vh;
    height: 100dvh;
    padding: 10px;
    touch-action: none;
    overflow: hidden;
    color: #fff;
}

.game-box {
    max-width: 600px;
    height: 100%;
    margin: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    border-radius: 999px;
    padding: 6px 8px 6px 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.back-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.10);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.15s;
    font-weight: 500;
    padding-bottom: 2px; /* visually center the arrow */
}
.back-btn:hover { background: rgba(255,255,255,0.16); }
.back-btn:active { transform: scale(0.9); }
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: rgba(255,255,255,0.15);
    box-shadow: 0 0 0 2px rgba(255,255,255,0.08);
}
.user-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0.92;
}
.user-balance {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
    font-size: 15px;
    background: linear-gradient(135deg, rgba(255,215,0,0.18), rgba(255,165,0,0.10));
    border: 1px solid rgba(255,215,0,0.25);
    padding: 4px 10px;
    border-radius: 999px;
    color: #ffd980;
}
.top-up-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #4CAF50, #2e7d32);
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(76,175,80,0.45), inset 0 1px 0 rgba(255,255,255,0.2);
    transition: transform 0.15s;
}
.top-up-btn:active { transform: scale(0.92); }

.controls-bar {
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    border-radius: 18px;
    padding: 10px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.20);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.controls-bar .score-board {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 4px 10px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.controls-bar .boosters {
    background: transparent;
    border: none;
    padding: 4px 0 0;
    box-shadow: none;
}

.boosters {
    flex-shrink: 0;
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}
.booster {
    position: relative;
    background: linear-gradient(135deg, rgba(255,255,255,0.10), rgba(255,255,255,0.04));
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 14px;
    padding: 7px 10px;
    line-height: 1;
    cursor: pointer;
    color: #fff;
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: transform 0.15s, box-shadow 0.15s, background 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.booster-icon { font-size: 20px; line-height: 1; }
.booster:hover {
    background: linear-gradient(135deg, rgba(255,255,255,0.14), rgba(255,255,255,0.06));
}
.booster:disabled { opacity: 0.45; cursor: not-allowed; }
.booster:active { transform: scale(0.94); }
.booster.active {
    background: linear-gradient(135deg, rgba(255,215,0,0.35), rgba(255,140,0,0.18));
    border-color: rgba(255,215,0,0.5);
    box-shadow: 0 0 20px rgba(255,215,0,0.45), inset 0 1px 0 rgba(255,255,255,0.15);
}
.booster-price {
    font-size: 13px;
    color: #ffd700;
    font-weight: 700;
    letter-spacing: 0.3px;
    line-height: 1;
}
.candy.hint-pulse {
    animation: hintPulse 1s ease-in-out 3;
    z-index: 2;
}
@keyframes hintPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 rgba(255,215,0,0); }
    50%      { transform: scale(1.18); box-shadow: 0 0 24px rgba(255,215,0,0.9), 0 0 0 3px rgba(255,215,0,0.6); }
}

/* Hammer boom — radial flash + scale */
.candy.hammer-hit {
    animation: hammerBoom 0.5s ease-out forwards;
    z-index: 3;
}
@keyframes hammerBoom {
    0%   { transform: scale(1);   box-shadow: 0 0 0 0 rgba(255,80,80,0.0); }
    30%  { transform: scale(1.4); box-shadow: 0 0 30px 8px rgba(255,80,80,0.6); }
    100% { transform: scale(0);   box-shadow: 0 0 0 30px rgba(255,80,80,0); opacity: 0; }
}

/* Booster flash on application */
.booster.firing {
    animation: boosterFire 0.6s ease-out;
}
@keyframes boosterFire {
    0%   { transform: scale(1);   box-shadow: 0 0 0 0 rgba(255,215,0,0); }
    40%  { transform: scale(1.18); box-shadow: 0 0 30px rgba(255,215,0,0.8), inset 0 0 16px rgba(255,215,0,0.4); }
    100% { transform: scale(1);   box-shadow: 0 0 0 rgba(255,215,0,0); }
}

/* Shuffle: tiles fade-spin (legacy, unused) */
.candy.shuffling {
    animation: shuffleSpin 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes shuffleSpin {
    0%   { transform: rotate(0)        scale(1);    opacity: 1; }
    50%  { transform: rotate(180deg)   scale(0.4);  opacity: 0.3; }
    100% { transform: rotate(360deg)   scale(1);    opacity: 1; }
}

/* Shuffle scatter-gather: tiles fly out, symbols swap, tiles fly back */
.candy.shuffle-scatter {
    animation: shuffleScatter 0.38s cubic-bezier(0.4, 0, 0.6, 1) forwards;
    z-index: 5;
}
@keyframes shuffleScatter {
    0%   { transform: translate(0,0) rotate(0) scale(1);   opacity: 1; }
    100% { transform: translate(var(--sx,0), var(--sy,0)) rotate(var(--srot,0)) scale(0.25); opacity: 0; }
}
.candy.shuffle-gather {
    animation: shuffleGather 0.45s cubic-bezier(0.2, 1.3, 0.4, 1) forwards;
    z-index: 5;
}
@keyframes shuffleGather {
    0%   { transform: translate(var(--sx,0), var(--sy,0)) rotate(var(--srot,0)) scale(0.25); opacity: 0; }
    60%  { opacity: 1; }
    100% { transform: translate(0,0) rotate(0) scale(1); opacity: 1; }
}

.score-board {
    flex-shrink: 0;
    font-size: clamp(13px, 3.6vw, 16px);
    color: #fff;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 8px 16px;
    border-radius: 14px;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    max-width: 600px;
}
.score-board #score, .score-board #bestScore {
    color: #fff;
    font-size: 1.2em;
    font-weight: 800;
    text-transform: none;
    margin-left: 6px;
}
.score-board .best-score {
    opacity: 0.7;
    font-weight: 500;
}
.sound-toggle {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    color: rgba(255,255,255,0.85);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s, color 0.2s;
}
.sound-toggle svg { width: 16px; height: 16px; display: block; }
.sound-toggle:hover  { background: rgba(255,255,255,0.14); color: #fff; }
.sound-toggle:active { transform: scale(0.92); }

.board-wrap {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#board {
    position: relative;
    width: min(100%, 100%);
    aspect-ratio: 1;
    max-width: 100%;
    max-height: 100%;
    background:
        radial-gradient(circle at 30% 30%, rgba(186, 104, 200, 0.10), transparent 60%),
        rgba(255, 255, 255, 0.04);
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255,255,255,0.05);
    backdrop-filter: blur(6px);
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 4px;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    container-type: inline-size;
}

.candy {
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    /* 13% of board width = ~78% of cell width — large but not clipped */
    font-size: 13cqi;
    line-height: 1;
    user-select: none;
    position: relative;
    z-index: 1;
    background:
        linear-gradient(135deg, rgba(255,255,255,0.10), rgba(255,255,255,0.03));
    border: 1px solid rgba(255,255,255,0.06);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 2px 4px rgba(0,0,0,0.15);
    aspect-ratio: 1;
}
/* Fallback for browsers without container queries */
@supports not (font-size: 1cqi) {
    .candy { font-size: clamp(24px, 10vmin, 56px); }
}

.candy:hover {
    transform: scale(1.05);
    background: linear-gradient(135deg, rgba(255,255,255,0.18), rgba(255,255,255,0.06));
}

.candy.selected {
    animation: pulse 1s infinite;
    background: linear-gradient(135deg, rgba(255,215,0,0.30), rgba(255,140,0,0.18));
    border-color: rgba(255,215,0,0.5);
    border-radius: 14px;
    box-shadow: 0 0 24px rgba(255, 215, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.15);
}

/* Drag-and-drop visuals — source follows finger instantly and floats above; target slides smoothly. */
.candy.dragging {
    z-index: 10;
    cursor: grabbing;
    touch-action: none;
    transition: none !important;
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.35));
}
.candy.drag-target {
    z-index: 1;
    transition: transform 0.12s ease-out !important;
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4); }
    50% { transform: scale(0.95); box-shadow: 0 0 20px rgba(255, 255, 255, 0.2); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

@keyframes borderPulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes pop {
    0%   { transform: scale(1);     filter: brightness(1)   blur(0); opacity: 1; }
    25%  { transform: scale(1.18);  filter: brightness(1.4) blur(0); opacity: 1; }
    100% { transform: scale(0.15);  filter: brightness(2)   blur(2px); opacity: 0; }
}

.candy.matched {
    animation: pop 0.45s cubic-bezier(0.4, 0, 0.6, 1) forwards;
    pointer-events: none;
    z-index: 3;
}

/* ── Special detonations: 💣 bomb and 🌟 star blow up instead of a plain pop ── */
.candy.bomb-detonate { animation: bombBoom 0.5s ease-out forwards; pointer-events: none; z-index: 4; }
@keyframes bombBoom {
    0%   { transform: scale(1);   filter: brightness(1); }
    22%  { transform: scale(1.55); filter: brightness(2.3) drop-shadow(0 0 18px rgba(255,150,20,0.95)); }
    55%  { transform: scale(1.25); filter: brightness(1.9) drop-shadow(0 0 26px rgba(255,80,0,0.85)); }
    100% { transform: scale(0.1); filter: brightness(2.6); opacity: 0; }
}
.candy.star-detonate { animation: starBoom 0.55s ease-out forwards; pointer-events: none; z-index: 4; }
@keyframes starBoom {
    0%   { transform: scale(1) rotate(0);       filter: brightness(1); }
    30%  { transform: scale(1.6) rotate(90deg); filter: brightness(2.5) drop-shadow(0 0 24px rgba(130,200,255,0.95)); }
    100% { transform: scale(0.1) rotate(230deg);filter: brightness(2.7); opacity: 0; }
}

/* Shockwave ring (appended to <body>, centred on the tile) */
.blast-ring {
    position: fixed; width: 22px; height: 22px; border-radius: 50%;
    transform: translate(-50%, -50%); pointer-events: none; z-index: 1200;
    border: 4px solid rgba(255,150,40,0.9);
    box-shadow: 0 0 26px rgba(255,120,0,0.7);
    animation: blastRing 0.55s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
.blast-ring.star { border-color: rgba(150,210,255,0.92); box-shadow: 0 0 26px rgba(120,180,255,0.75); }
@keyframes blastRing {
    0%   { width: 22px;  height: 22px;  opacity: 0.95; border-width: 5px; }
    100% { width: 160px; height: 160px; opacity: 0;    border-width: 1px; }
}

/* Burst glyphs flying outward */
.blast-particle {
    position: fixed; pointer-events: none; z-index: 1201; font-size: 20px;
    animation: blastFly 0.62s cubic-bezier(0.25, 0.6, 0.35, 1) forwards;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}
@keyframes blastFly {
    0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 1; }
    100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.15); opacity: 0; }
}

/* ── Super bomb (three bombs in a line) — a board-wide detonation ────────── */
.candy.super-detonate {
    animation: superBoom 0.6s ease-out forwards;
    pointer-events: none; z-index: 5;
}
@keyframes superBoom {
    0%   { transform: scale(1);                    filter: brightness(1); }
    18%  { transform: scale(1.7);                  filter: brightness(2.6) drop-shadow(0 0 22px rgba(255,180,40,0.95)); }
    50%  { transform: scale(1.3);                  filter: brightness(2.2) drop-shadow(0 0 30px rgba(255,90,0,0.9)); }
    100% { transform: scale(0.05) rotate(40deg);   filter: brightness(3); opacity: 0; }
}

/* Big shockwave ring from the board centre (appended to <body>) */
.super-ring {
    position: fixed; width: 40px; height: 40px; border-radius: 50%;
    transform: translate(-50%, -50%); pointer-events: none; z-index: 1300;
    border: 8px solid rgba(255,170,40,0.95);
    box-shadow: 0 0 40px rgba(255,120,0,0.85), inset 0 0 30px rgba(255,200,80,0.6);
    animation: superRing 0.68s cubic-bezier(0.15,0.75,0.3,1) forwards;
}
@keyframes superRing {
    0%   { width: 40px;  height: 40px;  opacity: 1; border-width: 8px; }
    100% { width: 460px; height: 460px; opacity: 0; border-width: 1px; }
}

/* Radial flash overlaying the board */
.super-flash {
    position: absolute; inset: 0; pointer-events: none; z-index: 6;
    border-radius: inherit;
    background: radial-gradient(circle at center, rgba(255,240,190,0.95), rgba(255,150,40,0.35) 55%, transparent 75%);
    animation: superFlash 0.5s ease-out forwards;
}
@keyframes superFlash {
    0%   { opacity: 0; }
    15%  { opacity: 1; }
    100% { opacity: 0; }
}

/* Screen shake on the whole game box */
.super-shake { animation: superShake 0.6s cubic-bezier(0.36,0.07,0.19,0.97); }
@keyframes superShake {
    0%,100% { transform: translate(0,0); }
    10% { transform: translate(-6px,-3px) rotate(-0.6deg); }
    20% { transform: translate(7px,2px)   rotate(0.6deg); }
    30% { transform: translate(-8px,3px)  rotate(-0.5deg); }
    40% { transform: translate(6px,-2px)  rotate(0.5deg); }
    55% { transform: translate(-4px,2px); }
    70% { transform: translate(4px,-1px); }
    85% { transform: translate(-2px,1px); }
}

/* Bigger burst glyphs + the "СУПЕРБОМБА!" callout */
.blast-particle.super { font-size: 30px; z-index: 1301; }
.super-label {
    position: fixed; left: 50%; top: 42%;
    transform: translate(-50%, -50%);
    pointer-events: none; z-index: 1400;
    font-weight: 800; font-size: 30px; letter-spacing: 1px; white-space: nowrap;
    color: #fff; text-shadow: 0 0 10px rgba(255,150,30,0.95), 0 2px 6px rgba(0,0,0,0.4);
    animation: superLabel 1.05s ease-out forwards;
}
@keyframes superLabel {
    0%   { opacity: 0; transform: translate(-50%,-50%) scale(0.5); }
    18%  { opacity: 1; transform: translate(-50%,-50%) scale(1.15); }
    32%  { transform: translate(-50%,-50%) scale(1); }
    75%  { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%,-60%) scale(1); }
}

@keyframes drop {
    0%   { transform: translateY(-110%) scale(0.85); opacity: 0; }
    60%  { opacity: 1; }
    85%  { transform: translateY(8%)    scale(1.03); opacity: 1; }
    100% { transform: translateY(0)     scale(1);    opacity: 1; }
}

.candy.dropping {
    animation: drop 0.45s cubic-bezier(0.34, 1.2, 0.5, 1) both;
    z-index: 2;
}

@keyframes fountain {
    0% {
        transform: translateY(0) scale(1) rotate(0deg);
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
    100% {
        transform: translateY(-150px) scale(0) rotate(360deg);
        opacity: 0;
    }
}

.particle {
    position: fixed;
    pointer-events: none;
    animation: fountain 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    z-index: 1000;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

@keyframes invalidMove {
    0% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
    100% { transform: translateX(0); }
}

.candy.invalid-move {
    animation: invalidMove 0.5s ease-in-out;
    background: rgba(255, 0, 0, 0.2);
}

/* Удалим стили для кнопки сброса */
.reset-button {
    display: none;
}

.best-score {
    font-size: 0.8em;
    opacity: 0.8;
}

@keyframes comboAppear {
    0% {
        transform: translateY(20px);
        opacity: 0;
    }
    40% {
        transform: translateY(-10px);
        opacity: 1;
    }
    60% {
        transform: translateY(5px);
    }
    80% {
        transform: translateY(-2px);
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes comboDisappear {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    20% {
        transform: translateY(-5px);
        opacity: 0.8;
    }
    100% {
        transform: translateY(-20px);
        opacity: 0;
    }
}

.combo-display {
    font-size: 1.2em;
    color: #ffeb3b;
    text-shadow: 0 0 10px rgba(255, 235, 59, 0.5);
    margin-top: 20px;
    text-align: center;
    display: none;
    font-weight: bold;
    position: relative;
}

.combo-display.show {
    display: block;
    animation: comboAppear 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.combo-display.hide {
    animation: comboDisappear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes comboScale {
    0% { transform: scale(1.2); }
    50% { transform: scale(1.4); }
    100% { transform: scale(1); }
}

.combo-effect {
    position: absolute;
    color: white;
    font-size: 1.5em;
    font-weight: bold;
    pointer-events: none;
    animation: floatUp 1s ease-out forwards;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.combo-effect.combo-active {
    color: #ffeb3b;
    font-size: 1.8em;
    text-shadow: 0 0 10px rgba(255, 235, 59, 0.5);
}

@keyframes floatUp {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-50px) scale(1.2);
        opacity: 0;
    }
}

/* Добавим стили для языкового селектора */
.language-selector,
.lang-btn {
    display: none;
}

/* Добавим поддержку RTL для арабского языка */
[dir="rtl"] .score-board {
    direction: rtl;
}

.game-over {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.game-over.show {
    opacity: 1;
    pointer-events: all;
}

.game-over-text {
    color: white;
    font-size: 3em;
    font-weight: bold;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    animation: gameOverPulse 2s infinite;
}

.restart-button {
    background: #ffeb3b;
    border: none;
    padding: 15px 30px;
    border-radius: 34px;
    color: #333;
    font-size: 1.2em;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(255, 235, 59, 0.3);
}

.restart-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(255, 235, 59, 0.4);
    background: #fff176;
}

.restart-button:active {
    transform: translateY(0);
}

@keyframes gameOverPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
} 