/**
 * Emoji Drop - Mobile-First Game Styles
 *
 * @file        style.css
 * @description Complete visual design: layout, animations, effects, responsive, and mobile-first UX.
 * @author      Mike Fairbrother <mike@fairbrother.me>
 * @copyright   2024-2026 Mike Fairbrother. All rights reserved.
 * @license     PROPRIETARY - No rights to copy, modify, distribute, or reuse
 *              any part of this code without explicit written permission from the author.
 *
 * NOTICE: This source code is the intellectual property of Mike Fairbrother.
 * Unauthorized copying, modification, distribution, or use of this file,
 * via any medium, is strictly prohibited.
 */

:root {
    --bg-dark: #0f0c29;
    --bg-mid: #1a1640;
    --bg-board: rgba(255, 255, 255, 0.04);
    --text-primary: #fff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --accent: #ffd93d;
    --accent-glow: rgba(255, 217, 61, 0.4);
    --danger: #ff4757;
    --danger-glow: rgba(255, 71, 87, 0.5);
    --success: #2ed573;
    --fire-a: #ff6b6b;
    --fire-b: #ff9f43;
    --cell-bg: rgba(255, 255, 255, 0.06);
    --cell-selected: rgba(255, 217, 61, 0.25);
    --cell-radius: 10px;
    --transition-fast: 150ms;
    --transition-normal: 300ms;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-dark);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

/* ---- App container ---- */
#app {
    position: relative;
    width: 100%;
    max-width: 420px;
    height: 100vh;
    height: 100dvh;
    margin: 0 auto;
    overflow: hidden;
    background: linear-gradient(170deg, #1a1640 0%, #0f0c29 40%, #1e1245 100%);
}

/* ---- Screen system ---- */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1;
}
.screen.active {
    opacity: 1;
    pointer-events: auto;
    z-index: 10;
}
.screen-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: safe center;
    padding: 40px 24px;
    text-align: center;
    overflow-y: auto;
}

/* ---- Menu Screen ---- */
.game-logo {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.logo-emoji {
    font-size: 48px;
    animation: logo-bounce 2s ease-in-out infinite;
}
.logo-emoji:nth-child(2) { animation-delay: 0.15s; }
.logo-emoji:nth-child(3) { animation-delay: 0.3s; }

@keyframes logo-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.game-title {
    font-size: 52px;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1;
    background: linear-gradient(135deg, #fff 0%, #ffd93d 50%, #ff6b6b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}
.game-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}
.menu-best {
    font-size: 18px;
    color: var(--accent);
    margin-bottom: 16px;
    font-weight: 600;
}

/* ---- Difficulty Selector ---- */
.difficulty-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}
.diff-arrow {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    font-size: 22px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
    line-height: 1;
}
.diff-arrow:active { background: rgba(255, 255, 255, 0.15); }
.diff-label {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    min-width: 80px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ---- Settings Row ---- */
.settings-row {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    align-items: center;
    justify-content: center;
}
.pause-settings {
    margin-top: 20px;
}

/* ---- Footer ---- */
.game-footer {
    margin-top: 16px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 0.5px;
    font-weight: 500;
    flex-shrink: 0;
}
.game-footer a {
    color: inherit;
    text-decoration: none;
}
.game-footer a:hover {
    text-decoration: underline;
}

/* ---- Buttons ---- */
.btn {
    display: block;
    width: 220px;
    padding: 16px 32px;
    border: none;
    border-radius: 16px;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    letter-spacing: 0.5px;
}
.btn:active { transform: scale(0.95); }
.btn-primary {
    background: linear-gradient(135deg, #ffd93d, #ff9f43);
    color: #1a1640;
    box-shadow: 0 4px 20px rgba(255, 217, 61, 0.3);
}
.btn-primary:active { box-shadow: 0 2px 10px rgba(255, 217, 61, 0.2); }
.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    margin-top: 12px;
    font-size: 16px;
    padding: 12px 32px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
    flex-shrink: 0;
}
.icon-btn:active { background: rgba(255, 255, 255, 0.15); }

/* Smaller toggle buttons for game header */
.icon-btn-sm {
    width: 30px;
    height: 30px;
    font-size: 13px;
    border-radius: 8px;
}

/* ---- Game Header ---- */
#screen-game { display: flex; flex-direction: column; }

#game-header {
    display: flex;
    align-items: center;
    padding: 10px 8px 6px;
    gap: 6px;
    min-height: 52px;
}
.stat {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.stat-right { align-items: flex-end; }
.stat-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}
.stat-value {
    font-size: 22px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.header-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
}

#combo-display {
    opacity: 0;
    transition: opacity 0.2s;
    text-align: center;
}
.combo-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--accent);
    text-shadow: 0 0 12px var(--accent-glow);
}
.combo-pop { animation: combo-pop 0.3s ease-out; }
@keyframes combo-pop {
    0% { transform: scale(0.5); }
    60% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

#selection-hint {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
    opacity: 0;
    transition: opacity 0.15s;
    text-align: center;
}

