/* ============================================
   GRAVITAS — CSS Design System
   ============================================ */

/* --- CSS Variables --- */
:root {
    --bg-primary: #06060f;
    --bg-secondary: #0c0c1d;
    --bg-card: #111128;
    --bg-cell: #0a0a1e;

    --neon-cyan: #00e5ff;
    --neon-magenta: #ff2d95;
    --neon-purple: #a855f7;
    --neon-gold: #fbbf24;
    --neon-green: #22d3ee;
    --neon-red: #ff3b5c;
    --neon-blue: #3b82f6;
    --neon-orange: #f97316;

    --text-primary: #e8e8f0;
    --text-secondary: #8888aa;
    --text-muted: #555570;

    --wall-color: #1c1c3a;
    --wall-border: #2a2a50;
    --empty-color: #0d0d22;

    --player-color: var(--neon-cyan);
    --exit-color: var(--neon-magenta);
    --star-color: var(--neon-gold);
    --spike-color: var(--neon-red);
    --breakable-color: #8b6914;
    --key-red: #ff4466;
    --lock-red: #992233;
    --key-blue: #4488ff;
    --lock-blue: #223399;
    --teleport-a: var(--neon-purple);
    --teleport-b: var(--neon-orange);

    --font-display: 'Orbitron', sans-serif;
    --font-body: 'Inter', sans-serif;

    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;

    --cell-size: 44px;
    --cell-gap: 3px;

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: none;
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    user-select: none;
    -webkit-user-select: none;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* --- Screen System --- */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    z-index: 1;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    z-index: 10;
}

#screen-levels {
    justify-content: flex-start;
}

/* --- Splash Screen --- */
.splash-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(0, 229, 255, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(255, 45, 149, 0.08) 0%, transparent 50%),
        var(--bg-primary);
}

.splash-content {
    position: relative;
    z-index: 2;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.logo-container {
    position: relative;
    display: inline-block;
}

.logo-glow {
    position: absolute;
    inset: -40px;
    background: radial-gradient(ellipse, rgba(0, 229, 255, 0.3) 0%, transparent 70%);
    filter: blur(30px);
    animation: logo-pulse 3s ease-in-out infinite;
}

@keyframes logo-pulse {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.1); }
}

.game-title {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 3.2rem;
    letter-spacing: 0.25em;
    background: linear-gradient(135deg, var(--neon-cyan) 0%, var(--neon-magenta) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 30px rgba(0, 229, 255, 0.4));
    position: relative;
}

.game-title.small {
    font-size: 2.2rem;
    letter-spacing: 0.2em;
}

.game-tagline {
    font-family: var(--font-display);
    font-size: 0.85rem;
    letter-spacing: 0.4em;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.tap-start {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 40px;
    letter-spacing: 0.05em;
}

.pulse {
    animation: pulse-fade 2s ease-in-out infinite;
}

@keyframes pulse-fade {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* --- Menu Screen --- */
.menu-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 50% 30%, rgba(0, 229, 255, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 50% 90%, rgba(255, 45, 149, 0.04) 0%, transparent 50%),
        var(--bg-primary);
}

.menu-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    width: 100%;
    max-width: 320px;
    padding: 0 24px;
}

.menu-logo {
    margin-bottom: 8px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.menu-stats {
    display: flex;
    gap: 24px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.menu-stats .stat {
    display: flex;
    align-items: center;
    gap: 6px;
}

.menu-stats .stat-icon {
    font-size: 1rem;
}

/* --- Buttons --- */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 28px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    letter-spacing: 0.02em;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, transparent 50%);
    pointer-events: none;
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: linear-gradient(135deg, var(--neon-cyan), #0088cc);
    color: #000;
    box-shadow: 0 4px 20px rgba(0, 229, 255, 0.3), inset 0 1px 0 rgba(255,255,255,0.2);
}

.btn-primary:active {
    box-shadow: 0 2px 10px rgba(0, 229, 255, 0.2);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.btn-ghost:active {
    background: rgba(255, 255, 255, 0.05);
}

.btn-danger {
    background: linear-gradient(135deg, var(--neon-red), #cc0033);
    color: #fff;
    box-shadow: 0 4px 20px rgba(255, 59, 92, 0.2);
}

.btn-icon {
    font-size: 1.1em;
}

.btn-icon-only {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon-only:active {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(0.92);
}

/* --- Screen Header --- */
.screen-header {
    display: flex;
    align-items: center;
    padding: 16px 16px;
    padding-top: calc(16px + var(--safe-top));
    width: 100%;
    gap: 12px;
    flex-shrink: 0;
    z-index: 5;
}

.screen-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.spacer {
    flex: 1;
}

/* --- Chapter Tabs --- */
.chapter-tabs {
    display: flex;
    gap: 6px;
    padding: 0 16px;
    padding-top: 8px;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
}

.chapter-tabs::-webkit-scrollbar {
    display: none;
}

.chapter-tab {
    flex-shrink: 0;
    padding: 8px 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-xl);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.chapter-tab.active {
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.15), rgba(168, 85, 247, 0.15));
    border-color: rgba(0, 229, 255, 0.3);
    color: var(--neon-cyan);
}

/* --- Levels Grid --- */
.levels-grid-container {
    flex: 1;
    width: 100%;
    overflow-y: auto;
    padding: 16px;
    padding-bottom: calc(16px + var(--safe-bottom));
    scrollbar-width: none;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.levels-grid-container::-webkit-scrollbar {
    display: none;
}

.levels-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    max-width: 420px;
    margin: 0 auto;
}

.level-card {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.level-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.04) 0%, transparent 50%);
    pointer-events: none;
}

