@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;700&display=swap');


:root {
    --pink: #F72585;
    --purple-1: #7209B7;
    --purple-2: #560BAD;
    --purple-3: #480CA8;
    --blue-1: #6C63FF;
    --blue-2: #4361EE;
    --blue-3: #4CC9F0;
    --bg-dark: #1a1a2e;
    --bg-light: #16213e;
    --bg-grid: #1e2a45;
    --text-light: #e8eaf6;
    --shadow-light: rgba(255, 255, 255, 0.15);
    --shadow-dark: rgba(0, 0, 0, 0.25);
    --grid-line: rgba(255, 255, 255, 0.04);
    --glow-pink: rgba(247, 37, 133, 0.5);
}

/* --- Global & Mobile Reset --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* =============================================================
   DO NOT CHANGE THIS html RULE — IT FIXES THE iOS PWA BOTTOM GAP
   The min-height hack + safe-area padding on html is REQUIRED.
   Without it, position:fixed elements get a gap at the bottom
   on iOS 26 standalone PWAs. Took 6 attempts to get this right.
   ============================================================= */
html {
    min-height: calc(100% + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: #1a1a2e;
    overflow: hidden;
}
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #1a1a2e;
    font-family: 'Poppins', sans-serif;
    color: var(--text-light);
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

/* --- Login/Register Page --- */
.login-register {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #1a1a2e 0%, #16213e 40%, #0f3460 100%);
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.form-container {
    background: rgba(22, 33, 62, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 40px 30px;
    border-radius: 20px;
    text-align: center;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.4), 0 0 80px rgba(108, 99, 255, 0.08);
    border: 1px solid rgba(108, 99, 255, 0.25);
    animation: form-slide-in 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes form-slide-in {
    from { opacity: 0; transform: translateY(30px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.form-container .logo {
    width: 180px;
    margin-bottom: 24px;
    filter: drop-shadow(0 0 25px rgba(247, 37, 133, 0.35));
}
.form-container h1 {
    margin-bottom: 24px;
    color: var(--blue-3);
    font-size: 28px;
    letter-spacing: 2px;
    text-shadow: 0 0 20px rgba(76, 201, 240, 0.3);
}
.form-container input {
    width: 100%;
    padding: 16px 18px;
    margin-bottom: 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(26, 26, 46, 0.7);
    color: var(--text-light);
    font-size: 16px;
    font-family: 'Poppins', sans-serif;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    outline: none;
}
.form-container input:focus {
    border-color: var(--pink);
    box-shadow: 0 0 18px rgba(247, 37, 133, 0.3);
}
.form-container input::placeholder {
    color: rgba(232, 234, 246, 0.35);
}
.form-container button {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #F72585, #7209B7);
    color: white;
    font-weight: bold;
    font-size: 18px;
    letter-spacing: 1px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 20px rgba(247, 37, 133, 0.35);
    font-family: 'Poppins', sans-serif;
}
.form-container button:hover {
    transform: scale(1.03);
    box-shadow: 0 6px 30px rgba(247, 37, 133, 0.55);
}
.form-container a {
    color: var(--blue-3);
    text-decoration: none;
    display: block;
    margin-top: 20px;
    font-size: 14px;
    transition: color 0.2s ease;
}
.form-container a:hover {
    color: var(--pink);
}
.form-container .error {
    color: var(--pink);
    margin-bottom: 15px;
    font-size: 14px;
    text-shadow: 0 0 10px rgba(247, 37, 133, 0.3);
}
.form-container .success {
    color: #4CC9F0;
    margin-bottom: 15px;
    font-size: 14px;
    text-shadow: 0 0 10px rgba(76, 201, 240, 0.3);
}
.form-container .form-subtitle {
    color: rgba(232, 234, 246, 0.5);
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.5;
}
.form-container .btn-back-login {
    display: block;
    width: 100%;
    padding: 14px 20px;
    margin-top: 15px;
    background: rgba(108, 99, 255, 0.15);
    border: 1px solid rgba(108, 99, 255, 0.3);
    border-radius: 14px;
    color: var(--blue-3);
    font-size: 15px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    box-sizing: border-box;
}
.form-container .btn-back-login:hover {
    background: rgba(108, 99, 255, 0.25);
    border-color: rgba(108, 99, 255, 0.5);
    color: #fff;
}
.form-container .form-links {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.form-container .form-links a {
    color: var(--blue-3);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s ease;
    margin-top: 0;
}
.form-container .form-links a:first-child {
    color: rgba(232, 234, 246, 0.45);
    font-size: 13px;
}
.form-container .form-links a:first-child:hover {
    color: var(--pink);
}

/* --- Install Page --- */
.install-container h1 {
    margin-bottom: 8px;
}
.install-tagline {
    color: var(--pink);
    font-size: 15px;
    letter-spacing: 1px;
    margin-bottom: 28px;
}
.install-instructions {
    text-align: left;
    width: 100%;
}
.install-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid rgba(108, 99, 255, 0.12);
    color: var(--text-light);
    font-size: 15px;
    line-height: 1.4;
}
.install-step:last-child {
    border-bottom: none;
}
.install-icon {
    font-size: 22px;
    flex-shrink: 0;
    width: 32px;
    text-align: center;
}
.install-btn-hidden {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #F72585, #7209B7);
    color: white;
    font-weight: bold;
    font-size: 18px;
    letter-spacing: 1px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(247, 37, 133, 0.35);
    font-family: 'Poppins', sans-serif;
    margin-bottom: 20px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.install-btn-hidden:hover {
    transform: scale(1.03);
    box-shadow: 0 6px 30px rgba(247, 37, 133, 0.55);
}

/* --- Loading Screen --- */
#loading-screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(160deg, #1a1a2e 0%, #16213e 40%, #0f3460 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.5s ease;
    /* Fixed elements ignore html padding — need their own safe area */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#loading-screen .logo {
    width: 260px;
    filter: drop-shadow(0 0 15px rgba(114, 9, 183, 0.45)) drop-shadow(0 0 35px rgba(247, 37, 133, 0.2));
    animation: logoBreath 3s ease-in-out 0.8s infinite;
}
#loading-screen .logo-wrap {
    position: relative;
    display: inline-block;
    animation: logoZoomIn 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
#loading-screen .tagline {
    margin: 20px 0;
    font-style: italic;
    color: var(--blue-3);
    font-size: 16px;
    letter-spacing: 1px;
    opacity: 0;
    animation: fadeIn 1s ease-out 0.5s forwards;
    max-width: 90%;
    text-align: center;
    line-height: 1.4;
    padding: 0 15px;
}
#start-game-button {
    background: linear-gradient(135deg, #F72585, #7209B7);
    color: white;
    padding: 16px 50px;
    border: none;
    border-radius: 12px;
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 1px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 25px rgba(247, 37, 133, 0.4);
    font-family: 'Poppins', sans-serif;
    margin-top: 30px;
}
#start-game-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 35px rgba(247, 37, 133, 0.6);
}

.spinner {
    border: 4px solid var(--shadow-light);
    border-top: 4px solid var(--pink);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

#loading-screen .loading-version {
    position: absolute;
    bottom: 12px;
    right: 16px;
    font-size: 12px;
    color: rgba(232, 234, 246, 0.35);
    letter-spacing: 1px;
}

/* Desktop: bigger logos */
@media (min-width: 768px) {
    #loading-screen .logo { width: 400px; }
    .game-logo { width: 160px; }
    .form-container .logo { width: 220px; }
}

/* --- Game Layout --- */
#game-container {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: linear-gradient(160deg, #1a1a2e 0%, #16213e 40%, #0f3460 100%);
    overflow: hidden;
}
header {
    display: flex;
    flex-direction: column;
    padding: 6px 10px 2px;
    gap: 4px;
}
.header-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0 6px;
}
.header-score-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    width: 100%;
}
.game-logo {
    width: 80px;
    flex-shrink: 0;
}

/* Info Button */
#info-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1.5px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.08);
    color: var(--blue-3);
    font-size: 16px;
    font-weight: bold;
    font-style: italic;
    font-family: Georgia, serif;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    flex-shrink: 0;
}
#info-btn:hover { transform: scale(1.1); background: rgba(255,255,255,0.15); }

/* Burger Menu Button */
#burger-btn {
    width: 32px;
    height: 32px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    border: 1.5px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.08);
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    padding: 0;
    flex-shrink: 0;
}
#burger-btn span {
    display: block;
    width: 16px;
    height: 2px;
    background: var(--blue-3);
    border-radius: 2px;
}
#burger-btn:hover { transform: scale(1.1); background: rgba(255,255,255,0.15); }
.score-box {
    background: rgba(22, 33, 62, 0.85);
    padding: 6px 10px;
    border-radius: 12px;
    text-align: center;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
}
.score-box:hover {
    transform: scale(1.05);
}
.score-box div:first-child { font-size: 12px; color: var(--blue-3); letter-spacing: 2px; }
.score-box div:last-child { font-size: 20px; color: white; white-space: nowrap; }

/* Score pop animation */
.score-pop {
    animation: score-pop 0.3s ease-out;
}
@keyframes score-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); color: var(--pink); }
    100% { transform: scale(1); }
}

main {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 6px;
    min-height: 0;
    overflow: visible;
}
#grid-container {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: min(95vw, 100%);
    aspect-ratio: 1 / 1;
    max-width: 560px;
    max-height: 100%;
    background: var(--bg-grid);
    border: 2px solid rgba(108, 99, 255, 0.3);
    border-radius: 14px;
    box-shadow: 0 0 40px rgba(108, 99, 255, 0.1), inset 0 0 30px rgba(0, 0, 0, 0.2);
    position: relative;
    contain: layout style;
}
.grid-cell {
    position: relative;
    border: 1px solid var(--grid-line);
    contain: layout style paint;
}