/* ---- Level bar ---- */
#level-bar {
    position: relative;
    height: 20px;
    margin: 0 12px 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    overflow: hidden;
}
#level-fill {
    position: absolute;
    inset: 0;
    width: 0%;
    background: linear-gradient(90deg, rgba(255, 217, 61, 0.25), rgba(255, 217, 61, 0.5));
    border-radius: 10px;
    transition: width 0.4s ease;
}
#level-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.65);
}

/* ---- Streak bar ---- */
#streak-bar {
    position: relative;
    height: 14px;
    margin: 0 12px 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 7px;
    overflow: hidden;
}
#streak-fill {
    position: absolute;
    inset: 0;
    width: 0%;
    background: linear-gradient(90deg, var(--fire-a), var(--fire-b));
    border-radius: 7px;
    transition: width 0.3s ease;
}
#streak-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
}
#streak-bar.on-fire #streak-fill {
    background: linear-gradient(90deg, var(--fire-a), var(--accent), var(--fire-a));
    background-size: 200% 100%;
    animation: fire-sweep 0.8s linear infinite;
}
@keyframes fire-sweep {
    0% { background-position: 0% 0%; }
    100% { background-position: 200% 0%; }
}

/* ---- Board ---- */
#board-wrapper {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 0 8px 8px;
    position: relative;
    overflow: hidden;
}
#board {
    position: relative;
    background: var(--bg-board);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.3);
}
.grid-bg {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

/* Danger line */
#danger-line {
    position: absolute;
    left: 8px;
    right: 8px;
    height: 2px;
    background: var(--danger);
    opacity: 0;
    z-index: 5;
    transition: opacity 0.3s;
    box-shadow: 0 0 8px var(--danger-glow), 0 0 16px var(--danger-glow);
    border-radius: 1px;
}
#board-wrapper.danger #danger-line {
    opacity: 1;
    animation: danger-pulse 1s ease-in-out infinite;
}
@keyframes danger-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}
#board-wrapper.danger #board {
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.3), inset 0 0 20px rgba(255, 71, 87, 0.12);
}

/* Per-column danger */
.col-danger {
    position: absolute;
    top: 0;
    background: linear-gradient(to bottom, rgba(255, 71, 87, 0.15), transparent);
    pointer-events: none;
    z-index: 1;
    border-radius: 8px 8px 0 0;
    animation: col-warn 1.2s ease-in-out infinite;
}
.col-danger.col-critical {
    background: linear-gradient(to bottom, rgba(255, 71, 87, 0.35), transparent 70%);
    animation: col-warn 0.6s ease-in-out infinite;
}
@keyframes col-warn {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* On Fire mode */
#board-wrapper.on-fire #board {
    box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.3),
        0 0 20px rgba(255, 150, 50, 0.25),
        0 0 40px rgba(255, 100, 50, 0.1);
}
#board-wrapper.on-fire::before {
    content: '🔥 ON FIRE 🔥';
    position: absolute;
    top: -2px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 800;
    color: var(--fire-a);
    letter-spacing: 2px;
    z-index: 20;
    animation: fire-text-pulse 0.5s ease-in-out infinite alternate;
    white-space: nowrap;
}
@keyframes fire-text-pulse {
    from { opacity: 0.7; transform: translateX(-50%) scale(1); }
    to   { opacity: 1;   transform: translateX(-50%) scale(1.05); }
}