.level-card:active {
    transform: scale(0.94);
}

.level-card.locked {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

.level-card.completed {
    border-color: rgba(0, 229, 255, 0.2);
}

.level-card.current {
    border-color: rgba(0, 229, 255, 0.5);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.15);
}

.level-card.current::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(0, 229, 255, 0.3);
    animation: border-glow 2s ease-in-out infinite;
}

@keyframes border-glow {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

.level-num {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--text-primary);
}

.level-stars {
    display: flex;
    gap: 2px;
    font-size: 0.65rem;
}

.level-stars .star {
    color: var(--text-muted);
}

.level-stars .star.earned {
    color: var(--star-color);
    text-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

.level-lock {
    font-size: 1.2rem;
    opacity: 0.4;
}

/* --- Game HUD --- */
.game-hud {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    padding-top: calc(12px + var(--safe-top));
    width: 100%;
    gap: 12px;
    background: rgba(6, 6, 15, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 5;
    position: absolute;
    top: 0;
    left: 0;
}

.hud-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.hud-level {
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--neon-cyan);
    letter-spacing: 0.15em;
}

.hud-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.hud-right {
    display: flex;
    gap: 12px;
}

.hud-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
}

.hud-stat-icon {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.hud-stat-icon.star-icon {
    color: var(--star-color);
}

.hud-stat-val {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-primary);
}

/* --- Game Area --- */
#screen-game {
    justify-content: flex-start;
}

.game-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 16px;
    overflow: hidden;
}

.game-grid {
    display: grid;
    gap: var(--cell-gap);
    position: relative;
}

/* --- Grid Cells --- */
.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    border-radius: var(--radius-sm);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
}

.cell-empty {
    background: var(--empty-color);
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.cell-wall {
    background: var(--wall-color);
    border: 1px solid var(--wall-border);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), inset 0 -2px 0 rgba(0, 0, 0, 0.3);
}

.cell-exit {
    background: rgba(255, 45, 149, 0.1);
    border: 1px solid rgba(255, 45, 149, 0.25);
    animation: exit-glow 2s ease-in-out infinite;
}

.cell-exit::after {
    content: '';
    width: 55%;
    height: 55%;
    border-radius: 50%;
    background: radial-gradient(circle, var(--exit-color), transparent);
    animation: exit-pulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 15px var(--exit-color);
}

@keyframes exit-glow {
    0%, 100% { background: rgba(255, 45, 149, 0.08); }
    50% { background: rgba(255, 45, 149, 0.15); }
}

@keyframes exit-pulse {
    0%, 100% { transform: scale(0.8); opacity: 0.6; }
    50% { transform: scale(1.1); opacity: 1; }
}

.cell-star {
    background: var(--empty-color);
    border: 1px solid rgba(251, 191, 36, 0.15);
}

.cell-star::after {
    content: '★';
    font-size: calc(var(--cell-size) * 0.5);
    color: var(--star-color);
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.6);
    animation: star-float 3s ease-in-out infinite;
}

@keyframes star-float {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-2px) scale(1.1); }
}

.cell-spike {
    background: rgba(255, 59, 92, 0.08);
    border: 1px solid rgba(255, 59, 92, 0.15);
}

.cell-spike::after {
    content: '';
    width: 60%;
    height: 60%;
    background: var(--spike-color);
    clip-path: polygon(50% 0%, 0% 100%, 25% 50%, 50% 80%, 75% 50%, 100% 100%);
    filter: drop-shadow(0 0 4px var(--spike-color));
    animation: spike-throb 2s ease-in-out infinite;
}