/* --- Block Pop Blocks (squarish with rounded corners, like the logo) --- */
.block {
    border-radius: 22%;
    transform: scale(0.92);
    box-shadow:
        inset 3px 3px 6px rgba(255, 255, 255, 0.5),
        inset -2px -2px 4px rgba(0, 0, 0, 0.25),
        0 3px 6px rgba(0, 0, 0, 0.35);
    position: relative;
    overflow: hidden;
    will-change: transform;
}
/* Glossy shine highlight (top-left like the logo) */
.block::before {
    content: '';
    position: absolute;
    top: 8%;
    left: 12%;
    width: 45%;
    height: 40%;
    background: linear-gradient(160deg, rgba(255,255,255,0.6) 0%, rgba(255,255,255,0.15) 40%, rgba(255,255,255,0) 70%);
    border-radius: 22%;
    pointer-events: none;
}
/* Subtle idle breathing — blocks feel alive */
@keyframes block-idle {
    0%, 100% { transform: scale(0.92); box-shadow: inset 3px 3px 6px rgba(255,255,255,0.5), inset -2px -2px 4px rgba(0,0,0,0.25), 0 3px 6px rgba(0,0,0,0.35); }
    50% { transform: scale(0.94); box-shadow: inset 3px 3px 6px rgba(255,255,255,0.55), inset -2px -2px 4px rgba(0,0,0,0.2), 0 4px 10px rgba(0,0,0,0.25); }
}
/* Candy colors with logo-style gradient (top-left highlight) */
.color-1  { background: linear-gradient(145deg, #ff7eb3 0%, #F72585 60%, #d11d6f 100%); } /* Rose */
.color-2  { background: linear-gradient(145deg, #b380ff 0%, #7209B7 60%, #5c069a 100%); } /* Violet */
.color-3  { background: linear-gradient(145deg, #8b7aff 0%, #5c4de5 60%, #4538c7 100%); } /* Lavender */
.color-4  { background: linear-gradient(145deg, #7c9aff 0%, #4361EE 60%, #2f4dd4 100%); } /* Cornflower */
.color-5  { background: linear-gradient(145deg, #6ee7b7 0%, #10b981 60%, #0a9468 100%); } /* Mint */
.color-6  { background: linear-gradient(145deg, #fcd34d 0%, #f59e0b 60%, #d48506 100%); } /* Sunshine */
.color-7  { background: linear-gradient(145deg, #93c5fd 0%, #3b82f6 60%, #2563d9 100%); } /* Sky */
.color-8  { background: linear-gradient(145deg, #ffa07a 0%, #e85d3a 60%, #c94420 100%); } /* Coral */
.color-9  { background: linear-gradient(145deg, #ffc9a8 0%, #f4845f 60%, #d96940 100%); } /* Peach */
.color-10 { background: linear-gradient(145deg, #5eead4 0%, #14b8a6 60%, #0d9488 100%); } /* Teal */

/* --- Piece Container --- */
footer {
    flex-shrink: 0;
    height: 172px;
    overflow: visible;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 0;
    position: relative;
    z-index: 10;
}
#pieces-container {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: stretch;
    justify-items: stretch;
    width: 100%;
    height: 100%;
    overflow: visible;
}
.piece-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
    overflow: visible;
    cursor: pointer;
}
.piece-slot.used {
    visibility: hidden;
    pointer-events: none;
}
.piece-preview {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    cursor: grab;
    transition: transform 0.2s ease, opacity 0.2s ease;
    padding: 6px;
}
.piece-preview:active {
    cursor: grabbing;
    transform: scale(1.2);
}
.piece-preview-cell {
    width: min(30px, 7vw);
    height: min(30px, 7vw);
}
.piece-preview-cell.block {
    border-radius: 22%;
}

/* Piece spawn animation */
.piece-spawn {
    animation: piece-spawn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.piece-slot:nth-child(1) .piece-spawn { animation-delay: 0s; }
.piece-slot:nth-child(2) .piece-spawn { animation-delay: 0.08s; }
.piece-slot:nth-child(3) .piece-spawn { animation-delay: 0.16s; }

@keyframes piece-spawn {
    0% { transform: scale(0) translateY(30px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* --- Animations & Effects --- */

/* Block pop (clear animation) */
.bubble-pop {
    animation: bubble-pop 0.5s ease-out forwards !important;
}
@keyframes bubble-pop {
    0% { transform: scale(0.92); opacity: 1; }
    25% { transform: scale(1.15) rotate(3deg); opacity: 1; }
    50% { transform: scale(1.3) rotate(-2deg); opacity: 0.7; }
    100% { transform: scale(0) rotate(5deg); opacity: 0; }
}

/* Keep old class name working as fallback */
.line-clear-flash {
    animation: bubble-pop 0.5s ease-out forwards !important;
}

/* Block place: gentle plop with a single soft bounce */
.plop-animation {
    animation: plop-drop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}
@keyframes plop-drop {
    0%   { transform: scale(0.4) translateY(-12px); opacity: 0; }
    50%  { transform: scale(0.96) translateY(1px); opacity: 1; }
    75%  { transform: scale(0.90); opacity: 1; }
    100% { transform: scale(0.92); opacity: 1; }
}

/* --- Screen Shake (3 intensity levels) --- */
.shake-light  { animation: shake-light  0.25s ease-in-out; }
.shake-medium { animation: shake-medium 0.35s ease-in-out; }
.shake-heavy  { animation: shake-heavy  0.45s ease-in-out; }

@keyframes shake-light {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-3px, -2px); }
    50% { transform: translate(3px, 2px); }
    75% { transform: translate(-2px, 3px); }
}

@keyframes shake-medium {
    0%, 100% { transform: translate(0, 0); }
    15% { transform: translate(-5px, -3px); }
    30% { transform: translate(4px, 4px); }
    45% { transform: translate(-4px, 3px); }
    60% { transform: translate(5px, -4px); }
    75% { transform: translate(-3px, 4px); }
    90% { transform: translate(3px, -2px); }
}

@keyframes shake-heavy {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    10% { transform: translate(-8px, -4px) rotate(-1deg); }
    20% { transform: translate(7px, 5px) rotate(1deg); }
    30% { transform: translate(-6px, 6px) rotate(-0.5deg); }
    40% { transform: translate(8px, -5px) rotate(0.5deg); }
    50% { transform: translate(-7px, 4px) rotate(-1deg); }
    60% { transform: translate(5px, -6px) rotate(0.5deg); }
    70% { transform: translate(-8px, 5px) rotate(-0.5deg); }
    80% { transform: translate(6px, -4px) rotate(1deg); }
    90% { transform: translate(-4px, 6px) rotate(0deg); }
}

/* --- Combo Text: BIG, IN YOUR FACE --- */
.combo-text {
    position: absolute;
    top: 50%;
    left: 50%;
    font-weight: 900;
    color: white;
    padding: 18px 40px;
    border-radius: 20px;
    pointer-events: none;
    white-space: nowrap;
    font-size: clamp(2.5rem, 11vw, 5rem);
    z-index: 60;
    opacity: 0;
    animation: combo-slam 1.8s cubic-bezier(0.16, 1, 0.3, 1);
    letter-spacing: 3px;
    text-transform: uppercase;
    text-shadow: 0 4px 15px rgba(0,0,0,0.5), 0 0 40px currentColor;
    -webkit-text-stroke: 1.5px rgba(255,255,255,0.3);
    max-width: 95vw;
}
.combo-text.combo-x2 {
    background: linear-gradient(135deg, #6ee7b7, #10b981, #059669);
    box-shadow: 0 0 60px rgba(16, 185, 129, 0.8), 0 0 120px rgba(16, 185, 129, 0.3), inset 0 2px 4px rgba(255,255,255,0.5);
    font-size: clamp(2.5rem, 11vw, 5rem);
}
.combo-text.combo-x3 {
    background: linear-gradient(135deg, #93c5fd, #3b82f6, #1d4ed8);
    box-shadow: 0 0 70px rgba(59, 130, 246, 0.8), 0 0 140px rgba(59, 130, 246, 0.3), inset 0 2px 4px rgba(255,255,255,0.5);
    font-size: clamp(2.8rem, 12vw, 5.5rem);
}
.combo-text.combo-x4 {
    background: linear-gradient(135deg, #fcd34d, #f59e0b, #d97706);
    box-shadow: 0 0 80px rgba(245, 158, 11, 0.9), 0 0 160px rgba(245, 158, 11, 0.4), inset 0 2px 4px rgba(255,255,255,0.5);
    font-size: clamp(3.2rem, 13vw, 6rem);
    animation: combo-slam-wild 1.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.combo-text.combo-x5 {
    background: linear-gradient(135deg, #ff7eb3, #F72585, #be185d);
    box-shadow: 0 0 100px rgba(247, 37, 133, 1), 0 0 200px rgba(247, 37, 133, 0.5), inset 0 2px 4px rgba(255,255,255,0.5);
    font-size: clamp(3.5rem, 14vw, 7rem);
    animation: combo-slam-wild 1.8s cubic-bezier(0.16, 1, 0.3, 1);
}
/* Glossy streak across combo badge */
.combo-text::before {
    content: '';
    position: absolute;
    top: 0;
    left: -60%;
    width: 40%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    border-radius: 20px;
    pointer-events: none;
    animation: combo-shine 0.6s 0.15s ease-out forwards;
}

/* Standard slam: zoom in from huge, bounce, hold, then fly up */
@keyframes combo-slam {
    0%   { transform: translate(-50%, -50%) scale(3) rotate(-3deg); opacity: 0; }
    8%   { transform: translate(-50%, -50%) scale(0.85) rotate(1deg); opacity: 1; }
    16%  { transform: translate(-50%, -50%) scale(1.1) rotate(-0.5deg); opacity: 1; }
    24%  { transform: translate(-50%, -50%) scale(0.97) rotate(0deg); opacity: 1; }
    32%  { transform: translate(-50%, -50%) scale(1.02); opacity: 1; }
    65%  { transform: translate(-50%, -50%) scale(1.0); opacity: 1; }
    100% { transform: translate(-50%, -250%) scale(0.6); opacity: 0; }
}

/* Wild slam for x4+: adds wobble shake while visible */
@keyframes combo-slam-wild {
    0%   { transform: translate(-50%, -50%) scale(4) rotate(-5deg); opacity: 0; }
    8%   { transform: translate(-50%, -50%) scale(0.8) rotate(2deg); opacity: 1; }
    14%  { transform: translate(-50%, -50%) scale(1.15) rotate(-2deg); opacity: 1; }
    20%  { transform: translate(-50%, -50%) scale(0.95) rotate(1deg); opacity: 1; }
    28%  { transform: translate(-50%, -50%) scale(1.05) rotate(-1deg); opacity: 1; }
    36%  { transform: translate(-50%, -48%) scale(1.02) rotate(0.5deg); opacity: 1; }
    44%  { transform: translate(-50%, -52%) scale(1.0) rotate(-0.5deg); opacity: 1; }
    52%  { transform: translate(-50%, -48%) scale(1.01) rotate(0.3deg); opacity: 1; }
    65%  { transform: translate(-50%, -50%) scale(1.0) rotate(0deg); opacity: 1; }
    100% { transform: translate(-50%, -300%) scale(0.5) rotate(3deg); opacity: 0; }
}

/* Shine streak across the badge */
@keyframes combo-shine {
    0% { left: -60%; }
    100% { left: 120%; }
}

/* --- Hype Escalation: Grid Glow --- */
#grid-container.hype-1 {
    box-shadow: 0 0 40px rgba(108, 99, 255, 0.2), 0 0 80px rgba(16, 185, 129, 0.15), inset 0 0 30px rgba(0, 0, 0, 0.2);
    border-color: rgba(16, 185, 129, 0.5);
    transition: box-shadow 0.5s ease, border-color 0.5s ease;
}
#grid-container.hype-2 {
    box-shadow: 0 0 50px rgba(59, 130, 246, 0.3), 0 0 100px rgba(59, 130, 246, 0.2), inset 0 0 30px rgba(0, 0, 0, 0.2);
    border-color: rgba(59, 130, 246, 0.6);
    transition: box-shadow 0.5s ease, border-color 0.5s ease;
}
#grid-container.hype-3 {
    box-shadow: 0 0 60px rgba(245, 158, 11, 0.4), 0 0 120px rgba(245, 158, 11, 0.2), inset 0 0 30px rgba(0, 0, 0, 0.2);
    border-color: rgba(245, 158, 11, 0.7);
    transition: box-shadow 0.5s ease, border-color 0.5s ease;
}
#grid-container.hype-4 {
    box-shadow: 0 0 80px rgba(247, 37, 133, 0.6), 0 0 160px rgba(247, 37, 133, 0.35), inset 0 0 30px rgba(0, 0, 0, 0.2);
    border-color: rgba(247, 37, 133, 0.8);
    animation: hype-pulse 0.6s ease-in-out infinite alternate;
    transition: box-shadow 0.5s ease, border-color 0.5s ease;
}
@keyframes hype-pulse {
    0% { opacity: 0.75; }
    100% { opacity: 1; }
}

/* --- Multiplier Badge (persistent top-right of grid) --- */
.multiplier-badge {
    position: absolute;
    top: -10px;
    right: -6px;
    background: linear-gradient(135deg, #fcd34d, #f59e0b);
    color: #1a1a2e;
    font-weight: bold;
    font-size: 0.95rem;
    padding: 5px 14px;
    border-radius: 20px;
    z-index: 100;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.5), inset 0 1px 2px rgba(255,255,255,0.4);
    pointer-events: none;
    animation: badge-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.multiplier-badge.hot {
    background: linear-gradient(135deg, #ff7eb3, #F72585);
    color: white;
    box-shadow: 0 0 20px rgba(247, 37, 133, 0.6), inset 0 1px 2px rgba(255,255,255,0.4);
}
@keyframes badge-in {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

/* --- Blast Radius flash on adjacent cells --- */
.blast-pop {
    animation: blast-pop 0.4s ease-out forwards;
}
@keyframes blast-pop {
    0% { transform: scale(0.92); opacity: 1; background: white; }
    50% { transform: scale(1.2); opacity: 0.7; }
    100% { transform: scale(0); opacity: 0; }
}

/* --- Score Fly-up Text --- */
.score-flyup {
    position: absolute;
    font-weight: bold;
    font-size: 1.4rem;
    color: white;
    text-shadow: 0 0 10px rgba(255,255,255,0.6);
    pointer-events: none;
    z-index: 55;
    animation: score-flyup 1s ease-out forwards;
}
@keyframes score-flyup {
    0% { transform: translateY(0) scale(0.8); opacity: 1; }
    50% { transform: translateY(-40px) scale(1.1); opacity: 1; }
    100% { transform: translateY(-80px) scale(0.9); opacity: 0; }
}

/* --- Hype Text (big on-screen messages — gem powers, line clears, etc.) --- */
.hype-text {
    position: absolute;
    top: 50%;
    left: 50%;
    font-weight: 900;
    color: white;
    -webkit-text-stroke: 1.5px rgba(0,0,0,0.3);
    text-shadow: 0 0 30px currentColor, 0 0 60px currentColor, 0 4px 8px rgba(0,0,0,0.5);
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    font-size: clamp(1.8rem, 9vw, 3rem);
    z-index: 58;
    letter-spacing: 2px;
    text-transform: uppercase;
    animation: hype-pop 1.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 95%;
    text-align: center;
}

@keyframes hype-pop {
    0% { transform: translate(-50%, -50%) scale(0) rotate(-8deg); opacity: 0; }
    12% { transform: translate(-50%, -50%) scale(1.4) rotate(4deg); opacity: 1; }
    24% { transform: translate(-50%, -50%) scale(0.95) rotate(-2deg); opacity: 1; }
    65% { transform: translate(-50%, -50%) scale(1.0) rotate(0deg); opacity: 1; }
    100% { transform: translate(-50%, -150%) scale(0.85) rotate(2deg); opacity: 0; }
}

/* --- Inline Text (positioned near grid events) --- */
.inline-text {
    position: absolute;
    font-weight: 900;
    font-size: clamp(0.9rem, 4vw, 1.3rem);
    color: white;
    pointer-events: none;
    white-space: nowrap;
    z-index: 59;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    opacity: 0;
    transform: translateX(-50%);
    animation: inline-float 1.1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes inline-float {
    0%   { transform: translateX(-50%) scale(0.5) translateY(0); opacity: 0; }
    15%  { transform: translateX(-50%) scale(1.15) translateY(-8px); opacity: 1; }
    30%  { transform: translateX(-50%) scale(0.95) translateY(-14px); opacity: 1; }
    60%  { transform: translateX(-50%) scale(1.0) translateY(-20px); opacity: 1; }
    100% { transform: translateX(-50%) scale(0.85) translateY(-50px); opacity: 0; }
}

/* --- Combo Inline Text (positioned near cleared lines) --- */
.combo-inline-text {
    position: absolute;
    font-weight: 900;
    font-size: 1.2rem;
    color: white;
    pointer-events: none;
    white-space: nowrap;
    z-index: 61;
    letter-spacing: 3px;
    text-transform: uppercase;
    opacity: 0;
    transform: translateX(-50%);
    animation: combo-inline-pop 1.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    -webkit-text-stroke: 1px rgba(0,0,0,0.6);
}
/* High combo (3+): intense glow, no background */
.combo-inline-text.combo-tier-high {
    -webkit-text-stroke: 1.5px rgba(0,0,0,0.5);
}
/* Max combo (5+): pulsing glow burst */
.combo-inline-text.combo-tier-max {
    -webkit-text-stroke: 2px rgba(0,0,0,0.4);
    animation: combo-inline-pop 1.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
               combo-glow-pulse 0.3s ease-in-out 3;
}
@keyframes combo-glow-pulse {
    0%, 100% { filter: brightness(1) drop-shadow(0 0 8px currentColor); }
    50% { filter: brightness(1.6) drop-shadow(0 0 20px currentColor); }
}

@keyframes combo-inline-pop {
    0%   { transform: translateX(-50%) scale(2.2) translateY(0); opacity: 0; }
    10%  { transform: translateX(-50%) scale(0.85) translateY(-6px); opacity: 1; }
    20%  { transform: translateX(-50%) scale(1.2) translateY(-10px); opacity: 1; }
    50%  { transform: translateX(-50%) scale(1.05) translateY(-16px); opacity: 1; }
    100% { transform: translateX(-50%) scale(0.8) translateY(-60px); opacity: 0; }
}

/* --- Particle System --- */
.pop-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 20;
    opacity: 1;
    will-change: transform, opacity;
}

/* --- Ambient Floating Bubbles --- */
.ambient-bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.15), rgba(255,255,255,0.03));
    border: 1px solid rgba(255,255,255,0.06);
    pointer-events: none;
    z-index: 0;
    animation: float-up linear infinite;
}
@keyframes float-up {
    0% { transform: translateY(0) scale(1); opacity: 0; }
    10% { opacity: 0.6; }
    90% { opacity: 0.6; }
    100% { transform: translateY(-110vh) scale(0.3); opacity: 0; }
}

/* --- Modals & Buttons --- */
.hidden { display: none !important; }

#game-over-modal, #continue-modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}
.modal-content {
    background: var(--bg-light);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    animation: modal-appear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    width: 90%;
    max-width: 350px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-content .button, .modal-content #restart-button {
    width: 100%;
    margin-top: 0;
}

@keyframes modal-appear {
    from { opacity: 0; transform: scale(0.7) translateY(20px); }
    to { opacity: 1; transform: scale(1.0) translateY(0); }
}
.highscore-modal-content {
    transform: translateY(20px) scale(0.97);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
    opacity: 0;
}
#highscore-overlay.visible .highscore-modal-content {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.modal-content h2 { font-size: 32px; color: var(--pink); margin-bottom: 10px; }
.modal-content p { font-size: 20px; margin-bottom: 20px; }
.button, #restart-button {
    display: block;
    text-decoration: none;
    background: linear-gradient(135deg, #F72585, #7209B7);
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    letter-spacing: 1px;
    margin-top: 10px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 20px rgba(247, 37, 133, 0.35);
    font-family: 'Poppins', sans-serif;
    text-align: center;
}
#restart-button { background: linear-gradient(135deg, #F72585, #B5179E); }
.button.logout { background: linear-gradient(135deg, #560BAD, #480CA8); box-shadow: 0 4px 20px rgba(86, 11, 173, 0.35); }
.button.button-danger { background: linear-gradient(135deg, #dc2626, #991b1b); box-shadow: 0 4px 20px rgba(220, 38, 38, 0.3); font-size: 12px; padding: 8px 16px; }
.button:hover, #restart-button:hover { transform: scale(1.05); box-shadow: 0 6px 30px rgba(247, 37, 133, 0.55); }

#install-pwa-button {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--blue-3);
    color: var(--bg-dark);
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-weight: bold;
    box-shadow: 0 4px 15px var(--shadow-dark);
}

/* --- Button SVG Icons --- */
.btn-icon {
    width: 18px;
    height: 18px;
    vertical-align: middle;
    margin-right: 6px;
    position: relative;
    top: -1px;
    flex-shrink: 0;
}
.btn-icon-sm {
    width: 20px;
    height: 20px;
    margin-right: 0;
    color: var(--text);
}

/* --- Game Over Header (trophy + title) --- */
.gameover-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gameover-trophy {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    transition: background 0.2s, transform 0.2s;
    line-height: 1;
    color: #fcd34d;
    font-size: 20px;
}
.fa-btn-icon {
    margin-right: 6px;
    font-size: 14px;
    vertical-align: middle;
    position: relative;
    top: -1px;
}
.gameover-trophy:hover {
    background: rgba(255,255,255,0.08);
    transform: translateY(-50%) scale(1.15);
}

/* --- Board Replay Overlay --- */
#board-replay-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
}
.board-replay-container {
    background: var(--bg-light);
    padding: 20px;
    border-radius: 20px;
    text-align: center;
    animation: modal-appear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    width: 90%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.board-replay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 4px;
}
.board-replay-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--pink);
}
.board-replay-score {
    font-size: 14px;
    color: var(--text);
    opacity: 0.8;
}

/* Replay grid — mirrors main grid styling */
.board-replay-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    aspect-ratio: 1 / 1;
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    background: var(--bg-grid);
    border: 2px solid rgba(108, 99, 255, 0.3);
    border-radius: 14px;
    box-shadow: 0 0 40px rgba(108, 99, 255, 0.1), inset 0 0 30px rgba(0, 0, 0, 0.2);
    position: relative;
}
.board-replay-grid .grid-cell {
    position: relative;
    border: 1px solid var(--grid-line);
}

/* Replay highlight flash on placed cells */
.board-replay-grid .replay-highlight {
    animation: replay-flash 0.3s ease-out;
}
@keyframes replay-flash {
    0% { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.8), inset 0 -2px 4px rgba(0,0,0,0.2); transform: scale(1.15); }
    100% { box-shadow: none; transform: scale(1); }
}

/* Replay progress area — fixed height to prevent layout shift */
.replay-progress-area {
    min-height: 28px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Replay controls — stacked vertically like other modals */
.board-replay-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.replay-btn {
    width: 100%;
    margin-top: 0 !important;
}
.replay-close {
    background: linear-gradient(135deg, #560BAD, #480CA8) !important;
    box-shadow: 0 4px 20px rgba(86, 11, 173, 0.35) !important;
}
.replay-pause {
    background: linear-gradient(135deg, #dc2626, #991b1b) !important;
    box-shadow: 0 4px 20px rgba(220, 38, 38, 0.3) !important;
}
.replay-export {
    background: linear-gradient(135deg, #0d9488, #0a7468) !important;
    box-shadow: 0 4px 20px rgba(13, 148, 136, 0.35) !important;
}

/* Video Export Progress Overlay */
.export-progress-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 30, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    border-radius: 16px;
    backdrop-filter: blur(6px);
}
.export-progress-content {
    text-align: center;
    padding: 24px;
    width: 100%;
    max-width: 280px;
}
.export-progress-icon {
    font-size: 2rem;
    color: #F72585;
    margin-bottom: 12px;
}
.export-progress-text {
    color: #e8eaf6;
    font-size: 0.9rem;
    margin-bottom: 16px;
    font-weight: 300;
}
.export-progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}
.export-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #F72585, #7209B7);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
}
.export-cancel-btn {
    margin-top: 14px !important;
    background: linear-gradient(135deg, #560BAD, #480CA8) !important;
    box-shadow: 0 4px 20px rgba(86, 11, 173, 0.35) !important;
}
.export-save-btn {
    margin-top: 14px !important;
    background: linear-gradient(135deg, #0d9488, #0a7468) !important;
    box-shadow: 0 4px 20px rgba(13, 148, 136, 0.35) !important;
}

/* Replay progress bar */
.replay-progress {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
}
.replay-progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
}
.replay-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--pink), var(--purple-1));
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}
.replay-progress-text {
    font-size: 12px;
    color: var(--text);
    opacity: 0.7;
}

/* --- High Score Page --- */
.highscore-page {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    overflow-y: auto;
    background: linear-gradient(160deg, #1a1a2e 0%, #16213e 40%, #0f3460 100%);
}
.highscore-container {
    background: var(--bg-light);
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    position: relative;
}
.highscore-container h1 { margin-bottom: 20px; }
.highscore-container .logo { width: 120px; margin-bottom: 10px; }

.back-button {
    position: absolute;
    top: 15px;
    left: 15px;
    background: linear-gradient(135deg, #F72585, #7209B7);
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 22px;
    font-weight: bold;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 20px rgba(247, 37, 133, 0.35);
    border: none;
}

.back-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(247, 37, 133, 0.55);
}


table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    table-layout: fixed;
}
th, td { padding: 10px; }
th {
    color: var(--blue-3);
    text-align: center;
}
tbody tr:nth-child(odd) { background: var(--bg-dark); }

td:nth-child(1),
td:nth-child(3) {
    text-align: center;
}
td:nth-child(2) {
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@keyframes zoomIn {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Zoom entrance on the wrapper — fast elastic pop */
@keyframes logoZoomIn {
    0%   { transform: scale(0); opacity: 0; }
    60%  { transform: scale(1.06); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* Gentle breathing on the image — delayed to start after zoom finishes */
@keyframes logoBreath {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.06); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- Line Completion Highlight (during drag preview) --- */
/* Uses inset box-shadow instead of ::after to avoid hiding special block icons (bomb, gem, frozen, etc.) */
.grid-cell.line-glow {
    box-shadow:
        inset 0 0 12px rgba(247, 37, 133, 0.45),
        inset 0 0 4px rgba(114, 9, 183, 0.25),
        0 3px 6px rgba(0, 0, 0, 0.35) !important;
}
/* Outline around entire completable row/column — pure glow, no borders */
.line-glow-outline {
    position: absolute;
    z-index: 3;
    border: none;
    border-radius: 12px;
    pointer-events: none;
    background: linear-gradient(90deg, rgba(247, 37, 133, 0.03), rgba(247, 37, 133, 0.08), rgba(247, 37, 133, 0.03));
    box-shadow:
        0 0 12px rgba(247, 37, 133, 0.5),
        0 0 28px rgba(247, 37, 133, 0.3),
        0 0 50px rgba(114, 9, 183, 0.18),
        inset 0 0 12px rgba(247, 37, 133, 0.08);
    animation: line-glow-pulse 1.2s ease-in-out infinite;
}
@keyframes line-glow-pulse {
    0%, 100% {
        box-shadow:
            0 0 12px rgba(247, 37, 133, 0.5),
            0 0 28px rgba(247, 37, 133, 0.3),
            0 0 50px rgba(114, 9, 183, 0.18),
            inset 0 0 12px rgba(247, 37, 133, 0.08);
        opacity: 0.75;
    }
    50% {
        box-shadow:
            0 0 20px rgba(247, 37, 133, 0.7),
            0 0 42px rgba(247, 37, 133, 0.45),
            0 0 70px rgba(114, 9, 183, 0.28),
            inset 0 0 18px rgba(247, 37, 133, 0.15);
        opacity: 1;
    }
}

/* --- Preview Overlay (piece placement ghost on grid) --- */
/* Perf: no box-shadow or animation during drag — just tinted background */
.preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 22%;
    z-index: 5;
    opacity: 0.65;
    transform: scale(0.92);
}
.preview-overlay.color-1  { background: rgba(247, 37, 133, 0.5); }
.preview-overlay.color-2  { background: rgba(114, 9, 183, 0.5); }
.preview-overlay.color-3  { background: rgba(92, 77, 229, 0.5); }
.preview-overlay.color-4  { background: rgba(67, 97, 238, 0.5); }
.preview-overlay.color-5  { background: rgba(16, 185, 129, 0.5); }
.preview-overlay.color-6  { background: rgba(245, 158, 11, 0.5); }
.preview-overlay.color-7  { background: rgba(59, 130, 246, 0.5); }
.preview-overlay.color-8  { background: rgba(232, 93, 58, 0.5); }
.preview-overlay.color-9  { background: rgba(244, 132, 95, 0.5); }
.preview-overlay.color-10 { background: rgba(20, 184, 166, 0.5); }


/* --- PWA Install Overlay Styles --- */
#pwa-install-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    display: flex;                  /* visible by default on all devices */
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    z-index: 200;
}

.overlay-content .logo { width: 150px; margin-bottom: 20px; }
.overlay-content h2 { color: var(--pink); margin-bottom: 10px; }
.overlay-content p { margin-bottom: 25px; line-height: 1.5; }
.overlay-content .small { font-size: 14px; color: var(--blue-3); opacity: 0.8; }

#install-pwa-button {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 0 auto 20px auto;
    font-size: 18px;
    font-weight: bold;
    padding: 15px;
    border-radius: 10px;
    border: none;
    background: var(--pink);
    color: white;
}
#install-pwa-button .icon { margin-right: 10px; }

/* Hide install overlay when running as installed PWA */
@media all and (display-mode: standalone) {
    #pwa-install-overlay { display: none !important; }
}

/* Hide install overlay on desktop — only needed on mobile */
@media (min-width: 769px) {
    #pwa-install-overlay { display: none !important; }
}

#loading-progress {
    margin-top: 15px;
    font-size: 16px;
    color: var(--blue-3);
}

/* ========================================
   COMBO TEXT OVERHAUL — Escalating Tiers
   ======================================== */
.combo-text.combo-x2-new,
.combo-text.combo-x3-new,
.combo-text.combo-x4-new,
.combo-text.combo-x5-new {
    position: fixed !important;
    left: 50% !important;
    top: 50% !important;
    background: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    z-index: 200;
    will-change: transform, opacity;
    max-width: 95vw;
    text-align: center;
}
.combo-text.combo-x2-new {
    font-size: clamp(2.5rem, 11vw, 52px);
    color: #6ee7b7;
    text-shadow: 0 0 20px rgba(16, 185, 129, 0.9), 0 0 40px rgba(16, 185, 129, 0.5), 0 4px 8px rgba(0,0,0,0.5);
    animation: combo-scale-2 1.6s cubic-bezier(.17,.67,.83,.67) forwards;
}
.combo-text.combo-x3-new {
    font-size: clamp(2.8rem, 12vw, 60px);
    color: #93c5fd;
    text-shadow: 0 0 25px rgba(59, 130, 246, 0.9), 0 0 50px rgba(59, 130, 246, 0.5), 0 4px 8px rgba(0,0,0,0.5);
    animation: combo-scale-3 1.6s cubic-bezier(.17,.67,.83,.67) forwards;
}
.combo-text.combo-x4-new {
    font-size: clamp(3.2rem, 13vw, 70px);
    color: #fcd34d;
    text-shadow: 0 0 30px rgba(255, 215, 0, 1), 0 0 60px rgba(255, 165, 0, 0.7), 0 0 90px rgba(255, 100, 0, 0.3), 0 4px 8px rgba(0,0,0,0.5);
    animation: combo-scale-4 1.6s cubic-bezier(.17,.67,.83,.67) forwards;
}
.combo-text.combo-x5-new {
    font-size: clamp(3.5rem, 14vw, 80px);
    color: white;
    text-shadow: 0 0 20px #F72585, 0 0 40px #7209B7, 0 0 70px #4CC9F0, 0 0 100px rgba(247, 37, 133, 0.5);
    animation: combo-scale-5 1.6s cubic-bezier(.17,.67,.83,.67) forwards;
}

@keyframes combo-scale-2 {
    0%   { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
    8%   { transform: translate(-50%, -50%) scale(0.9); opacity: 1; }
    16%  { transform: translate(-50%, -50%) scale(1.15); }
    24%  { transform: translate(-50%, -50%) scale(1.0); }
    70%  { transform: translate(-50%, -50%) scale(1.0); opacity: 1; }
    100% { transform: translate(-50%, -120%) scale(0.8); opacity: 0; }
}
@keyframes combo-scale-3 {
    0%   { transform: translate(-50%, -50%) scale(3); opacity: 0; }
    8%   { transform: translate(-50%, -50%) scale(0.85); opacity: 1; }
    16%  { transform: translate(-50%, -50%) scale(1.2); }
    24%  { transform: translate(-50%, -50%) scale(1.05); }
    70%  { transform: translate(-50%, -50%) scale(1.05); opacity: 1; }
    100% { transform: translate(-50%, -150%) scale(0.7); opacity: 0; }
}
@keyframes combo-scale-4 {
    0%   { transform: translate(-50%, -50%) scale(3.5) rotate(-3deg); opacity: 0; }
    7%   { transform: translate(-50%, -50%) scale(0.8) rotate(1.5deg); opacity: 1; }
    14%  { transform: translate(-50%, -50%) scale(1.25) rotate(-1deg); }
    22%  { transform: translate(-50%, -50%) scale(1.1) rotate(0deg); }
    65%  { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
    100% { transform: translate(-50%, -200%) scale(0.6) rotate(2deg); opacity: 0; }
}
@keyframes combo-scale-5 {
    0%   { transform: translate(-50%, -50%) scale(4) rotate(-4deg); opacity: 0; }
    6%   { transform: translate(-50%, -50%) scale(0.75) rotate(2deg); opacity: 1; }
    12%  { transform: translate(-50%, -50%) scale(1.35) rotate(-1.5deg); }
    20%  { transform: translate(-50%, -50%) scale(1.15) rotate(0.5deg); }
    28%  { transform: translate(-50%, -50%) scale(1.2) rotate(-0.5deg); }
    60%  { transform: translate(-50%, -50%) scale(1.2) rotate(0deg); opacity: 1; }
    100% { transform: translate(-50%, -250%) scale(0.5) rotate(3deg); opacity: 0; }
}

@keyframes hue-rotate-rainbow {
    0%   { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}
@keyframes chromatic-flicker {
    0%, 100% { text-shadow: 3px 0 #ff4444, -3px 0 #4444ff, 0 4px 20px rgba(59, 130, 246, 0.8); }
    50%      { text-shadow: -3px 0 #ff4444, 3px 0 #4444ff, 0 4px 20px rgba(59, 130, 246, 0.8); }
}

/* ========================================
   SCREEN FLASH OVERLAY
   ======================================== */
.screen-flash {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 150;
    animation: flash-fade 0.4s ease-out forwards;
}
@keyframes flash-fade {
    0%   { opacity: 1; }
    100% { opacity: 0; }
}

/* ========================================
   FLAME PARTICLES
   ======================================== */
.flame-particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 25;
    will-change: transform, opacity;
}

/* ========================================
   FIRE BORDER OVERLAY
   ======================================== */
.fire-border-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 15;
    border: 3px solid transparent;
    border-image: linear-gradient(0deg, #ff4500, #ff6b35, #ffa500, #ff1744, transparent 80%) 1;
    animation: fire-border-pulse 0.4s ease-in-out infinite alternate;
    border-radius: 14px;
}
@keyframes fire-border-pulse {
    0%   { opacity: 0.4; }
    100% { opacity: 1; }
}

/* ========================================
   GEM POWER GLOW OVERLAY
   ======================================== */
/* Intensified glow frame — stronger during gem power activation */
.gem-power-glow-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 16;
    border-radius: 4px;
    box-shadow:
        inset 0 0 50px color-mix(in srgb, var(--glow-color, #fff) 50%, transparent),
        inset 0 0 100px color-mix(in srgb, var(--glow-soft, #fff) 35%, transparent),
        0 0 35px color-mix(in srgb, var(--glow-color, #fff) 40%, transparent),
        0 0 70px color-mix(in srgb, var(--glow-soft, #fff) 25%, transparent),
        0 0 120px color-mix(in srgb, var(--glow-color, #fff) 12%, transparent);
    animation: gem-glow-breathe 1.8s ease-in-out infinite alternate;
    will-change: opacity;
}

/* No ::before or ::after pseudo-elements — removed rotating blurred conic
   gradients that were the primary cause of frame drops during drag */

/* Fade-out class added by JS before removal */
.gem-power-glow-overlay.gem-power-glow-fading {
    animation: gem-glow-fadeout 0.8s ease-out forwards;
}

@keyframes gem-glow-breathe {
    0%   { opacity: 0.7; }
    100% { opacity: 1; }
}

@keyframes gem-glow-fadeout {
    0%   { opacity: 1; }
    100% { opacity: 0; }
}

/* ========================================
   VIGNETTE OVERLAY
   ======================================== */
.vignette-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 14;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.6) 100%);
    animation: flash-fade 1.5s ease-out forwards;
}

/* ========================================
   CHROMATIC ABERRATION ON GAME CONTAINER
   ======================================== */
.chromatic {
    animation: chromatic-shift 0.12s ease-in-out infinite alternate !important;
}
@keyframes chromatic-shift {
    0%   { transform: translateX(0); }
    100% { transform: translateX(1px); }
}

/* ========================================
   PHANTOM BLOCKS
   ======================================== */
.phantom-block {
    border: 2px dashed rgba(217, 70, 239, 0.8) !important;
    animation: phantom-pulse 1.5s ease-in-out infinite !important;
    background: rgba(217, 70, 239, 0.15) !important;
    box-shadow: 0 0 12px rgba(217, 70, 239, 0.4), 0 0 24px rgba(168, 85, 247, 0.2) !important;
}
.phantom-block::after {
    content: var(--phantom-timer, "");
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1rem;
    font-weight: 900;
    color: rgba(217, 70, 239, 0.9);
    pointer-events: none;
    text-shadow: 0 0 6px rgba(217, 70, 239, 0.6);
}
@keyframes phantom-pulse {
    0%, 100% { opacity: 0.5; }
    50%      { opacity: 0.9; }
}

/* ========================================
   FROZEN BLOCKS
   ======================================== */
.frozen-full {
    filter: saturate(0.3) brightness(1.2) !important;
    border: 2px solid rgba(56, 189, 248, 0.8) !important;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.4), 0 0 20px rgba(56, 189, 248, 0.2) !important;
    animation: frozen-glow 2s ease-in-out infinite !important;
}
.frozen-full::after {
    content: '\2744';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2em;
    pointer-events: none;
    filter: drop-shadow(0 0 4px rgba(56, 189, 248, 0.8));
}
.frozen-cracked {
    filter: saturate(0.5) brightness(1.1) !important;
    border: 2px solid rgba(56, 189, 248, 0.5) !important;
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.3) !important;
}
.frozen-cracked::after {
    content: '\1F48E';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1em;
    pointer-events: none;
}
@keyframes frozen-glow {
    0%, 100% { box-shadow: 0 0 10px rgba(56, 189, 248, 0.4), 0 0 20px rgba(56, 189, 248, 0.2); }
    50%      { box-shadow: 0 0 20px rgba(56, 189, 248, 0.7), 0 0 35px rgba(56, 189, 248, 0.4); }
}
.ice-crack-animation {
    animation: ice-crack 0.5s ease-out forwards !important;
}
@keyframes ice-crack {
    0%   { transform: scale(0.92); }
    30%  { transform: scale(1.15); filter: brightness(2); }
    60%  { transform: scale(0.9); filter: brightness(1.2); }
    100% { transform: scale(0.92); filter: brightness(1); }
}

/* ========================================
   POWER BLOCKS
   ======================================== */
.power-x2 {
    border: 2px solid rgba(249, 115, 22, 0.8) !important;
    box-shadow: 0 0 12px rgba(249, 115, 22, 0.5), 0 0 24px rgba(249, 115, 22, 0.2) !important;
}
.power-x2::after {
    content: '\26A1';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.1em;
    pointer-events: none;
    filter: drop-shadow(0 0 4px rgba(249, 115, 22, 0.8));
}
.power-x3 {
    border: 2px solid rgba(239, 68, 68, 0.9) !important;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.6), 0 0 30px rgba(239, 68, 68, 0.3) !important;
    animation: power-pulse 1s ease-in-out infinite !important;
}
.power-x3::after {
    content: '\26A1';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2em;
    pointer-events: none;
    filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.9));
}
@keyframes power-pulse {
    0%, 100% { box-shadow: 0 0 15px rgba(239, 68, 68, 0.6), 0 0 30px rgba(239, 68, 68, 0.3); }
    50%      { box-shadow: 0 0 25px rgba(239, 68, 68, 0.9), 0 0 45px rgba(239, 68, 68, 0.5); }
}

/* ========================================
   GEM BLOCKS
   ======================================== */
.gem-block {
    border: 2px solid #ffd700 !important;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.7), 0 0 20px rgba(255, 215, 0, 0.4), inset 0 1px 3px rgba(255, 255, 255, 0.4) !important;
    animation: gem-golden-glow 2s ease-in-out infinite !important;
    overflow: hidden;
}
.gem-block::before {
    content: '' !important;
    top: -50% !important; left: -100% !important;
    width: 60% !important; height: 200% !important;
    background: linear-gradient(100deg, transparent 0%, rgba(255,255,255,0.1) 30%, rgba(255,215,0,0.35) 45%, rgba(255,255,255,0.55) 50%, rgba(255,215,0,0.35) 55%, rgba(255,255,255,0.1) 70%, transparent 100%) !important;
    border-radius: 0 !important;
    animation: gem-shine-sweep 3s ease-in-out infinite !important;
    z-index: 3;
}
.gem-block::after {
    content: '\1F48E' !important;
    position: absolute !important;
    inset: auto !important;
    top: 50% !important; left: 50% !important;
    width: auto !important; height: auto !important;
    background: none !important;
    border-radius: 0 !important;
    transform: translate(-50%, -50%) !important;
    font-size: 1em !important;
    pointer-events: none;
    z-index: 4;
    filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.9)) !important;
    animation: none !important;
}
@keyframes gem-golden-glow {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 215, 0, 0.7), 0 0 20px rgba(255, 215, 0, 0.4), inset 0 1px 3px rgba(255, 255, 255, 0.4); }
    50%      { box-shadow: 0 0 18px rgba(255, 215, 0, 0.9), 0 0 35px rgba(255, 215, 0, 0.6), inset 0 1px 4px rgba(255, 255, 255, 0.5); }
}
@keyframes gem-shine-sweep {
    0%, 100% { left: -100%; }
    50%      { left: 200%; }
}

/* ========================================
   BLAST TELEGRAPH
   ======================================== */
.blast-telegraph {
    animation: blast-telegraph-pulse 0.2s ease-out !important;
    box-shadow: 0 0 15px rgba(255, 165, 0, 0.8) !important;
}
@keyframes blast-telegraph-pulse {
    0%, 100% { box-shadow: 0 0 0 rgba(255, 165, 0, 0); }
    50%      { box-shadow: 0 0 25px rgba(255, 165, 0, 0.9); }
}

/* ========================================
   PERFECT CLEAR TEXT
   ======================================== */
.perfect-clear-text {
    font-size: clamp(3rem, 16vw, 6rem) !important;
    text-shadow: 0 0 30px #fff, 0 0 60px #fff, 0 0 90px #ff0 !important;
    animation: hype-pop 1.6s cubic-bezier(0.34, 1.56, 0.64, 1), hue-rotate-rainbow 1s linear infinite !important;
}

/* ========================================
   GAME OVER STATS PANEL
   ======================================== */
.final-score-display {
    font-size: 22px;
    margin-bottom: 5px;
}
.final-score-display span {
    color: #fcd34d;
    font-weight: 900;
    font-size: 28px;
}
.stats-panel {
    width: 100%;
    margin: 12px 0 16px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-size: 13px;
}
.stat-row span:first-child {
    opacity: 0.8;
}
.stat-row span:last-child {
    font-weight: bold;
    color: var(--blue-3);
    font-size: 15px;
}

/* --- Game Over: Remaining Pieces --- */
.gameover-pieces {
    width: 100%;
    margin: 4px 0 0;
}
.gameover-pieces-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.5;
    margin-bottom: 6px;
}
.gameover-pieces-tray {
    display: flex;
    justify-content: center;
    gap: 12px;
    min-height: 50px;
    align-items: center;
}
.gameover-piece-mini {
    display: grid;
    gap: 1px;
    opacity: 0.85;
}
.gameover-piece-mini .block {
    width: 12px;
    height: 12px;
    border-radius: 22%;
}
.gameover-piece-mini .empty-cell {
    width: 12px;
    height: 12px;
}

/* --- Replay: Pieces Tray --- */
.replay-pieces {
    width: 100%;
    margin: 4px 0 0;
}
.replay-pieces-tray {
    display: flex;
    justify-content: center;
    gap: 14px;
    min-height: 45px;
    align-items: center;
}
.replay-piece-slot {
    display: grid;
    gap: 1px;
    transition: opacity 0.4s ease, transform 0.4s ease;
}
.replay-piece-slot.used {
    opacity: 0.15;
    transform: scale(0.7);
}
.replay-piece-slot .block {
    width: 10px;
    height: 10px;
    border-radius: 22%;
}
.replay-piece-slot .empty-cell {
    width: 10px;
    height: 10px;
}

/* --- Overlay Modals (shared) --- */
#settings-overlay, #info-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    touch-action: auto;
}
#highscore-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    touch-action: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
#highscore-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* --- Settings Menu --- */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    font-size: 16px;
}
.toggle-btn {
    padding: 6px 18px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    font-family: 'Poppins', sans-serif;
}
.toggle-btn.on {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}
.toggle-btn.off {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.5);
}
.toggle-btn:hover { transform: scale(1.05); }

/* --- Custom Volume Slider (div-based, works on iOS) --- */
.vol-track {
    position: relative;
    width: 120px;
    height: 40px;
    border-radius: 5px;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
    touch-action: none;
}
/* Visible rail inside the track */
.vol-track::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 10px;
    transform: translateY(-50%);
    border-radius: 5px;
    background: rgba(255,255,255,0.15);
    pointer-events: none;
}
.vol-fill {
    position: absolute;
    top: 50%;
    left: 0;
    height: 10px;
    transform: translateY(-50%);
    border-radius: 5px;
    background: linear-gradient(90deg, #059669, #10b981);
    pointer-events: none;
    width: 50%;
}
.vol-thumb {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981, #059669);
    border: 2px solid rgba(255,255,255,0.3);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
    transform: translate(-50%, -50%);
    cursor: pointer;
    touch-action: none;
}

/* --- Info Overlay --- */
.info-content {
    max-height: 80vh;
}
.info-scroll {
    text-align: left;
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 8px;
    margin-bottom: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--pink) transparent;
}

/* --- Sexy Custom Scrollbars --- */
.info-scroll::-webkit-scrollbar,
.highscore-list::-webkit-scrollbar,
.modal-content::-webkit-scrollbar {
    width: 6px;
}
.info-scroll::-webkit-scrollbar-track,
.highscore-list::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}
.info-scroll::-webkit-scrollbar-thumb,
.highscore-list::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--pink), var(--purple-1));
    border-radius: 3px;
    box-shadow: 0 0 6px var(--glow-pink);
}
.info-scroll::-webkit-scrollbar-thumb:hover,
.highscore-list::-webkit-scrollbar-thumb:hover,
.modal-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #ff4da6, var(--pink));
    box-shadow: 0 0 10px var(--glow-pink);
}
.info-scroll h3 {
    color: var(--blue-3);
    font-size: 16px;
    margin: 16px 0 8px;
    letter-spacing: 1px;
}
.info-scroll p {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 8px;
    color: rgba(255,255,255,0.8);
}
.info-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    font-size: 14px;
    line-height: 1.4;
    color: rgba(255,255,255,0.85);
}
.info-icon {
    font-size: 20px;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}

/* --- High Score Overlay --- */
.highscore-list {
    max-height: 50vh;
    min-height: 200px;
    overflow-y: auto;
    width: 100%;
    margin-bottom: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--pink) transparent;
}
.highscore-list .hs-row {
    opacity: 0;
    transform: translateY(8px);
}
.highscore-list.hs-loaded .hs-row {
    animation: hs-row-in 0.3s ease-out forwards;
}
@keyframes hs-row-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.hs-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
}
.hs-row:nth-child(odd) { background: rgba(255,255,255,0.04); }
.hs-row.hs-me { background: rgba(247, 37, 133, 0.15); border: 1px solid rgba(247, 37, 133, 0.3); }
.hs-rank { width: 30px; flex-shrink: 0; color: var(--blue-3); font-weight: bold; }
.hs-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hs-score { min-width: 70px; text-align: right; font-weight: bold; color: #fcd34d; flex-shrink: 0; }
.hs-row.hs-clickable { cursor: pointer; transition: background 0.2s; }
.hs-row.hs-clickable:hover { background: rgba(108, 99, 255, 0.15); }
/* Skeleton loading rows */
.hs-skeleton { pointer-events: none; }
.skeleton-bar {
    display: inline-block;
    background: linear-gradient(90deg, rgba(255,255,255,0.06) 25%, rgba(255,255,255,0.12) 50%, rgba(255,255,255,0.06) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.2s ease-in-out infinite;
    border-radius: 4px;
}
@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.hs-row.hs-clickable::after {
    content: '\25BC';
    font-size: 8px;
    margin-left: 6px;
    color: rgba(255, 255, 255, 0.3);
    transition: transform 0.2s;
}
.hs-stats {
    background: rgba(30, 42, 69, 0.8);
    border-radius: 8px;
    padding: 8px 12px;
    margin: 0 4px 6px;
    border: 1px solid rgba(108, 99, 255, 0.2);
}
.hs-stats.hidden { display: none; }
.hs-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    text-align: center;
}
.hs-stat-val {
    display: block;
    font-weight: bold;
    font-size: 14px;
    color: #4CC9F0;
}
.hs-stat-label {
    display: block;
    font-size: 9px;
    color: rgba(232, 234, 246, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- Gem Strip --- */
#gem-strip {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 18px 10px 0;
    flex-shrink: 0;
}
.gem-slot {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    border-radius: 50%;
    background: linear-gradient(145deg, rgba(255,255,255,0.06), rgba(0,0,0,0.1));
    border: 1.5px solid rgba(255,255,255,0.1);
    opacity: 0.25;
    filter: grayscale(1);
    transition: all 0.4s ease;
    position: relative;
    overflow: visible;
}
.gem-slot.collected {
    opacity: 1;
    filter: grayscale(0);
    background: linear-gradient(145deg, rgba(255, 215, 0, 0.15), rgba(184, 134, 11, 0.1));
    border: 1.5px solid rgba(255, 215, 0, 0.6);
    box-shadow:
        0 0 8px var(--gem-glow),
        0 0 16px color-mix(in srgb, var(--gem-glow) 40%, transparent),
        inset 0 1px 2px rgba(255, 255, 255, 0.3),
        0 0 4px rgba(255, 215, 0, 0.3);
    animation: gem-idle-glow 3s ease-in-out infinite;
}
/* Shine highlight on collected gems */
.gem-slot.collected::before {
    content: '';
    position: absolute;
    top: 1px;
    left: 20%;
    width: 50%;
    height: 40%;
    border-radius: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.4) 0%, transparent 100%);
    pointer-events: none;
    z-index: 1;
}
.gem-slot.gem-just-collected {
    animation: gem-collect-burst 1.6s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 10;
}
.gem-slot.gem-just-collected::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--gem-glow) 0%, transparent 70%);
    animation: gem-ring-expand 1s ease-out forwards;
    pointer-events: none;
}
@keyframes gem-idle-glow {
    0%, 100% {
        box-shadow: 0 0 8px var(--gem-glow), 0 0 16px color-mix(in srgb, var(--gem-glow) 40%, transparent),
            inset 0 1px 2px rgba(255, 255, 255, 0.3), 0 0 4px rgba(255, 215, 0, 0.3);
    }
    50% {
        box-shadow: 0 0 14px var(--gem-glow), 0 0 28px color-mix(in srgb, var(--gem-glow) 60%, transparent),
            inset 0 1px 3px rgba(255, 255, 255, 0.4), 0 0 8px rgba(255, 215, 0, 0.5);
    }
}
@keyframes gem-collect-burst {
    0%   { transform: scale(1); filter: brightness(1); box-shadow: 0 0 0 0 var(--gem-glow); }
    10%  { transform: scale(2) translateY(-8px); filter: brightness(2.5); box-shadow: 0 0 30px 8px var(--gem-glow); }
    25%  { transform: scale(1.1) translateY(-2px); filter: brightness(1.4); }
    40%  { transform: scale(1.6) translateY(-4px); filter: brightness(1.8); box-shadow: 0 0 20px 4px var(--gem-glow); }
    60%  { transform: scale(0.95); filter: brightness(1.1); }
    75%  { transform: scale(1.15); filter: brightness(1.3); box-shadow: 0 0 12px 2px var(--gem-glow); }
    100% { transform: scale(1); filter: brightness(1); box-shadow: 0 0 8px var(--gem-glow); }
}
@keyframes gem-ring-expand {
    0%   { transform: scale(0.5); opacity: 0.9; }
    100% { transform: scale(3); opacity: 0; }
}

/* --- Gem Block Variants on Grid (per-gem CSS vars for gem strip + glow tint) --- */
.gem-ruby    { --gem-color: #ef4444; --gem-glow: #fca5a5; }
.gem-sapphire { --gem-color: #3b82f6; --gem-glow: #93c5fd; }
.gem-emerald  { --gem-color: #10b981; --gem-glow: #6ee7b7; }
.gem-amethyst { --gem-color: #a855f7; --gem-glow: #d8b4fe; }
.gem-topaz    { --gem-color: #f59e0b; --gem-glow: #fcd34d; }
.gem-diamond  { --gem-color: #e2e8f0; --gem-glow: #ffffff; }
.gem-opal     { --gem-color: #c084fc; --gem-glow: #e9d5ff; }
.gem-pearl    { --gem-color: #fafafa; --gem-glow: #f5f5f5; }
.gem-obsidian { --gem-color: #6b7280; --gem-glow: #9ca3af; }
.gem-moonstone { --gem-color: #bfdbfe; --gem-glow: #dbeafe; }

/* ========================================
   FIX: Opal emoji square on mobile
   🌌 (Milky Way) renders as a rectangular
   photo-style emoji on iOS, showing a
   visible square edge. Replace the emoji
   with a pure CSS radial-gradient gem.
   ======================================== */
.gem-slot[data-gem-id="opal"] {
    font-size: 0;          /* hide the emoji text */
    overflow: hidden;
}
.gem-slot[data-gem-id="opal"]::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%,
        #e9d5ff 0%,
        #c084fc 35%,
        #a855f7 55%,
        #7c3aed 80%,
        #5b21b6 100%
    );
    opacity: 0.85;
}

/* ========================================
   FIX: Obsidian too dark before collection
   Brighten the uncollected state so the
   moon emoji is actually visible.
   ======================================== */
.gem-slot[data-gem-id="obsidian"] {
    opacity: 0.4;
    filter: grayscale(0.6) brightness(1.5);
}
.gem-slot[data-gem-id="obsidian"].collected {
    opacity: 1;
    filter: grayscale(0) brightness(1);
}

/* ========================================
   SMALL SCREENS (iPod Touch, SE, etc.)
   Height < 600px — shrink everything
   ======================================== */
@media (max-height: 600px) {
    header {
        padding: 2px 8px 0;
        gap: 2px;
    }
    .score-box div:first-child { font-size: 10px; }
    .score-box div:last-child { font-size: 16px; }
    .score-box { padding: 3px 8px; }
    .game-logo { width: 60px; }
    #gem-strip {
        padding: 4px 6px 2px;
        gap: 4px;
    }
    .gem-slot {
        width: 22px;
        height: 22px;
        font-size: 12px;
    }
    main {
        padding-top: 0;
    }
    footer {
        height: 138px;
        padding: 2px 0 1px;
    }
    .piece-preview-cell {
        width: min(22px, 6vw) !important;
        height: min(22px, 6vw) !important;
    }
    .piece-preview {
        padding: 4px;
    }
    .piece-slot {
        min-width: 40px;
    }
}

/* Extra tiny: height < 500px (iPod Touch landscape-ish or very small) */
@media (max-height: 500px) {
    header {
        padding: 1px 6px 0;
        gap: 1px;
    }
    #gem-strip {
        padding: 2px 6px 0;
    }
    main {
        padding-top: 0;
        margin-top: -4px;
    }
    .score-box div:last-child { font-size: 14px; }
    .game-logo { width: 50px; }
    .gem-slot {
        width: 18px;
        height: 18px;
        font-size: 10px;
    }
    .piece-preview-cell {
        width: min(18px, 5vw) !important;
        height: min(18px, 5vw) !important;
    }
    footer {
        height: 110px;
    }
    .piece-preview {
        padding: 2px;
    }
    .piece-slot {
        min-width: 30px;
    }
}

/* Narrow screens (width < 360px) — iPod Touch is 320px */
@media (max-width: 360px) {
    .piece-preview-cell {
        width: min(24px, 7vw) !important;
        height: min(24px, 7vw) !important;
    }
    .header-score-row { gap: 15px; }
    .score-box { padding: 4px 8px; }
}

/* Mobile: pull grid up tight (desktop stays centered) */
@media (max-width: 767px) {
    main {
        align-items: flex-start;
        padding-top: 18px;
    }
    #gem-strip {
        padding: 10px 10px 0;
    }
}

/* Tiny mobile screens: override the 32px padding back to tight */
@media (max-width: 767px) and (max-height: 600px) {
    main {
        padding-top: 0;
        margin-top: 6px;
    }
}
@media (max-width: 767px) and (max-height: 500px) {
    main {
        padding-top: 0;
        margin-top: 2px;
    }
}

/* ========================================
   DESKTOP: Scale down the game canvas
   Keep header, pieces, and everything else
   the same size — just shrink the grid.
   ======================================== */
@media (min-width: 768px) {
    #grid-container {
        max-width: 440px;
        max-height: min(440px, 100%);
    }
}

/* ========================================
   TABLET (iPad): width >= 768px but limited
   height — the desktop grid max-height of
   440px can overflow main and hide the gem
   strip. Shrink logo + footer to reclaim
   vertical space.
   ======================================== */
@media (min-width: 768px) and (max-height: 900px) {
    .game-logo { width: 100px; }
    footer {
        height: 150px;
        padding: 4px 0;
    }
    #gem-strip {
        padding: 8px 10px 0;
    }
}
@media (min-width: 768px) and (max-height: 750px) {
    .game-logo { width: 80px; }
    header {
        padding: 2px 8px 0;
        gap: 2px;
    }
    .score-box div:first-child { font-size: 10px; }
    .score-box div:last-child { font-size: 16px; }
    .score-box { padding: 3px 8px; }
    #gem-strip {
        padding: 4px 6px 2px;
        gap: 4px;
    }
    .gem-slot {
        width: 24px;
        height: 24px;
        font-size: 13px;
    }
    footer {
        height: 130px;
        padding: 2px 0;
    }
}

/* ========================================
   DESKTOP: full-width background
   Only fires when viewport is wider than
   the game container (700px). Moves the
   gradient to body so it fills edge-to-edge.
   Mobile & tablet are untouched.
   ======================================== */
@media (min-width: 701px) {
    html, body {
        background: linear-gradient(160deg, #1a1a2e 0%, #16213e 40%, #0f3460 100%);
    }
    #game-container {
        background: transparent;
    }
}

/* ========================================
   GEM FLASH ANIMATION
   Shows the gem name + icon in center of
   screen, holds, then explodes outward
   to trigger the gem's power effect.
   ======================================== */
.gem-flash-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    pointer-events: none;
    animation: gem-flash-explode 1.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.gem-flash-emoji {
    font-size: 56px;
    filter: drop-shadow(0 0 20px var(--gem-flash-glow, #06b6d4));
}
/* Opal emoji fix — renders as square on iOS, use CSS gem instead */
.gem-flash-emoji-opal {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%,
        #e9d5ff 0%,
        #c084fc 30%,
        #a855f7 50%,
        #7c3aed 75%,
        #5b21b6 100%
    );
    box-shadow: 0 0 20px #e9d5ff, 0 0 40px rgba(192, 132, 252, 0.5);
}
.gem-flash-name {
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--gem-flash-color, #06b6d4);
    text-shadow: 0 0 15px var(--gem-flash-glow, #06b6d4), 0 2px 6px rgba(0,0,0,0.5);
}
.gem-flash-power {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.85);
    text-shadow: 0 1px 4px rgba(0,0,0,0.6);
    margin-top: 2px;
}
/* Burst ring that expands behind the gem */
.gem-flash-ring {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid var(--gem-flash-color, #06b6d4);
    box-shadow: 0 0 30px var(--gem-flash-glow, #06b6d4);
    animation: gem-ring-burst 0.8s 0.5s ease-out forwards;
    opacity: 0;
}
@keyframes gem-flash-explode {
    0%   { transform: translate(-50%, -50%) scale(0) rotate(-10deg); opacity: 0; }
    15%  { transform: translate(-50%, -50%) scale(1.4) rotate(3deg); opacity: 1; }
    28%  { transform: translate(-50%, -50%) scale(0.95) rotate(-1deg); opacity: 1; }
    40%  { transform: translate(-50%, -50%) scale(1.05) rotate(0deg); opacity: 1; }
    65%  { transform: translate(-50%, -50%) scale(1.0); opacity: 1; }
    85%  { transform: translate(-50%, -50%) scale(1.8); opacity: 0.6; filter: brightness(2); }
    100% { transform: translate(-50%, -50%) scale(3.0); opacity: 0; filter: brightness(3); }
}
@keyframes gem-ring-burst {
    0%   { transform: scale(0.5); opacity: 0.9; }
    100% { transform: scale(5); opacity: 0; }
}

/* Emerald gem power: flash on cells that get auto-filled */
.gem-fill-flash {
    animation: gem-cell-fill 0.6s ease-out !important;
}
@keyframes gem-cell-fill {
    0%   { filter: brightness(2); }
    100% { filter: brightness(1); }
}

/* ========================================
   GEM POWER TELEGRAPH EFFECTS
   Highlights targets BEFORE power fires
   so the player sees what's about to happen.
   ======================================== */

/* Generic telegraph pulse — color set via --telegraph-color.
   Uses box-shadow only (no filter:brightness) to preserve ::after icons */
.gem-telegraph {
    box-shadow: 0 0 14px var(--telegraph-color, rgba(255,255,255,0.7)), inset 0 0 12px var(--telegraph-color, rgba(255,255,255,0.35));
    animation: gem-telegraph-pulse 0.18s ease-in-out infinite alternate !important;
    z-index: 10;
    position: relative;
}
@keyframes gem-telegraph-pulse {
    0%   { opacity: 0.6; }
    100% { opacity: 1; }
}

/* Opal ripple flash — brief burst as each ring recolors */
.gem-ripple-flash {
    animation: gem-ripple-burst 0.4s ease-out forwards !important;
}
@keyframes gem-ripple-burst {
    0%   { filter: brightness(2.5); transform: scale(1.15); }
    100% { filter: brightness(1); transform: scale(1); }
}

/* Diamond buff — persistent border glow on grid, opacity-only pulse for performance */
.diamond-buff-glow {
    border-color: rgba(255, 255, 255, 0.7) !important;
    box-shadow: 0 0 40px rgba(255,255,255,0.35), 0 0 70px rgba(226,232,240,0.2), inset 0 0 30px rgba(0,0,0,0.2) !important;
    animation: diamond-buff-pulse 1.8s ease-in-out infinite !important;
    will-change: opacity;
}
@keyframes diamond-buff-pulse {
    0%, 100% { opacity: 0.7; }
    50%      { opacity: 1; }
}

/* Amethyst gravity slam — per-column impact */
.gem-gravity-slam {
    animation: gem-gravity-slam 0.25s ease-in forwards !important;
}
@keyframes gem-gravity-slam {
    0%   { transform: translateY(-4px); opacity: 0.7; }
    70%  { transform: translateY(2px); opacity: 1; }
    100% { transform: translateY(0); opacity: 1; }
}

/* Moonstone pre-spin — subtle wobble before rotation */
.gem-prespin {
    animation: gem-prespin-wobble 0.4s ease-in-out !important;
}
@keyframes gem-prespin-wobble {
    0%   { transform: rotate(0deg); }
    25%  { transform: rotate(-3deg); }
    50%  { transform: rotate(3deg); }
    75%  { transform: rotate(-2deg); }
    100% { transform: rotate(0deg); }
}

/* ========================================
   BOMB BLOCKS
   ======================================== */
.bomb-block {
    border: 2px solid rgba(239, 68, 68, 0.9) !important;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.6), 0 0 24px rgba(249, 115, 22, 0.3) !important;
    animation: bomb-pulse 1.2s ease-in-out infinite !important;
}
.bomb-block::after {
    content: '\1F4A3';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.1em;
    pointer-events: none;
    z-index: 5;
    filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.8));
}
@keyframes bomb-pulse {
    0%, 100% { box-shadow: 0 0 12px rgba(239, 68, 68, 0.6), 0 0 24px rgba(249, 115, 22, 0.3); }
    50%      { box-shadow: 0 0 20px rgba(239, 68, 68, 0.9), 0 0 40px rgba(249, 115, 22, 0.5); }
}
/* Bomb telegraph before detonation — quick flash for blast-radius chains */
.bomb-telegraph {
    animation: bomb-flash 0.15s ease-in-out 4 !important;
    z-index: 10;
}
/* Bomb countdown telegraph — dramatic flashing for non-cleared bombs waiting to blow */
.bomb-countdown {
    animation: bomb-countdown-flash 0.4s ease-in-out infinite !important;
    z-index: 10;
}
@keyframes bomb-flash {
    0%, 100% { filter: brightness(1); }
    50%      { filter: brightness(3); box-shadow: 0 0 30px rgba(255, 100, 0, 1); }
}
@keyframes bomb-countdown-flash {
    0%   { filter: brightness(1); transform: scale(1); }
    50%  { filter: brightness(3.5); transform: scale(1.15); box-shadow: 0 0 35px rgba(255, 80, 0, 1), 0 0 60px rgba(239, 68, 68, 0.6); }
    100% { filter: brightness(1); transform: scale(1); }
}
/* Bomb explosion pop */
.bomb-explode {
    animation: bomb-explode 0.6s ease-out forwards !important;
}
@keyframes bomb-explode {
    0%   { transform: scale(1); opacity: 1; }
    10%  { transform: scale(1.3); opacity: 1; filter: brightness(4); background: #fff !important; box-shadow: 0 0 40px rgba(255, 255, 255, 0.9), 0 0 80px rgba(255, 107, 53, 0.8) !important; }
    25%  { transform: scale(1.5); opacity: 1; filter: brightness(2.5); background: radial-gradient(circle, #fff 0%, #ff6b35 50%, #ef4444 100%) !important; box-shadow: 0 0 30px rgba(255, 107, 53, 0.9), 0 0 60px rgba(239, 68, 68, 0.6) !important; }
    50%  { transform: scale(1.1); opacity: 0.7; filter: brightness(1.5); background: radial-gradient(circle, #ffa500 0%, #ff4500 60%, transparent 100%) !important; }
    100% { transform: scale(0); opacity: 0; }
}

/* ========================================
   TROPHY BUTTON (header)
   ======================================== */
#trophy-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1.5px solid rgba(245, 158, 11, 0.4);
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    line-height: 1;
    padding: 0;
}
#trophy-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 16px rgba(245, 158, 11, 0.5);
}

/* ========================================
   ACHIEVEMENTS OVERLAY
   ======================================== */
#achievements-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}
.achievements-content {
    max-height: 85vh;
    overflow-y: auto;
    max-width: 420px;
}
.achievements-progress {
    text-align: center;
    color: #fcd34d;
    font-size: 13px;
    font-weight: 700;
    margin: 0 0 6px;
    letter-spacing: 1px;
}
.achievements-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 10px 0;
    max-height: 55vh;
    overflow-y: auto;
    padding: 4px 8px 4px 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--pink) transparent;
}
.achievements-grid::-webkit-scrollbar { width: 6px; }
.achievements-grid::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.05); border-radius: 3px; }
.achievements-grid::-webkit-scrollbar-thumb { background: linear-gradient(180deg, var(--pink), var(--purple-1)); border-radius: 3px; box-shadow: 0 0 6px var(--glow-pink); }
.achievements-grid::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, #ff4da6, var(--pink)); box-shadow: 0 0 10px var(--glow-pink); }
.achievement-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 8px;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}
.achievement-card.unlocked {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.4);
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.2);
}
.achievement-card.locked {
    opacity: 0.5;
    filter: grayscale(0.6);
}
.achievement-card .ach-icon {
    font-size: 28px;
    display: block;
    margin-bottom: 4px;
    line-height: 1.2;
}
.achievement-card .ach-name {
    font-size: 11px;
    font-weight: 700;
    color: #fcd34d;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    line-height: 1.2;
    display: block;
    margin-bottom: 4px;
}
.achievement-card .ach-desc {
    font-size: 9px;
    color: rgba(232, 234, 246, 0.7);
    margin-top: 0;
    line-height: 1.3;
    display: block;
}
.achievement-card.unlocked .ach-check {
    position: absolute;
    top: 4px; right: 6px;
    font-size: 12px;
    color: #10b981;
}

/* ========================================
   ACHIEVEMENT TOAST NOTIFICATION
   ======================================== */
.achievement-toast {
    position: fixed;
    top: calc(env(safe-area-inset-top, 20px) + 50px);
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: linear-gradient(135deg, #1e2a45, #16213e);
    border: 2px solid #ffd700;
    border-radius: 16px;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 300;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 215, 0, 0.3);
    animation: toast-slide-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
               toast-slide-out 0.4s ease-in 3s forwards;
    max-width: 90vw;
}
.achievement-toast .toast-icon {
    font-size: 32px;
    flex-shrink: 0;
}
.achievement-toast .toast-text {
    display: flex;
    flex-direction: column;
}
.achievement-toast .toast-label {
    font-size: 10px;
    font-weight: 700;
    color: #ffd700;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.achievement-toast .toast-name {
    font-size: 14px;
    font-weight: 700;
    color: #e8eaf6;
}
@keyframes toast-slide-in {
    0%   { transform: translateX(-50%) translateY(-100px); opacity: 0; }
    100% { transform: translateX(-50%) translateY(0); opacity: 1; }
}
@keyframes toast-slide-out {
    0%   { transform: translateX(-50%) translateY(0); opacity: 1; }
    100% { transform: translateX(-50%) translateY(-100px); opacity: 0; }
}

/* DJ song toast */
.dj-toast {
    position: fixed;
    top: calc(env(safe-area-inset-top, 20px) + 50px);
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: linear-gradient(135deg, #2d1b4e, #1a1a2e);
    border: 2px solid #F72585;
    border-radius: 16px;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 300;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 20px rgba(247, 37, 133, 0.3);
    animation: toast-slide-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
               toast-slide-out 0.4s ease-in 3s forwards;
    max-width: 90vw;
}
.dj-toast .toast-icon {
    font-size: 32px;
    flex-shrink: 0;
}
.dj-toast .toast-text {
    display: flex;
    flex-direction: column;
}
.dj-toast .toast-label {
    font-size: 10px;
    font-weight: 700;
    color: #F72585;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.dj-toast .toast-name {
    font-size: 14px;
    font-weight: 700;
    color: #e8eaf6;
}

/* ========================================
   LANDSCAPE OVERLAY
   On mobile landscape, hide the game and
   show only the BlockPop logo centered.
   ======================================== */
#landscape-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(160deg, #1a1a2e 0%, #16213e 40%, #0f3460 100%);
    z-index: 99999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
}
#landscape-overlay .landscape-logo {
    width: min(50vw, 280px);
    filter: drop-shadow(0 0 30px rgba(108, 99, 255, 0.5));
}
#landscape-overlay .landscape-hint {
    color: rgba(232, 234, 246, 0.5);
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 300;
    letter-spacing: 1px;
}