/* ---- Emoji cells ---- */
.emoji-cell {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cell-bg);
    border-radius: var(--cell-radius);
    cursor: pointer;
    transition: top 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), left 0.2s ease;
    will-change: top, transform;
    z-index: 2;
}
.emoji-cell::after {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: calc(var(--cell-radius) - 1px);
    border: 1.5px solid rgba(255, 255, 255, 0.06);
    pointer-events: none;
}

/* Selection */
.emoji-cell.selected {
    background: var(--cell-selected);
    transform: scale(1.1);
    z-index: 3;
    box-shadow: 0 0 16px var(--accent-glow), 0 0 4px var(--accent-glow);
    transition: top 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), left 0.2s ease,
                transform var(--transition-fast) ease, background var(--transition-fast) ease,
                box-shadow var(--transition-fast) ease;
}
.emoji-cell.selected::after { border-color: rgba(255, 217, 61, 0.4); }

/* Landing */
.emoji-cell.landed { animation: land-bounce 0.25s ease-out; }
@keyframes land-bounce {
    0% { transform: scaleY(0.85) scaleX(1.1); }
    50% { transform: scaleY(1.08) scaleX(0.95); }
    100% { transform: scaleY(1) scaleX(1); }
}

/* Clearing */
.emoji-cell.clearing {
    animation: clear-pop 0.4s ease-out forwards;
    z-index: 4;
    pointer-events: none;
}
@keyframes clear-pop {
    0%   { transform: scale(1);   opacity: 1; }
    40%  { transform: scale(1.4); opacity: 0.8; }
    100% { transform: scale(0);   opacity: 0; }
}

/* Chain glow */
.emoji-cell.chain-glow {
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5), 0 0 8px rgba(255, 217, 61, 0.5);
    transform: scale(1.15);
    z-index: 4;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* Gravity */
.emoji-cell.gravity {
    transition: top 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Lucky convert */
.emoji-cell.lucky-convert {
    animation: lucky-flash 0.5s ease-out;
}
@keyframes lucky-flash {
    0%  { filter: brightness(2.5); transform: scale(1.3); }
    100% { filter: brightness(1); transform: scale(1); }
}

/* ---- Powerup styles ---- */
.emoji-cell.pw-bomb {
    animation: pw-glow-orange 1.5s ease-in-out infinite;
}
.emoji-cell.pw-row {
    animation: pw-glow-yellow 1.5s ease-in-out infinite;
}
.emoji-cell.pw-col {
    animation: pw-glow-blue 1.5s ease-in-out infinite;
}
.emoji-cell.pw-rainbow {
    animation: pw-glow-rainbow 2s linear infinite;
}
.emoji-cell.pw-lucky {
    animation: pw-glow-green 1.5s ease-in-out infinite;
}
.emoji-cell.pw-freeze {
    animation: pw-glow-cyan 1.5s ease-in-out infinite;
}

@keyframes pw-glow-orange {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 100, 50, 0.3); }
    50% { box-shadow: 0 0 16px rgba(255, 100, 50, 0.6), 0 0 4px rgba(255, 200, 50, 0.3); }
}
@keyframes pw-glow-yellow {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 217, 61, 0.3); }
    50% { box-shadow: 0 0 16px rgba(255, 217, 61, 0.6), 0 0 4px rgba(255, 255, 100, 0.3); }
}
@keyframes pw-glow-blue {
    0%, 100% { box-shadow: 0 0 8px rgba(100, 150, 255, 0.3); }
    50% { box-shadow: 0 0 16px rgba(100, 150, 255, 0.6), 0 0 4px rgba(150, 200, 255, 0.3); }
}
@keyframes pw-glow-green {
    0%, 100% { box-shadow: 0 0 8px rgba(46, 213, 115, 0.3); }
    50% { box-shadow: 0 0 16px rgba(46, 213, 115, 0.6), 0 0 4px rgba(100, 255, 150, 0.3); }
}
@keyframes pw-glow-cyan {
    0%, 100% { box-shadow: 0 0 8px rgba(0, 210, 255, 0.3); }
    50% { box-shadow: 0 0 16px rgba(0, 210, 255, 0.6), 0 0 4px rgba(100, 240, 255, 0.3); }
}
@keyframes pw-glow-rainbow {
    0%   { box-shadow: 0 0 14px rgba(255, 100, 100, 0.5); }
    25%  { box-shadow: 0 0 14px rgba(255, 217, 61, 0.5); }
    50%  { box-shadow: 0 0 14px rgba(100, 255, 100, 0.5); }
    75%  { box-shadow: 0 0 14px rgba(100, 150, 255, 0.5); }
    100% { box-shadow: 0 0 14px rgba(255, 100, 100, 0.5); }
}