@keyframes spike-throb {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.cell-breakable {
    background: rgba(139, 105, 20, 0.2);
    border: 1px solid rgba(139, 105, 20, 0.35);
    box-shadow: inset 0 0 8px rgba(139, 105, 20, 0.15);
}

.cell-breakable::after {
    content: '';
    width: 70%;
    height: 70%;
    border: 2px solid rgba(139, 105, 20, 0.5);
    border-radius: 3px;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 3px,
        rgba(139, 105, 20, 0.15) 3px,
        rgba(139, 105, 20, 0.15) 6px
    );
}

/* Key & Lock Cells */
.cell-key-red, .cell-key-blue {
    background: var(--empty-color);
}

.cell-key-red::after, .cell-key-blue::after {
    content: '🔑';
    font-size: calc(var(--cell-size) * 0.4);
    animation: key-bob 2s ease-in-out infinite;
}

@keyframes key-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.cell-key-red { border: 1px solid rgba(255, 68, 102, 0.25); }
.cell-key-red::after { filter: hue-rotate(0deg) drop-shadow(0 0 6px var(--key-red)); }

.cell-key-blue { border: 1px solid rgba(68, 136, 255, 0.25); }
.cell-key-blue::after { filter: hue-rotate(200deg) drop-shadow(0 0 6px var(--key-blue)); }