/* Show landscape overlay on mobile devices in landscape orientation */
@media (orientation: landscape) and (max-height: 500px) {
    #landscape-overlay {
        display: flex;
    }
    #game-container,
    #loading-screen,
    #pwa-install-overlay {
        display: none !important;
    }
}

/* ========================================
   GEM MODE — persistent glow while gems
   are activating / chaining. Animated
   border glow similar to Siri.
   ======================================== */
/* Gem-mode glow — intensified box-shadow, opacity-only animation */
#game-container.gem-mode-active::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 4px;
    z-index: 90;
    pointer-events: none;
    box-shadow:
        inset 0 0 40px rgba(247, 37, 133, 0.45),
        inset 0 0 80px rgba(114, 9, 183, 0.3),
        0 0 30px rgba(247, 37, 133, 0.35),
        0 0 60px rgba(114, 9, 183, 0.2),
        0 0 100px rgba(247, 37, 133, 0.1);
    animation: gem-mode-enter 0.5s ease-out forwards, gem-mode-glow 2s 0.5s ease-in-out infinite alternate;
    will-change: opacity;
}
/* Gradient border — stronger for gem mode */
#game-container.gem-mode-active::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 6px;
    z-index: 89;
    pointer-events: none;
    border: 3px solid transparent;
    background: linear-gradient(135deg, rgba(247, 37, 133, 0.7), rgba(114, 9, 183, 0.6), rgba(76, 201, 240, 0.7), rgba(247, 37, 133, 0.7)) border-box;
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    animation: gem-mode-enter 0.5s ease-out forwards;
}
@keyframes gem-mode-enter {
    0%   { opacity: 0; }
    100% { opacity: 1; }
}
/* Breathe via opacity only — stronger range */
@keyframes gem-mode-glow {
    0%   { opacity: 0.7; }
    50%  { opacity: 1; }
    100% { opacity: 0.85; }
}