/* Powerup clear effects */
.emoji-cell.bomb-clear {
    animation: bomb-pop 0.4s ease-out forwards;
}
@keyframes bomb-pop {
    0%   { transform: scale(1);   opacity: 1; filter: brightness(1); }
    30%  { transform: scale(1.5); opacity: 1; filter: brightness(2); }
    100% { transform: scale(0.2); opacity: 0; filter: brightness(3); }
}
.emoji-cell.row-clear {
    animation: row-sweep 0.4s ease-out forwards;
}
@keyframes row-sweep {
    0%   { transform: scaleX(1) scaleY(1);   opacity: 1; }
    40%  { transform: scaleX(1.5) scaleY(0.6); opacity: 0.8; }
    100% { transform: scaleX(2) scaleY(0);   opacity: 0; }
}
.emoji-cell.col-clear {
    animation: col-sweep 0.4s ease-out forwards;
}
@keyframes col-sweep {
    0%   { transform: scaleY(1) scaleX(1);   opacity: 1; }
    40%  { transform: scaleY(1.5) scaleX(0.6); opacity: 0.8; }
    100% { transform: scaleY(2) scaleX(0);   opacity: 0; }
}
.emoji-cell.rainbow-clear {
    animation: rainbow-pop 0.45s ease-out forwards;
}
@keyframes rainbow-pop {
    0%   { transform: scale(1);   opacity: 1; filter: hue-rotate(0deg); }
    50%  { transform: scale(1.3); opacity: 0.8; filter: hue-rotate(180deg); }
    100% { transform: scale(0);   opacity: 0; filter: hue-rotate(360deg); }
}

/* Freeze clear effect */
.emoji-cell.freeze-clear {
    animation: freeze-pop 0.45s ease-out forwards;
}
@keyframes freeze-pop {
    0%   { transform: scale(1);   opacity: 1; filter: brightness(1) hue-rotate(180deg); }
    50%  { transform: scale(1.3); opacity: 0.8; filter: brightness(2) hue-rotate(200deg); }
    100% { transform: scale(0);   opacity: 0; filter: brightness(3) hue-rotate(220deg); }
}

/* Freeze timer bar - shown above the board during freeze */
#freeze-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    z-index: 15;
    background: rgba(0, 210, 255, 0.15);
    border-radius: 3px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}
#freeze-bar.active {
    opacity: 1;
}
#freeze-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #00d2ff, #7effff, #00d2ff);
    background-size: 200% 100%;
    border-radius: 3px;
    transition: width 0.1s linear;
    animation: freeze-shimmer 1s linear infinite;
}
@keyframes freeze-shimmer {
    0% { background-position: 0% 0%; }
    100% { background-position: 200% 0%; }
}