.cell-lock-red, .cell-lock-blue {
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

.cell-lock-red::after, .cell-lock-blue::after {
    content: '🔒';
    font-size: calc(var(--cell-size) * 0.4);
}

.cell-lock-red {
    background: var(--lock-red);
    border: 1px solid rgba(255, 68, 102, 0.4);
}
.cell-lock-red::after { filter: drop-shadow(0 0 4px var(--key-red)); }

.cell-lock-blue {
    background: var(--lock-blue);
    border: 1px solid rgba(68, 136, 255, 0.4);
}
.cell-lock-blue::after { filter: drop-shadow(0 0 4px var(--key-blue)); }

/* Teleporter Cells */
.cell-teleport-a {
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.cell-teleport-a::after {
    content: '';
    width: 60%;
    height: 60%;
    border-radius: 50%;
    border: 2px solid var(--teleport-a);
    animation: teleport-spin 3s linear infinite;
    box-shadow: 0 0 10px var(--teleport-a), inset 0 0 8px var(--teleport-a);
}

.cell-teleport-b {
    background: rgba(249, 115, 22, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.3);
}

.cell-teleport-b::after {
    content: '';
    width: 60%;
    height: 60%;
    border-radius: 50%;
    border: 2px solid var(--teleport-b);
    animation: teleport-spin 3s linear infinite reverse;
    box-shadow: 0 0 10px var(--teleport-b), inset 0 0 8px var(--teleport-b);
}

@keyframes teleport-spin {
    0% { transform: rotate(0deg) scale(0.9); border-radius: 50%; }
    25% { border-radius: 40% 60% 60% 40%; }
    50% { transform: rotate(180deg) scale(1.1); border-radius: 50%; }
    75% { border-radius: 60% 40% 40% 60%; }
    100% { transform: rotate(360deg) scale(0.9); border-radius: 50%; }
}

/* --- Player --- */
.player {
    position: absolute;
    width: var(--cell-size);
    height: var(--cell-size);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    pointer-events: none;
    transition: left 0.18s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                top 0.18s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.player-orb {
    width: 60%;
    height: 60%;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fff, var(--player-color));
    box-shadow:
        0 0 15px var(--player-color),
        0 0 30px rgba(0, 229, 255, 0.4),
        0 0 60px rgba(0, 229, 255, 0.15);
    animation: orb-glow 2s ease-in-out infinite;
}

@keyframes orb-glow {
    0%, 100% { box-shadow: 0 0 15px var(--player-color), 0 0 30px rgba(0, 229, 255, 0.4); }
    50% { box-shadow: 0 0 20px var(--player-color), 0 0 40px rgba(0, 229, 255, 0.5), 0 0 60px rgba(0, 229, 255, 0.2); }
}

.player.sliding {
    transition-duration: 0.22s;
    transition-timing-function: cubic-bezier(0.22, 0.61, 0.36, 1);
}

.player.dead .player-orb {
    animation: player-die 0.5s forwards;
}

@keyframes player-die {
    0% { transform: scale(1); opacity: 1; }
    30% { transform: scale(1.5); opacity: 0.8; filter: hue-rotate(90deg); }
    100% { transform: scale(0); opacity: 0; }
}

/* --- Game Footer --- */
.game-footer {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    padding-bottom: calc(12px + var(--safe-bottom));
    width: 100%;
    background: rgba(6, 6, 15, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    justify-content: center;
}

.btn-control {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-control:active {
    background: rgba(255, 255, 255, 0.08);
    transform: scale(0.95);
}

.btn-control svg {
    flex-shrink: 0;
}

/* --- Modal System --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    width: 100%;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    position: relative;
    overflow: hidden;
    animation: modal-in 0.3s ease;
}

.modal-overlay.active .modal {
    animation: modal-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-in {
    from { transform: scale(0.9) translateY(10px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-glow {
    position: absolute;
    top: -50%;
    left: 50%;
    transform: translateX(-50%);
    width: 200%;
    height: 100%;
    background: radial-gradient(ellipse, rgba(0, 229, 255, 0.08), transparent 60%);
    pointer-events: none;
}

.modal-title {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.modal-title.success {
    color: var(--neon-cyan);
    text-shadow: 0 0 20px rgba(0, 229, 255, 0.4);
}

.modal-title.danger {
    color: var(--neon-red);
    text-shadow: 0 0 20px rgba(255, 59, 92, 0.4);
}

.modal-buttons {
    display: flex;
    gap: 8px;
    width: 100%;
}

.modal-buttons .btn {
    flex: 1;
    padding: 12px 16px;
    font-size: 0.9rem;
}

/* --- Complete Stars --- */
.complete-stars {
    display: flex;
    gap: 12px;
}

.complete-star {
    font-size: 2.2rem;
    color: var(--text-muted);
    transition: all 0.5s ease;
    filter: grayscale(1) brightness(0.3);
}

.complete-star.earned {
    color: var(--star-color);
    filter: none;
    text-shadow: 0 0 15px rgba(251, 191, 36, 0.6);
    animation: star-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes star-pop {
    from { transform: scale(0) rotate(-45deg); }
    to { transform: scale(1) rotate(0deg); }
}

.complete-stats {
    display: flex;
    gap: 24px;
}

.stat-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* --- Death Modal --- */
.death-modal {
    border-color: rgba(255, 59, 92, 0.2);
}

.death-icon {
    font-size: 3rem;
    animation: death-shake 0.5s ease;
}

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

.death-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* --- Settings --- */
.settings-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.setting-label {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.toggle {
    width: 48px;
    height: 28px;
    border-radius: 14px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
    position: relative;
    transition: background var(--transition-fast);
}

.toggle.active {
    background: var(--neon-cyan);
}

.toggle-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    transition: transform var(--transition-fast);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.toggle.active .toggle-knob {
    transform: translateX(20px);
}

.settings-danger {
    width: 100%;
    padding-top: 16px;
    margin-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.settings-danger .btn {
    width: 100%;
    padding: 10px;
    font-size: 0.85rem;
}

.confirm-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
}

/* --- Cell Animations --- */
.cell.collecting {
    animation: cell-collect 0.4s forwards;
}

@keyframes cell-collect {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); opacity: 0.5; }
    100% { transform: scale(0); opacity: 0; }
}

.cell.breaking {
    animation: cell-break 0.4s forwards;
}

@keyframes cell-break {
    0% { transform: scale(1); opacity: 1; }
    30% { transform: scale(1.1); }
    100% { transform: scale(0.8) rotate(15deg); opacity: 0; }
}

.cell.unlocking {
    animation: cell-unlock 0.5s forwards;
}

@keyframes cell-unlock {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); filter: brightness(2); }
    100% { transform: scale(0); opacity: 0; }
}

/* --- Particle Effects (via JS) --- */
.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 30;
}

/* --- Key Indicators --- */
.key-indicators {
    display: flex;
    gap: 6px;
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
}

.key-indicator {
    font-size: 1rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.6);
    animation: key-bob 1.5s ease-in-out infinite;
}

/* --- Screen Flash --- */
.screen-flash {
    position: fixed;
    inset: 0;
    z-index: 50;
    pointer-events: none;
    opacity: 0;
}

.screen-flash.death {
    background: radial-gradient(circle, rgba(255, 59, 92, 0.4), transparent);
    animation: flash 0.4s ease-out forwards;
}

.screen-flash.win {
    background: radial-gradient(circle, rgba(0, 229, 255, 0.3), transparent);
    animation: flash 0.5s ease-out forwards;
}

@keyframes flash {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* --- Responsive --- */
@media (max-height: 600px) {
    :root {
        --cell-size: 36px;
        --cell-gap: 2px;
    }

    .game-hud {
        padding: 8px 12px;
    }

    .game-footer {
        padding: 8px 12px;
    }
}

@media (max-height: 500px) {
    :root {
        --cell-size: 30px;
        --cell-gap: 2px;
    }
}

@media (min-width: 768px) {
    :root {
        --cell-size: 52px;
        --cell-gap: 4px;
    }

    .levels-grid {
        max-width: 500px;
    }
}