/* Freeze active board tint */
#board-wrapper.frozen #board {
    box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.3),
        0 0 15px rgba(0, 210, 255, 0.2),
        0 0 30px rgba(0, 210, 255, 0.08);
}
#board-wrapper.frozen::before {
    content: '⏸ FROZEN ⏸';
    position: absolute;
    top: -2px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 800;
    color: #00d2ff;
    letter-spacing: 2px;
    z-index: 20;
    animation: freeze-text-pulse 0.8s ease-in-out infinite alternate;
    white-space: nowrap;
}
@keyframes freeze-text-pulse {
    from { opacity: 0.6; transform: translateX(-50%) scale(1); }
    to   { opacity: 1;   transform: translateX(-50%) scale(1.05); }
}

/* Last chance bomb pulse */
.emoji-cell.last-chance-bomb {
    animation: lc-bomb-pulse 0.5s ease-in-out infinite alternate;
    z-index: 6;
}
@keyframes lc-bomb-pulse {
    from { transform: scale(1);   box-shadow: 0 0 10px rgba(255, 71, 87, 0.5); }
    to   { transform: scale(1.2); box-shadow: 0 0 25px rgba(255, 71, 87, 0.8), 0 0 8px rgba(255, 200, 50, 0.4); }
}

/* ---- Particles ---- */
#particles {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 200;
    overflow: hidden;
}
.particle {
    position: fixed;
    font-size: 14px;
    pointer-events: none;
    animation: particle-fly 0.65s ease-out forwards;
    z-index: 200;
}
@keyframes particle-fly {
    0%   { transform: translate(0, 0) scale(1) rotate(0deg); opacity: 1; }
    100% { transform: translate(var(--tx), var(--ty)) scale(0.2) rotate(var(--rot)); opacity: 0; }
}

/* Score popup */
.score-popup {
    position: absolute;
    font-size: 18px;
    font-weight: 800;
    color: var(--accent);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 20;
    animation: score-float 0.9s ease-out forwards;
    white-space: nowrap;
    transform: translateX(-50%);
}
.score-popup.big-combo {
    font-size: 24px;
    color: var(--fire-a);
    text-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
}
@keyframes score-float {
    0%   { transform: translateX(-50%) translateY(0) scale(0.5); opacity: 0; }
    20%  { transform: translateX(-50%) translateY(-10px) scale(1.1); opacity: 1; }
    100% { transform: translateX(-50%) translateY(-60px) scale(0.9); opacity: 0; }
}

/* Screen shake */
.shake { animation: shake 0.3s ease-out; }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px) rotate(-0.5deg); }
    40% { transform: translateX(4px) rotate(0.5deg); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(2px); }
}

/* Level up flash */
.level-up-flash::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 217, 61, 0.15);
    border-radius: 12px;
    animation: level-flash 0.5s ease-out forwards;
    pointer-events: none;
    z-index: 10;
}
@keyframes level-flash {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* ---- Toast notifications ---- */
#toasts {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    pointer-events: none;
    width: 300px;
}
.toast {
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    background: rgba(30, 20, 60, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0;
    transform: translateY(-10px) scale(0.9);
    transition: opacity 0.25s ease, transform 0.25s ease;
    white-space: nowrap;
}
.toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.toast.hide {
    opacity: 0;
    transform: translateY(-10px) scale(0.9);
}
.toast-chain  { color: #a29bfe; border-color: rgba(162, 155, 254, 0.3); }
.toast-combo  { color: var(--accent); border-color: rgba(255, 217, 61, 0.3); }
.toast-best   { color: var(--accent); border-color: rgba(255, 217, 61, 0.3); background: rgba(60, 40, 10, 0.9); }
.toast-fire   { color: var(--fire-a); border-color: rgba(255, 107, 107, 0.3); }
.toast-powerup { color: var(--success); border-color: rgba(46, 213, 115, 0.3); }
.toast-danger { color: var(--danger); border-color: rgba(255, 71, 87, 0.3); }

/* ---- Help Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    padding: 20px;
}
.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.modal-content {
    background: linear-gradient(170deg, #1e1650, #150f35);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 28px 24px;
    max-width: 360px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.25s ease;
}
.modal-overlay.active .modal-content {
    transform: scale(1);
}
.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    font-size: 20px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-title {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 20px;
}
.help-section {
    margin-bottom: 16px;
    text-align: left;
}
.help-section h4 {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-primary);
}
.help-section p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}
.help-powerups {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.help-pw {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}
.help-pw span {
    font-size: 16px;
    margin-right: 4px;
}

/* ---- Pause Overlay ---- */
.game-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.game-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.overlay-title {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 20px;
}

/* ---- Last Chance Overlay ---- */
.lc-overlay {
    background: linear-gradient(
        to bottom,
        rgba(255, 40, 60, 0.8) 0%,
        transparent 35%,
        transparent 65%,
        rgba(255, 40, 60, 0.8) 100%
    );
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
/* Last chance overlay is purely visual - taps must pass through to the board */
.lc-overlay.active {
    pointer-events: none;
}
.lc-content {
    text-align: center;
    animation: lc-appear 0.4s ease-out;
}
@keyframes lc-appear {
    0% { transform: scale(0.5); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}
.lc-title {
    font-size: 32px;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 20px rgba(255, 71, 87, 0.8);
    animation: lc-pulse 0.6s ease-in-out infinite alternate;
}
@keyframes lc-pulse {
    from { transform: scale(1); }
    to   { transform: scale(1.08); }
}
.lc-subtitle {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.85);
    margin: 8px 0 16px;
}
.lc-timer {
    font-size: 48px;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 30px rgba(255, 71, 87, 0.8);
}

/* ---- Game Over Screen ---- */
.gameover-title {
    font-size: 36px;
    font-weight: 800;
    margin-bottom: 8px;
}
#new-best-badge {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    background: rgba(255, 217, 61, 0.15);
    padding: 6px 20px;
    border-radius: 20px;
    margin-bottom: 16px;
    animation: badge-pop 0.5s ease-out;
}
#almost-badge {
    font-size: 15px;
    font-weight: 600;
    color: var(--fire-a);
    margin-bottom: 12px;
    animation: badge-pop 0.5s ease-out;
}
@keyframes badge-pop {
    0%  { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}
.hidden { display: none !important; }

.final-score-block, .final-best-block { margin-bottom: 6px; }
.final-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}
.final-value {
    font-size: 52px;
    font-weight: 800;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.final-value-small {
    font-size: 26px;
    color: var(--text-secondary);
}
.final-stats {
    display: flex;
    gap: 20px;
    margin: 20px 0 16px;
}
.final-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.final-stat-num {
    font-size: 22px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}
.final-stat-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}
.motivation-text {
    font-size: 15px;
    font-weight: 600;
    color: var(--fire-a);
    margin-bottom: 20px;
    animation: badge-pop 0.5s ease-out 0.3s both;
}

/* ---- Back to Games (inline in menu & gameover) ---- */
.back-to-games-inline {
    display: inline-block;
    color: rgba(255, 255, 255, 0.35);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 10px;
    margin-bottom: 12px;
    transition: color 150ms, background 150ms;
}
.back-to-games-inline:active {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}
.gameover-back {
    margin-top: 12px;
    margin-bottom: 0;
}

/* ---- Responsive ---- */
@media (min-width: 421px) {
    body {
        display: flex;
        align-items: center;
        justify-content: center;
        background: #080620;
    }
    #app {
        border-radius: 24px;
        box-shadow: 0 0 60px rgba(30, 20, 80, 0.5);
        border: 1px solid rgba(255, 255, 255, 0.05);
        max-height: 900px;
    }
}

@supports (padding-top: env(safe-area-inset-top)) {
    #game-header {
        padding-top: calc(10px + env(safe-area-inset-top));
    }
}
