:root {
    /* Base HSL Tokens - PowerShell dark blue theme */
    --h-bg: 215;
    --s-bg: 98%;
    --l-bg: 15%;

    --bg-color: hsl(var(--h-bg), var(--s-bg), var(--l-bg));
    --panel-bg: hsla(var(--h-bg), var(--s-bg), 9%, 0.85);

    /* Brand Colors */
    --accent-primary: hsl(190, 100%, 55%); /* PowerShell cyan/light blue */
    --accent-success: hsl(145, 63%, 49%);
    --accent-warning: hsl(55, 90%, 60%);   /* Bright yellow warning */
    --accent-danger: hsl(2, 91%, 63%);

    /* Type Specific HSL */
    --type-char: hsl(180, 100%, 50%);
    /* Cyan */
    --type-short: hsl(120, 100%, 50%);
    /* Green */
    --type-int: hsl(45, 100%, 50%);
    /* Yellow */
    --type-long: hsl(30, 100%, 50%);
    /* Orange */
    --type-llong: hsl(330, 100%, 60%);
    /* Pink */
    --type-auto: hsl(260, 100%, 75%);
    /* Purple */

    --text-main: hsl(0, 0%, 100%); /* Crisp white text */
    --terminal-green: hsl(190, 100%, 55%);
    --font-mono: 'JetBrains Mono', monospace;

    /* FX */
    --glow-primary: 0 0 15px var(--accent-primary);
    --glow-neon: 0 0 10px currentColor, 0 0 20px currentColor;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-mono);
    overflow: hidden;
    height: 100dvh;
    width: 100vw;
    margin: 0;
    padding: 0;
    position: fixed;
    /* Lock viewport */
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid hsla(0, 0%, 100%, 0.1);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
}

.neon-text {
    text-shadow: var(--glow-neon);
}

/* Atmospheric Overlays */
#vignette {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle, transparent 40%, rgba(0, 0, 0, 0.6) 100%);
    pointer-events: none;
    z-index: 5;
}

#scanlines {
    position: fixed;
    inset: 0;
    background: linear-gradient(to bottom,
            rgba(18, 16, 16, 0) 50%,
            rgba(0, 0, 0, 0.1) 50%);
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 6;
    opacity: 0.3;
}
#memory-leak-warning {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 50;
    box-shadow: inset 0 0 100px rgba(248, 81, 73, 0);
    transition: box-shadow 0.3s ease;
}
#memory-leak-warning.active {
    animation: warning-pulse 1.5s infinite alternate;
}
@keyframes warning-pulse {
    from { box-shadow: inset 0 0 30px rgba(248, 81, 73, 0.1); }
    to { box-shadow: inset 0 0 150px rgba(248, 81, 73, 0.7); }
}

#game-scaler {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    width: 100vw;
    max-width: 600px;
    margin: 0 auto;
    overflow: hidden;
    position: relative;
    background-color: var(--bg-color);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.6);
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

#game-wrapper {
    position: absolute;
    left: 50%;
    margin-left: -250px; /* Half of 500px */
    width: 500px;
    height: 750px;
    background: rgba(22, 27, 34, 0);
    border: 1px solid #30363d;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform-origin: top center;
    overflow: hidden;
    z-index: 10;
}

/* Background Console Layer */
#console-logs {
    position: absolute;
    inset: 0;
    font-size: 11px;
    line-height: 1.8;
    color: var(--terminal-green);
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column-reverse;
    padding: 100px 20px;
    /* mask-image: linear-gradient(to bottom, transparent, black 15%, black 85%, transparent); */
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    z-index: 1;
}

/* Top Header refinement */
#top-header {
    flex-shrink: 0;
    height: 85px; /* v2.9.5: Increased to fix clipped 'ALLOCATED MEMORY' label */
    padding: 5px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 30;
    border-radius: 0;
    border-bottom: 1px solid hsla(0, 0%, 100%, 0.1);
}

#ui-layer>* {
    pointer-events: auto;
}

/* Immersive Header v2.0 */
/* Header & Navigation */


#top-header h1 {
    font-size: 18px;
    margin: 0;
    letter-spacing: 3px;
    color: var(--accent-primary);
}

.system-status {
    font-size: 8px;
    color: var(--accent-success);
    opacity: 0.8;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.score-display {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.score-display .label {
    font-size: 8px;
    color: #8b949e;
}

.score-display .value {
    font-size: 18px;
    font-weight: bold;
}

.high-score.score-display .value {
    font-size: 12px;
    color: var(--accent-warning);
}

/* UI Visibility Control */
.hidden {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.hidden-ui {
    display: none !important;
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

/* Command Center (Footer Area) */
#command-center {
    position: absolute;
    bottom: calc(env(safe-area-inset-bottom) + 20px);
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 100%;
    max-width: 500px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 50;
    border: 1px solid hsla(0, 0%, 100%, 0.1);
    border-radius: 24px;
    background: hsla(var(--h-bg), var(--s-bg), 8%, 0.9); /* Sleeker, highly legible glass panel */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.control-row.settings {
    margin-top: 5px;
    justify-content: flex-start;
    gap: 15px;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.volume-control .label {
    font-size: 9px;
    font-weight: bold;
    min-width: 25px;
}

.volume-control input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    overflow: visible;
    touch-action: none;
}

/* Custom Thumb - Premium Glow FX */
.volume-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #fff;
    border: 2px solid var(--accent-primary);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-primary), 
                0 0 20px rgba(88, 166, 255, 0.4);
    transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
                box-shadow 0.2s ease;
}

.volume-control input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.25);
    box-shadow: 0 0 15px var(--accent-primary), 
                0 0 30px rgba(88, 166, 255, 0.6);
}

.volume-control input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(1.4);
    background: var(--accent-primary);
    border-color: #fff;
}

/* Firefox support */
.volume-control input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #fff;
    border: 2px solid var(--accent-primary);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-primary);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.control-row {
    display: flex;
    gap: 12px;
    width: 100%;
    align-items: center;
}

/* Symmetrical Input Group */
.input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 6px 12px;
    height: 52px;
    justify-content: center;
}

.input-label {
    font-size: 8px;
    color: #8b949e;
    letter-spacing: 1.5px;
    font-weight: bold;
    text-transform: uppercase;
}

#target-type-selector {
    background: rgba(255, 255, 255, 0.05); /* Soft premium background */
    border: 1px solid rgba(255, 255, 255, 0.1); /* Subtle cyber borders */
    border-radius: 6px;
    color: #fff;
    font-family: var(--font-mono);
    font-size: 11px; /* Slightly smaller for precision and alignment */
    width: 100%;
    outline: none;
    cursor: pointer;
    padding: 2px 24px 2px 8px; /* Leave space on the right for the chevron */
    height: 26px;
    line-height: 20px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none; /* Strip browser default styles */
    
    /* Modern vector down arrow */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.6)' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: all 0.2s ease;
}

#target-type-selector:hover {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

select option,
#target-type-selector option,
#debug-piece-selector option {
    background-color: hsl(var(--h-bg), var(--s-bg), 12%);
    color: var(--text-main);
    font-family: var(--font-mono);
}

/* Unified Node Button Styling */
.primary-node, .secondary-node {
    height: 52px;
    border-radius: 12px;
    font-family: var(--font-mono);
    font-weight: bold;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    text-shadow: none;
}

/* Primary compiler button */
.primary-node {
    flex: 1.2;
    background: var(--accent-primary);
    color: #000;
    border: 1px solid var(--accent-primary);
    box-shadow: var(--glow-primary);
}

.primary-node:hover {
    background: #79c0ff;
    border-color: #79c0ff;
    box-shadow: 0 0 20px rgba(88, 166, 255, 0.6);
}

/* Secondary utility buttons */
.secondary-node {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    position: relative;
    overflow: hidden;
}

.secondary-node:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Defrag button specific customization with horizontal progress fill */
#compaction-btn {
    --fill-percent: 0%;
    background: linear-gradient(to right, rgba(210, 153, 34, 0.15) var(--fill-percent), rgba(255, 255, 255, 0.03) var(--fill-percent));
    border-color: rgba(210, 153, 34, 0.25);
    color: rgba(210, 153, 34, 0.9);
}

#compaction-btn:hover:not(:disabled) {
    background: linear-gradient(to right, rgba(210, 153, 34, 0.25) var(--fill-percent), rgba(255, 255, 255, 0.08) var(--fill-percent));
    border-color: rgba(210, 153, 34, 0.5);
    color: #d29922;
}

#compaction-btn.ready {
    background: linear-gradient(to right, rgba(252, 202, 63, 0.25) 100%, transparent 100%);
    border-color: #fcca3f;
    color: #fcca3f;
    animation: compaction-glow-pulse 1.5s infinite alternate;
    text-shadow: 0 0 8px rgba(252, 202, 63, 0.5);
}

#compaction-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.05);
    color: #555;
    background: linear-gradient(to right, rgba(210, 153, 34, 0.15) var(--fill-percent), rgba(255, 255, 255, 0.02) var(--fill-percent));
}

#rm-f-btn {
    border-color: rgba(248, 81, 73, 0.25);
    color: rgba(248, 81, 73, 0.8);
    transition: all 0.2s ease;
}

#rm-f-btn:hover:not(:disabled) {
    background: rgba(248, 81, 73, 0.1);
    border-color: rgba(248, 81, 73, 0.5);
    color: #f85149;
    box-shadow: 0 0 15px rgba(248, 81, 73, 0.2);
}

#rm-f-btn.ready {
    background: rgba(248, 81, 73, 0.08);
    border-color: #f85149;
    color: #f85149;
    text-shadow: 0 0 8px rgba(248, 81, 73, 0.6);
    box-shadow: 0 0 15px rgba(248, 81, 73, 0.25), inset 0 0 10px rgba(248, 81, 73, 0.15);
    animation: rm-glow-pulse 1.5s infinite alternate;
}

@keyframes rm-glow-pulse {
    from {
        box-shadow: 0 0 8px rgba(248, 81, 73, 0.15), inset 0 0 5px rgba(248, 81, 73, 0.05);
        border-color: rgba(248, 81, 73, 0.6);
    }
    to {
        box-shadow: 0 0 16px rgba(248, 81, 73, 0.35), inset 0 0 12px rgba(248, 81, 73, 0.2);
        border-color: #f85149;
    }
}

.footer-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08) 20%, rgba(255, 255, 255, 0.08) 80%, transparent);
    width: 100%;
}

.utility-divider {
    width: 1px;
    height: 28px;
    background: rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.icon-node {
    width: 52px;
    height: 52px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s ease;
}

.icon-node:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.kill-node {
    border-color: rgba(248, 81, 73, 0.3);
}

.kill-node:hover {
    background: rgba(248, 81, 73, 0.2);
    border-color: #f85149;
    color: #f85149;
    box-shadow: 0 0 15px rgba(248, 81, 73, 0.4);
}


/* Danger Line v2.1 */
#danger-line {
    position: absolute;
    top: 130px;
    /* Threshold */
    left: 0;
    right: 0;
    height: 2px;
    border-top: 2px dashed rgba(248, 81, 73, 0.5);
    box-shadow: 0 0 10px rgba(248, 81, 73, 0.3);
    z-index: 2;
    pointer-events: none;
}

#danger-line::before {
    content: 'CRITICAL_LIMIT';
    position: absolute;
    right: 10px;
    top: -12px;
    font-size: 8px;
    color: rgba(248, 81, 73, 0.8);
    letter-spacing: 1px;
}

#next-type-label {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--accent-primary);
}

/* Score Pop Animation */
#score-value.pop {
    animation: score-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes score-pop {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }

    50% {
        transform: scale(1.3);
        filter: brightness(2);
    }

    100% {
        transform: scale(1);
        filter: brightness(1);
    }
}

/* Compile Glow Animation */
.compile-glow {
    animation: compile-pulse 1s ease-out;
}

@keyframes compile-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(88, 166, 255, 0.5);
        border-color: var(--accent-primary);
    }

    100% {
        box-shadow: 0 0 50px 20px transparent;
        border-color: rgba(255, 255, 255, 0.1);
    }
}

/* Background Console Expansion & Animation */
#console-logs {
    position: fixed;
    inset: 0;
    padding: 100px 30px 200px;
    font-size: 11px;
    line-height: 1.8;
    color: var(--terminal-green);
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column-reverse;
    /* mask-image: linear-gradient(to bottom, transparent, black 15%, black 85%, transparent); */
}

.log-line {
    opacity: 0.7;
}

.log-line.success {
    color: var(--accent-success);
    opacity: 0.7;
}

.log-line.warn {
    color: var(--accent-warning);
    opacity: 0.7;
}

.log-line.error {
    color: var(--accent-danger);
    opacity: 0.7;
}

@keyframes log-fade-in {
    from {
        transform: translateX(-10px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 0.7;
    }
}

/* Fast logging effect */
.logging-fast .log-line {
    animation-duration: 0.1s;
}

.title-group {
    flex: 1;
    min-width: 0;
}

h1 {
    font-size: 20px;
    letter-spacing: 2px;
    color: var(--accent-primary);
    text-shadow: 0 0 10px rgba(88, 166, 255, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.subtitle {
    font-size: 9px;
    color: #8b949e;
    margin-top: -2px;
}

.score-board {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
    pointer-events: auto;
}

#sound-toggle {
    background: var(--panel-bg);
    border: 1px solid #30363d;
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.2s;
    outline: none;
    pointer-events: auto;
    z-index: 100;
}

#sound-toggle:hover {
    background: #30363d;
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(88, 166, 255, 0.2);
}

#sound-toggle.muted .icon {
    filter: grayscale(1) opacity(0.5);
}

.score-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.score-text {
    text-align: right;
    line-height: 1;
}

.score-text .label {
    font-size: 8px;
    color: #8b949e;
    margin-right: 5px;
}

#score-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--accent-warning);
}

.score-text.high-score #high-score-value {
    font-size: 16px;
    color: #8b949e;
}

.score-text.high-score .label {
    font-size: 7px;
}

/* Controls Top Right */
.controls-top-right {
    position: absolute;
    top: 95px;
    right: 20px;
    width: 140px;
    /* Fixed width to prevent drift */
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 30;
    /* Higher than header bg */
}

.compile-box {
    background: var(--panel-bg);
    backdrop-filter: blur(10px);
    border: 1px solid #30363d;
    padding: 10px;
    border-radius: 4px;
}

.compile-box .label {
    font-size: 8px;
    color: #8b949e;
    margin-bottom: 5px;
}

#compile-btn {
    background: var(--accent-primary);
    color: white;
    border: none;
    font-family: var(--font-mono);
    font-weight: bold;
    padding: 6px;
    width: 100%;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 11px;
    pointer-events: auto;
    z-index: 100;
}

#compile-btn:hover {
    background: #79c0ff;
    box-shadow: 0 0 15px rgba(88, 166, 255, 0.4);
}

#compaction-btn {
    --fill-percent: 0%;
    background: linear-gradient(to top, rgba(210, 153, 34, 0.3) var(--fill-percent), transparent var(--fill-percent));
    color: #d29922;
    border: 1px solid #d29922;
    position: relative;
    overflow: hidden;
    font-family: var(--font-mono);
    font-weight: bold;
    padding: 10px 6px;
    width: 100%;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
    font-size: 11px;
    pointer-events: auto;
    z-index: 100;
    margin-bottom: 0px;
    letter-spacing: 2px;
}

@keyframes defrag-ready {
    from {
        box-shadow: 0 0 4px rgba(210, 153, 34, 0.2);
    }

    to {
        box-shadow: 0 0 12px rgba(210, 153, 34, 0.6);
    }
}

#compaction-btn:hover:not(:disabled) {
    background: rgba(210, 153, 34, 0.15);
    box-shadow: 0 0 20px rgba(210, 153, 34, 0.8);
}

#compaction-btn:disabled {
    color: #444;
    border-color: #333;
    cursor: not-allowed;
    animation: none;
    box-shadow: none;
    background: linear-gradient(to top, rgba(210, 153, 34, 0.15) var(--fill-percent), transparent var(--fill-percent));
}

#compaction-btn.ready {
    background: linear-gradient(to top, rgba(252, 202, 63, 0.4) 100%, transparent 100%);
    color: #fcca3f;
    border-color: #fcca3f;
    animation: compaction-glow-pulse 1.5s infinite alternate;
    text-shadow: 0 0 8px rgba(252, 202, 63, 0.5);
}

@keyframes compaction-glow-pulse {
    from {
        box-shadow: 0 0 5px rgba(252, 202, 63, 0.2);
    }
    to {
        box-shadow: 0 0 20px rgba(252, 202, 63, 0.6), inset 0 0 10px rgba(252, 202, 63, 0.2);
    }
}

/* Next Preview — positioned outside bucket by JS */
#next-preview {
    position: fixed;
    background: var(--panel-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 10px 8px;
    border-radius: 12px;
    width: 72px;
    text-align: center;
    pointer-events: none;
    z-index: 40;
    display: none; /* hidden until game starts, shown by JS */
}

#next-preview.visible {
    display: block;
}

#next-preview .label {
    font-size: 8px;
    color: #8b949e;
    letter-spacing: 1px;
}

#next-type-label {
    font-size: 10px;
    margin: 3px 0;
    color: var(--accent-success);
}

#next-visual {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin: 0 auto;
    transition: all 0.3s;
}

/* Game Over Overlay */
#game-over-overlay {
    position: absolute;
    inset: 0;
    background: rgba(13, 17, 23, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    visibility: visible;
    pointer-events: auto;
}

#game-over-overlay.hidden {
    visibility: hidden;
    pointer-events: none;
    display: none;
}

.hidden {
    display: none !important;
}

.error-window {
    width: 80%;
    border: 2px solid var(--accent-danger);
    background: #0d1117;
    box-shadow: 0 0 30px rgba(248, 81, 73, 0.3);
}

.error-header {
    background: var(--accent-danger);
    color: white;
    padding: 5px 10px;
    font-weight: bold;
    font-size: 14px;
}

.error-body {
    padding: 20px;
    font-size: 13px;
    line-height: 1.6;
}

.error-body p {
    margin-bottom: 20px;
}

.error-window.success-state {
    border-color: var(--accent-success);
    box-shadow: 0 0 30px rgba(46, 204, 113, 0.4);
}

.error-window.success-state .error-header {
    background: var(--accent-success);
    color: #0d1117;
}

#restart-btn {
    background: transparent;
    border: 1px solid var(--accent-danger);
    color: var(--accent-danger);
    padding: 10px 20px;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: 0.2s;
}

#restart-btn:hover {
    background: var(--accent-danger);
    color: white;
}

/* Start Overlay */
#start-overlay {
    position: absolute;
    inset: 0;
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    z-index: 600; /* Lower than boot */
    transition: opacity 1s, visibility 1s;
    visibility: visible;
    pointer-events: auto;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

#start-overlay::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

#start-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.privacy-notice {
    margin-top: 25px;
    font-size: 10px;
    color: #8b949e;
    text-align: left;
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.privacy-notice p {
    margin-bottom: 8px;
    font-weight: bold;
}

.privacy-notice ul {
    margin-bottom: 12px;
    padding-left: 15px;
}

.privacy-notice a {
    color: var(--accent-primary);
    text-decoration: none;
}

.privacy-notice a:hover {
    text-decoration: underline;
}

.purge-btn {
    display: block;
    width: 100%;
    background: transparent;
    border: 1px solid rgba(248, 81, 73, 0.3);
    color: #f85149;
    font-family: var(--font-mono);
    font-size: 9px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 4px;
    opacity: 0.7;
}

.purge-btn:hover {
    background: rgba(248, 81, 73, 0.1);
    border-color: #f85149;
    opacity: 1;
    box-shadow: 0 0 10px rgba(248, 81, 73, 0.2);
}

.start-logo {
    width: 200px;
    height: 200px;
    background-image: url('sprites.png');
    background-position: 100% 100%; /* Responsive alignment for bottom-right tile */
    background-size: 400% 400%; /* Responsive scale for 4x4 grid spritesheet */
    margin: 0 auto 20px;
    filter: drop-shadow(0 0 15px var(--accent-primary));
}

.score-records-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 15px auto 10px;
    width: 100%;
}

#personal-best-display, #world-record-display {
    font-size: 12px;
    letter-spacing: 2px;
    padding: 8px 15px;
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
    box-sizing: border-box;
    border-radius: 4px;
}

#personal-best-display {
    color: var(--accent-warning);
    background: color-mix(in srgb, var(--accent-warning) 5%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent-warning) 20%, transparent);
    animation: pb-pulse 2s infinite alternate;
}

#world-record-display {
    color: var(--accent-primary);
    background: color-mix(in srgb, var(--accent-primary) 5%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent-primary) 20%, transparent);
    animation: wr-pulse 2s infinite alternate;
}

#world-record-display.hidden {
    display: none !important;
}

#pb-score {
    font-weight: bold;
    font-size: 16px;
    text-shadow: 0 0 10px var(--accent-warning);
}

.pb-label {
    color: #8b949e;
    font-size: 10px;
}

#wr-score {
    font-weight: bold;
    font-size: 16px;
    text-shadow: 0 0 10px var(--accent-primary);
}

.wr-user {
    color: #8b949e;
    font-size: 10px;
}

@keyframes wr-pulse {
    from {
        border-color: color-mix(in srgb, var(--accent-primary) 10%, transparent);
        opacity: 0.8;
    }
    to {
        border-color: color-mix(in srgb, var(--accent-primary) 40%, transparent);
        opacity: 1;
    }
}

@keyframes pb-pulse {
    from {
        border-color: color-mix(in srgb, var(--accent-warning) 10%, transparent);
        opacity: 0.8;
    }
    to {
        border-color: color-mix(in srgb, var(--accent-warning) 40%, transparent);
        opacity: 1;
    }
}

#start-btn, .primary-btn {
    background: transparent;
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary);
    padding: 15px 40px;
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: bold;
    letter-spacing: 4px;
    cursor: pointer;
    margin-top: 30px;
    transition: all 0.3s;
    box-shadow: 0 0 10px rgba(88, 166, 255, 0.2);
}

#start-btn:hover, .primary-btn:hover {
    background: var(--accent-primary);
    color: #0d1117;
    box-shadow: 0 0 30px rgba(88, 166, 255, 0.6);
}

.secondary-btn {
    background: transparent;
    border: 1px solid #30363d;
    color: #8b949e;
    padding: 10px 30px;
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 3px;
    cursor: pointer;
    margin-top: 12px;
    transition: all 0.3s;
    display: block;
    width: 100%;
}

.secondary-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(88, 166, 255, 0.2);
}

/* Game Over Buttons */
.game-over-btns {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.privacy-notice {
    margin-top: 30px;
    font-size: 10px;
    color: #8b949e;
    text-align: left;
    max-width: 400px;
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border: 1px solid #30363d;
    line-height: 1.4;
}

.privacy-notice p {
    margin-bottom: 8px;
    font-weight: bold;
    color: #58a6ff;
}

.privacy-notice ul {
    list-style: none;
    padding: 0;
}

.privacy-notice li {
    position: relative;
    padding-left: 15px;
    margin-bottom: 5px;
}

.privacy-notice li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: #58a6ff;
}

#ranking-overlay {
    position: absolute;
    inset: 0;
    background: rgba(13, 17, 23, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    visibility: visible;
    pointer-events: auto;
}

#ranking-overlay.hidden {
    visibility: hidden;
    pointer-events: none;
    display: none;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: scale(0.97);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.ranking-window {
    width: 90%;
    max-height: 80%;
    border: 1px solid var(--accent-primary);
    background: #0d1117;
    box-shadow: 0 0 40px rgba(88, 166, 255, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ranking-header {
    background: var(--accent-primary);
    color: #0d1117;
    padding: 8px 14px;
    font-weight: bold;
    font-size: 14px;
    letter-spacing: 3px;
}

.ranking-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

#ranking-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-bottom: 16px;
}

#ranking-table th {
    color: #8b949e;
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid #30363d;
    letter-spacing: 2px;
    font-size: 10px;
}

#ranking-table td {
    padding: 8px 8px;
    border-bottom: 1px solid #161b22;
    color: var(--text-main);
    transition: color 0.2s;
}

#ranking-table tr:nth-child(1) td {
    color: #ffd700;
}

#ranking-table tr:nth-child(2) td {
    color: #c0c0c0;
}

#ranking-table tr:nth-child(3) td {
    color: #cd7f32;
}

.rank-cell {
    color: #8b949e;
    font-size: 11px;
}

#close-ranking-btn {
    background: transparent;
    border: 1px solid var(--accent-danger);
    color: var(--accent-danger);
    padding: 8px 20px;
    font-family: var(--font-mono);
    font-size: 12px;
    cursor: pointer;
    transition: 0.2s;
    width: 100%;
    letter-spacing: 2px;
}

#close-ranking-btn:hover {
    background: var(--accent-danger);
    color: white;
}

.ranking-loading {
    text-align: center;
    color: #8b949e;
    padding: 20px;
    font-size: 12px;
    letter-spacing: 2px;
    animation: blinker 1s linear infinite;
}

.my-rank-row td {
    background: rgba(88, 166, 255, 0.05);
    color: var(--accent-primary) !important;
}


/* Boot Sequence Overlay */
#boot-overlay {
    position: absolute;
    inset: 0;
    background: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5000; /* Highest priority on launch */
    transition: opacity 1s ease-out;
    touch-action: none;
    /* Block browser gestures on terminal */
}

#boot-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.boot-terminal {
    width: 88%;
    max-height: 70%;
    background: var(--panel-bg);
    border: 1px solid color-mix(in srgb, var(--accent-primary) 30%, transparent);
    border-radius: 6px;
    box-shadow:
        0 0 0 1px #000,
        0 30px 80px rgba(0, 0, 0, 0.8),
        0 0 60px color-mix(in srgb, var(--accent-primary) 8%, transparent);
    overflow: hidden;
    animation: terminal-appear 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes terminal-appear {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.boot-terminal-bar {
    display: flex;
    align-items: center;
    padding: 4px 12px;
    background: color-mix(in srgb, var(--accent-primary) 20%, #000);
    border-bottom: 1px solid color-mix(in srgb, var(--accent-primary) 30%, transparent);
}

.boot-terminal-title {
    font-size: 11px;
    color: #ffffff;
    font-weight: bold;
    letter-spacing: 1px;
}

.boot-terminal-body {
    padding: 18px 16px;
    min-height: 160px;
    max-height: 360px;
    overflow-y: auto;
    position: relative;
}

/* Subtle scanline effect */
.boot-terminal-body::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.04) 2px,
            rgba(0, 0, 0, 0.04) 4px);
    pointer-events: none;
}

#boot-log-area {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.boot-log-line {
    font-size: 12px;
    line-height: 1.6;
    color: color-mix(in srgb, var(--accent-primary) 50%, transparent);
    animation: line-appear 0.2s ease both;
    word-break: break-all;
}

@media (max-width: 480px) {
    .boot-log-line {
        font-size: 10px;
    }

    .boot-terminal-body {
        padding: 12px 10px;
    }
}

.boot-log-line.active {
    color: var(--text-main);
}

.boot-log-line.warn-log {
    color: var(--accent-warning);
}

.boot-log-line.ok-log {
    color: var(--accent-primary);
}

.boot-log-line.hi-log {
    color: var(--text-main);
    font-weight: bold;
}

@keyframes line-appear {
    from {
        opacity: 0;
        transform: translateX(-6px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.boot-cursor {
    display: inline-block;
    color: var(--text-main);
    font-size: 14px;
    margin-top: 4px;
    animation: blinker 0.8s step-end infinite;
}

.skip-btn {
    position: absolute;
    bottom: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.5);
    padding: 6px 12px;
    font-family: var(--font-mono);
    font-size: 10px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    z-index: 10;
}

.skip-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border-color: #fff;
}

/* Touch Target Improvements for Mobile */
button {
    min-height: 40px;
    touch-action: manipulation;
}

#sound-toggle {
    min-width: 44px;
    min-height: 44px;
}

.secondary-btn {
    min-height: 44px;
}

#start-btn {
    min-height: 50px;
}

/* Log Coloring */
.log-line.warn {
    color: var(--accent-warning) !important;
}

.log-line.error {
    color: var(--accent-danger) !important;
    text-shadow: 0 0 5px rgba(248, 81, 73, 0.5);
}

.log-line.success {
    color: var(--accent-success) !important;
}

/* Flash Effect */
#flash-overlay {
    position: absolute;
    inset: 0;
    background: #fff;
    opacity: 0;
    pointer-events: none;
    z-index: 10000; /* Above everything */
}

#flash-overlay.active {
    animation: flash-anim 0.4s ease-out;
}

#flash-overlay.reboot {
    animation: reboot-flicker 0.8s steps(4) forwards;
}

@keyframes flash-anim {
    0% { opacity: 0.8; }
    100% { opacity: 0; }
}

@keyframes reboot-flicker {
    0% { opacity: 0; background: #fff; }
    10% { opacity: 1; background: #000; }
    20% { opacity: 0.4; background: #d29922; }
    40% { opacity: 0.8; background: #000; }
    60% { opacity: 1; background: #fff; }
    80% { opacity: 0.3; background: #000; }
    100% { opacity: 0; background: #000; }
}

@keyframes flash-anim {
    0% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* Compaction Screen */
#compaction-overlay {
    position: absolute;
    inset: 0;
    background: #0d1117;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 300;
}

#compaction-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2100;
    visibility: hidden;
    pointer-events: none;
}

#compaction-overlay.active {
    visibility: visible;
    pointer-events: auto;
    animation: fade-in-out 2.5s ease-in-out forwards;
}

.compaction-content {
    text-align: center;
}

.compaction-logo {
    width: 256px;
    height: 256px;
    background-image: url('sprites.png');
    background-position: -768px -768px;
    /* Row 3, Col 3 */
    background-size: 1024px 1024px;
    margin: 0 auto 30px;
    filter: drop-shadow(0 0 20px var(--accent-primary));
    animation: pulse-glow 1.5s infinite alternate;
}

.compaction-label {
    letter-spacing: 4px;
    color: var(--accent-primary);
    font-size: 14px;
    animation: blinker 1s linear infinite;
}

@keyframes fade-in-out {
    0% {
        opacity: 0;
    }

    20% {
        opacity: 1;
    }

    80% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

@keyframes pulse-glow {
    from {
        transform: scale(0.95);
        opacity: 0.8;
    }

    to {
        transform: scale(1.05);
        opacity: 1;
    }
}

@keyframes blinker {
    50% {
        opacity: 0;
    }
}

/* Game Over Score Display */
.game-over-score-box {
    margin: 15px 0;
    padding: 12px;
    border: 1px dashed rgba(248, 81, 73, 0.4);
    background: rgba(248, 81, 73, 0.05);
    text-align: center;
    border-radius: 4px;
    color: var(--accent-danger);
    font-weight: bold;
    font-size: 13px;
    letter-spacing: 2px;
    font-family: var(--font-mono);
}

.game-over-score-box span {
    font-size: 18px;
    color: var(--accent-danger);
    text-shadow: 0 0 10px var(--accent-danger);
    margin-left: 5px;
}

/* If system recovery success state is active, make it green */
.error-window.success-state .game-over-score-box {
    border-color: rgba(46, 204, 113, 0.4);
    background: rgba(46, 204, 113, 0.05);
    color: var(--accent-success);
}

.error-window.success-state .game-over-score-box span {
    color: var(--accent-success);
    text-shadow: 0 0 10px var(--accent-success);
}

/* Game Over Rank Display */
.rank-syncing-box {
    margin: 12px 0;
    padding: 10px 14px;
    border: 1px solid #30363d;
    font-size: 11px;
    letter-spacing: 2px;
    color: #8b949e;
    text-align: center;
    animation: blinker 1s linear infinite;
}

.rank-syncing-box.revealed {
    animation: none;
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    font-size: 14px;
    font-weight: bold;
    text-shadow: 0 0 10px var(--accent-primary);
    letter-spacing: 3px;
}

.rank-syncing-box.hidden {
    display: none;
}

/* Title screen username */
.title-username {
    font-size: 11px;
    color: #58a6ff;
    letter-spacing: 2px;
    margin: 6px 0 4px;
    font-family: var(--font-mono);
    opacity: 0.8;
}

/* Leaderboard section divider */
.rank-divider td {
    text-align: center;
    font-size: 9px;
    letter-spacing: 2px;
    color: #444c56;
    padding: 8px 0 4px;
    border-bottom: 1px solid #21262d;
}

/* Cut-in Effect */
#cutin-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 800;
    overflow: hidden;
    pointer-events: none;
}

#cutin-overlay.active {
    display: flex;
    visibility: visible;
    pointer-events: none; /* Keep none to allow gameplay feel, context-dependent */
}

#cutin-overlay.hidden {
    display: none;
    visibility: hidden;
    pointer-events: none;
}

.cutin-bar {
    position: absolute;
    width: 200%;
    height: 120px;
    background: var(--accent-primary);
    box-shadow: 0 0 30px var(--accent-primary);
    transform: rotate(-15deg);
    opacity: 0;
}

.cutin-bar.top {
    top: 30%;
    transform: translateX(-100%) rotate(-15deg);
}

.cutin-bar.bottom {
    bottom: 30%;
    transform: translateX(100%) rotate(-15deg);
    background: #0d1117;
    border-top: 2px solid var(--accent-primary);
    border-bottom: 2px solid var(--accent-primary);
}

.cutin-content {
    position: relative;
    z-index: 2;
    transform: scale(0);
    opacity: 0;
}

.cutin-text {
    font-size: 24px;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 20px var(--accent-primary), 0 0 40px var(--accent-primary);
    letter-spacing: 4px;
    font-family: var(--font-mono);
    white-space: nowrap;
}

/* Cut-in Animations */
#cutin-overlay.active .cutin-bar.top {
    animation: cutin-bar-top 0.8s cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

#cutin-overlay.active .cutin-bar.bottom {
    animation: cutin-bar-bottom 0.8s cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

#cutin-overlay.active .cutin-content {
    animation: cutin-text-pop 0.8s cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

@keyframes cutin-bar-top {
    0% {
        transform: translateX(-100%) rotate(-15deg);
        opacity: 0.8;
    }

    40% {
        transform: translateX(0%) rotate(-15deg);
        opacity: 1;
    }

    80% {
        transform: translateX(0%) rotate(-15deg);
        opacity: 1;
    }

    100% {
        transform: translateX(100%) rotate(-15deg);
        opacity: 0;
    }
}

@keyframes cutin-bar-bottom {
    0% {
        transform: translateX(100%) rotate(-15deg);
        opacity: 0.8;
    }

    40% {
        transform: translateX(0%) rotate(-15deg);
        opacity: 1;
    }

    80% {
        transform: translateX(0%) rotate(-15deg);
        opacity: 1;
    }

    100% {
        transform: translateX(-100%) rotate(-15deg);
        opacity: 0;
    }
}

@keyframes cutin-text-pop {
    0% {
        transform: scale(3);
        opacity: 0;
        filter: blur(10px);
    }

    30% {
        transform: scale(1);
        opacity: 1;
        filter: blur(0px);
    }

    80% {
        transform: scale(1);
        opacity: 1;
        filter: blur(0px);
    }

    100% {
        transform: scale(0.5);
        opacity: 0;
        filter: blur(5px);
    }
}

/* Evolution Chain HUD (v2.3) */
#evolution-chain {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 4px;
    opacity: 0.9;
    max-width: 280px; 
}

.chain-node {
    width: 32px;
    height: 32px;
    background-size: contain;
    background-repeat: no-repeat;
    border-radius: 4px;
}

.chain-arrow {
    font-size: 8px;
    opacity: 0.2;
    color: #fff;
}


@keyframes hint-glow {
    from { opacity: 0.7; filter: brightness(0.8); }
    to { opacity: 1; filter: brightness(1.2); }
}

.objective-hint {
    margin: 15px 0;
    font-size: 11px;
    color: var(--accent-success);
    opacity: 0.9;
    letter-spacing: 1px;
}
/* Safety Gauge HUD (v2.5) */
#safety-gauge-container {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    z-index: 100;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#safety-gauge-label {
    font-size: 10px;
    color: var(--accent-success);
    margin-bottom: 4px;
    text-align: center;
    letter-spacing: 1px;
    font-family: inherit;
    text-shadow: 0 0 5px var(--accent-success);
}

#safety-gauge-bar {
    height: 4px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--accent-success);
    overflow: hidden;
}

#safety-gauge-inner {
    height: 100%;
    width: 100%;
    background: var(--accent-success);
    box-shadow: 0 0 10px var(--accent-success);
    transform-origin: left center;
}

.safety-active #safety-gauge-inner {
    animation: shrink-gauge 5s linear forwards;
}

@keyframes shrink-gauge {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* Mobile Responsive Overrides (Fixing Horizontal Overflow) */
@media (max-width: 600px) {
    #top-header {
        height: 55px; /* Compact header */
        padding: 4px 25px 4px 15px; /* Extra padding on the right for iOS curves and glow */
        align-items: center;
        justify-content: flex-end; /* Align remaining content to the right */
    }
    .header-left {
        display: none;
    }
    .score-display .value {
        font-size: 16px; /* slightly smaller to safely avoid clipping */
    }
    .system-status {
        display: none;
    }

    /* Start Screen Mobile Compacting */
    #start-overlay {
        padding: 15px 0;
    }
    .start-content {
        padding: 10px;
        width: 100%;
        max-width: 320px;
        margin: 20px auto; /* Keeps it centered but scrollable without top/bottom clipping */
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .start-logo {
        width: 70px; /* Compacted from 120px */
        height: 70px;
        margin: 0 auto 6px;
    }
    .start-content h1 {
        white-space: normal;
        font-size: 16px;
        margin: 4px 0;
    }
    .start-content .subtitle {
        font-size: 10px;
        margin-bottom: 6px;
    }
    .start-content .objective-hint {
        margin: 4px 0;
        font-size: 10px;
        text-align: center;
    }
    .start-content .title-username {
        margin: 4px 0 2px;
        font-size: 10px;
    }
    .score-records-container {
        margin: 6px auto;
        gap: 8px;
    }
    #personal-best-display, #world-record-display {
        padding: 4px 10px;
        min-width: 120px;
        font-size: 10px;
    }
    #personal-best-display #pb-score, #world-record-display #wr-score {
        font-size: 13px;
    }
    .pb-label, .wr-label {
        font-size: 8px;
    }
    #start-btn {
        width: 100%;
        min-height: 40px; /* Compact but tap-friendly */
        margin-bottom: 6px;
        font-size: 13px;
    }
    .start-content .ad-option {
        margin-top: 8px !important;
        margin-bottom: 8px !important;
    }
    .start-content .ad-option span {
        font-size: 0.8em;
    }
    #show-ranking-start {
        width: 100%;
        min-height: 38px;
        font-size: 11px;
    }
    .privacy-notice {
        margin-top: 10px;
        padding: 10px;
        font-size: 8px;
        width: 100%;
        box-sizing: border-box;
    }
    .privacy-notice p {
        margin-bottom: 4px;
    }
    .privacy-notice ul {
        margin-bottom: 6px;
        padding-left: 10px;
    }
    .privacy-notice li {
        margin-bottom: 2px;
    }
    .purge-btn {
        padding: 6px;
        font-size: 8px;
    }

    /* Footer/Command Center Mobile Compacting */
    #command-center {
        padding: 12px;
        gap: 8px;
        bottom: calc(env(safe-area-inset-bottom) + 12px);
    }
    .input-group {
        height: 44px;
        padding: 4px 10px;
    }
    .input-label {
        font-size: 7px;
    }
    #target-type-selector {
        font-size: 10px;
        height: 22px;
        background-position: right 4px center;
        padding: 2px 16px 2px 4px;
    }
    .primary-node, .secondary-node {
        height: 44px;
        font-size: 12px;
    }
    .utility-divider {
        height: 24px;
    }
}

.danger-btn {
    background: transparent;
    border: 1px solid var(--accent-danger);
    color: var(--accent-danger);
    padding: 10px 20px;
    font-family: var(--font-mono);
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
    border-radius: 4px;
}
.danger-btn:hover {
    background: var(--accent-danger);
    color: white;
    box-shadow: 0 0 15px rgba(248, 81, 73, 0.4);
}

/* Legal Modal Styling */
#legal-modal {
    position: absolute;
    inset: 0;
    background: rgba(13, 17, 23, 0.96);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#legal-modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.legal-window {
    width: 90%;
    max-width: 420px;
    height: 75%;
    max-height: 500px;
    background: hsla(var(--h-bg), var(--s-bg), 6%, 0.95);
    border: 1px solid rgba(88, 166, 255, 0.25);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 30px rgba(88, 166, 255, 0.1);
}

.legal-header {
    background: rgba(88, 166, 255, 0.1);
    color: var(--accent-primary);
    padding: 14px 20px;
    font-family: var(--font-mono);
    font-weight: bold;
    font-size: 13px;
    border-bottom: 1px solid rgba(88, 166, 255, 0.2);
    letter-spacing: 1px;
}

.legal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
}

#legal-text-content {
    flex: 1;
    overflow-y: auto;
    font-size: 11px;
    line-height: 1.6;
    color: var(--text-main);
    margin-bottom: 15px;
    padding-right: 8px;
    text-align: left;
    font-family: var(--font-mono);
}

#legal-text-content h2 {
    font-size: 12px;
    color: var(--accent-primary);
    margin-top: 18px;
    margin-bottom: 8px;
    border-left: 2px solid var(--accent-primary);
    padding-left: 8px;
}

#legal-text-content p {
    margin-bottom: 10px;
}

#legal-text-content ul {
    margin-bottom: 10px;
    padding-left: 14px;
}

#legal-text-content li {
    margin-bottom: 4px;
}

/* Custom scrollbar for legal document */
#legal-text-content::-webkit-scrollbar {
    width: 4px;
}
#legal-text-content::-webkit-scrollbar-track {
    background: transparent;
}
#legal-text-content::-webkit-scrollbar-thumb {
    background: rgba(88, 166, 255, 0.3);
    border-radius: 2px;
}

/* ==========================================================================
   App-like UI Constraints & Click Blocker (Prevent text selection / drag)
   ========================================================================== */
body {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none; /* Disable context menu callout on iOS long-press */
}

/* Make inputs or textareas selectable if needed (currently none relevant, but good practice) */
input, textarea, select {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

img {
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    pointer-events: none; /* Prevents copying, dragging and tap-highlighting */
}

/* Screen transition global click blocker overlay */
#click-blocker {
    position: fixed;
    inset: 0;
    z-index: 99999; /* Ensure it stays above all other panel elements and modals */
    background: transparent;
    pointer-events: auto;
    cursor: default;
}
#click-blocker.hidden {
    display: none;
    pointer-events: none;
}

/* How to Play Modal Styling */
#how-to-play-modal {
    position: absolute;
    inset: 0;
    background: rgba(13, 17, 23, 0.96);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#how-to-play-modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.legal-text-content-scrollable {
    flex: 1;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-main);
    margin-bottom: 15px;
    padding-right: 8px;
    text-align: left;
    font-family: var(--font-mono);
}

.legal-text-content-scrollable h2 {
    font-size: 15px;
    color: var(--accent-primary);
    margin-top: 18px;
    margin-bottom: 8px;
    border-left: 2px solid var(--accent-primary);
    padding-left: 8px;
}

.legal-text-content-scrollable p {
    margin-bottom: 10px;
}

.legal-text-content-scrollable code {
    background: rgba(255, 255, 255, 0.15);
    padding: 2px 4px;
    border-radius: 2px;
    color: var(--accent-warning);
}

.legal-text-content-scrollable::-webkit-scrollbar {
    width: 4px;
}
.legal-text-content-scrollable::-webkit-scrollbar-track {
    background: transparent;
}
.legal-text-content-scrollable::-webkit-scrollbar-thumb {
    background: rgba(88, 166, 255, 0.3);
    border-radius: 2px;
}




/* =========================================================
   PC Desktop: Home Screen Vertical Scroll
   ========================================================= */
@media (min-width: 601px) {
    .start-content {
        margin: 40px auto;
        padding: 30px 20px;
    }
}

/* --- Billing Overlay Styles --- */
#billing-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, #0f1319 0%, #06080a 100%);
    z-index: 1000;
    overflow-y: auto;
    padding: 30px 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: var(--font-mono);
}

#billing-overlay.hidden {
    display: none !important;
}

.billing-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    z-index: 1010;
    transition: all 0.2s ease;
}

.billing-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.billing-badge {
    border: 1px solid #ff5eb4;
    color: #ff5eb4;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 15px;
    box-shadow: 0 0 10px rgba(255, 94, 180, 0.2);
    display: inline-block;
    text-align: center;
}

.billing-title {
    font-size: 28px;
    font-weight: bold;
    text-align: center;
    color: #fff;
    margin-bottom: 8px;
    line-height: 1.3;
}

.billing-title span {
    background: linear-gradient(90deg, #ff5eb4 0%, #a05eff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.billing-subtitle {
    font-size: 15px;
    color: #8b949e;
    text-align: center;
    max-width: 440px;
    margin-bottom: 25px;
    line-height: 1.7;
    padding: 0 10px;
}

.billing-cards {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 480px;
    margin-bottom: 25px;
}

.billing-card {
    background: rgba(22, 27, 34, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.billing-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(to bottom, #ff5eb4, #a05eff);
}

.billing-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.billing-card-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 94, 180, 0.1);
    border: 1px solid rgba(255, 94, 180, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ff5eb4;
    font-size: 16px;
}

.billing-card-title {
    font-size: 18px;
    font-weight: bold;
    color: #f0f6fc;
}

.billing-card-desc {
    font-size: 15px;
    color: #8b949e;
    line-height: 1.7;
    margin-bottom: 12px;
    text-align: left;
}

/* Metric / Chart styles */
.metric-container {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.metric-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
}

.metric-label {
    color: #8b949e;
}

.metric-value-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.metric-bars {
    display: flex;
    gap: 3px;
}

.metric-bar {
    width: 12px;
    height: 6px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
}

.metric-bar.active-normal {
    background: #a05eff;
}

.metric-bar.active-root {
    background: #ff5eb4;
}

.metric-num {
    font-weight: bold;
    color: #f0f6fc;
}

/* Diagram layout */
.diagram-container {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    font-size: 10px;
    overflow: hidden;
}

.diagram-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
    z-index: 2;
}

.diagram-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.diagram-dot.blue { background: #58a6ff; box-shadow: 0 0 8px #58a6ff; }
.diagram-dot.pink { background: #ff5eb4; box-shadow: 0 0 8px #ff5eb4; }

.diagram-label {
    color: #8b949e;
    font-size: 9.5px;
    white-space: nowrap;
}

.diagram-sublabel {
    color: #c9d1d9;
    font-weight: bold;
}

.diagram-arrow-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    margin: 0 5px;
    z-index: 1;
}

.diagram-line {
    width: 100%;
    height: 2px;
    border-top: 1px dashed rgba(255, 94, 180, 0.4);
    position: relative;
}

.diagram-badge {
    background: rgba(255, 94, 180, 0.15);
    border: 1px solid rgba(255, 94, 180, 0.3);
    color: #ff5eb4;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 9px;
    margin-bottom: 4px;
    white-space: nowrap;
}

/* Main CTA Box */
.billing-cta-box {
    background: rgba(22, 27, 34, 0.85);
    border: 1px solid rgba(255, 94, 180, 0.2);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 10px 30px rgba(255, 94, 180, 0.05);
}

.cta-license-tag {
    font-size: 10.5px;
    color: #ff5eb4;
    letter-spacing: 1px;
    font-weight: bold;
    margin-bottom: 6px;
}

.cta-price-box {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-bottom: 6px;
}

.cta-price-symbol {
    font-size: 18px;
    font-weight: bold;
    color: #ff5eb4;
}

.cta-price-amount {
    font-size: 36px;
    font-weight: bold;
    color: #fff;
}

.cta-price-period {
    font-size: 14px;
    color: #8b949e;
}

.cta-price-sub {
    font-size: 13px;
    color: #8b949e;
    margin-bottom: 20px;
}

.cta-bullets {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-bottom: 25px;
}

.cta-bullet {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 15px;
    color: #c9d1d9;
    text-align: left;
}

.cta-bullet-check {
    color: #ff5eb4;
    font-size: 14px;
}

.cta-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #ff5eb4 0%, #a05eff 100%);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(160, 94, 255, 0.3);
    font-family: var(--font-mono);
}

.cta-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(160, 94, 255, 0.5);
    filter: brightness(1.1);
}

.cta-btn:active {
    transform: translateY(0);
}

.cta-btn:disabled {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #484f58 !important;
    box-shadow: none !important;
    cursor: not-allowed !important;
    transform: none !important;
    filter: none !important;
}

.cta-btn:disabled .cta-btn-icon {
    opacity: 0.3;
}

#billing-restore-btn:disabled {
    background: rgba(0, 0, 0, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.05) !important;
    color: #484f58 !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
}

.cta-btn-icon {
    font-size: 14px;
}

.cta-trust-footer {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    font-size: 10px;
    color: #8b949e;
}

.lang-toggle-container {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.lang-toggle-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    padding: 4px 8px;
    font-size: 10.5px;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-mono);
}

.lang-toggle-btn.active {
    background: rgba(255, 94, 180, 0.15);
    border-color: #ff5eb4;
    color: #ff5eb4;
    font-weight: bold;
}

/* Spinner and Simulator styling */
#checkout-simulation-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

#checkout-simulation-overlay.hidden {
    display: none !important;
}

.sim-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 94, 180, 0.2);
    border-radius: 50%;
    border-top-color: #ff5eb4;
    animation: sim-spin 1s linear infinite;
}

@keyframes sim-spin {
    to { transform: rotate(360deg); }
}

/* Locked rollback button overrides */
.primary-btn.locked-rollback {
    background: rgba(255, 94, 180, 0.1) !important;
    border: 1px solid rgba(255, 94, 180, 0.4) !important;
    color: #ff5eb4 !important;
    box-shadow: 0 0 10px rgba(255, 94, 180, 0.1) !important;
}

.primary-btn.locked-rollback:hover {
    background: rgba(255, 94, 180, 0.2) !important;
    border-color: #ff5eb4 !important;
    box-shadow: 0 0 15px rgba(255, 94, 180, 0.3) !important;
}

/* Dark Side (Sith) Theme Override */
body.theme-darkside {
    --h-bg: 120; /* Green tint */
    --s-bg: 20%;
    --l-bg: 1.5%; /* Very dark black-green background */

    --bg-color: hsl(var(--h-bg), var(--s-bg), var(--l-bg));
    --panel-bg: hsla(var(--h-bg), var(--s-bg), 5%, 0.85);

    --accent-primary: hsl(120, 50%, 38%); /* Calm, non-glaring retro green */
    --accent-success: hsl(120, 50%, 38%);
    --accent-warning: hsl(40, 60%, 42%);   /* Muted amber warning */
    --accent-danger: hsl(0, 60%, 42%);     /* Muted red alert */

    --text-main: hsl(120, 35%, 68%);        /* Easy-on-the-eyes phosphor green text */
    --terminal-green: hsl(120, 50%, 38%);
}

body.theme-darkside .active-theme-btn {
    border-color: var(--accent-primary) !important;
    color: var(--accent-primary) !important;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5), inset 0 0 5px var(--accent-primary);
    text-shadow: 0 0 5px var(--accent-primary);
}

/* Active Theme Styling for Default */
.active-theme-btn {
    border-color: var(--accent-primary) !important;
    color: var(--accent-primary) !important;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5), inset 0 0 5px var(--accent-primary);
    text-shadow: 0 0 5px var(--accent-primary);
}

/* =========================================================
   WELCOME BACK BANNER (Root Pack users, shown after game start)
   ========================================================= */
#welcome-back-banner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: linear-gradient(135deg,
        rgba(88, 166, 255, 0.15) 0%,
        rgba(255, 94, 180, 0.1) 100%);
    border-bottom: 1px solid rgba(88, 166, 255, 0.3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 20px rgba(88, 166, 255, 0.15);
    transform: translateY(-100%);
    pointer-events: auto;
}

#welcome-back-banner:not(.hidden) {
    animation: banner-slide-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

#welcome-back-banner.banner-slide-out {
    animation: banner-slide-out 0.35s ease-in forwards;
}

@keyframes banner-slide-in {
    from { transform: translateY(-100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

@keyframes banner-slide-out {
    from { transform: translateY(0);    opacity: 1; }
    to   { transform: translateY(-100%); opacity: 0; }
}

#welcome-back-banner.hidden {
    display: none;
}

.wb-icon {
    font-size: 18px;
    flex-shrink: 0;
    animation: wb-pulse 2s ease-in-out infinite alternate;
}

@keyframes wb-pulse {
    from { filter: drop-shadow(0 0 4px rgba(255, 94, 180, 0.6)); }
    to   { filter: drop-shadow(0 0 10px rgba(88, 166, 255, 0.9)); }
}

.wb-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 0;
}

#wb-title {
    font-size: 11px;
    font-weight: bold;
    color: #58a6ff;
    letter-spacing: 1.5px;
    text-shadow: 0 0 8px rgba(88, 166, 255, 0.6);
    font-family: var(--font-mono);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#wb-sub {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.5px;
    font-family: var(--font-mono);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wb-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-size: 12px;
    cursor: pointer;
    padding: 4px 6px;
    min-height: auto;
    flex-shrink: 0;
    transition: color 0.2s;
    font-family: var(--font-mono);
}

.wb-close:hover {
    color: rgba(255, 255, 255, 0.9);
}


/* =========================================================
   PURCHASE SUCCESS OVERLAY (shown after billing completes)
   ========================================================= */
#purchase-success-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#purchase-success-overlay.hidden {
    display: none;
}

.purchase-success-window {
    position: relative;
    background: linear-gradient(160deg,
        rgba(13, 17, 23, 0.97) 0%,
        rgba(22, 28, 38, 0.97) 100%);
    border: 1px solid rgba(255, 94, 180, 0.4);
    border-radius: 16px;
    padding: 36px 28px 28px;
    width: 88%;
    max-width: 340px;
    text-align: center;
    box-shadow:
        0 0 0 1px rgba(255, 94, 180, 0.1),
        0 0 40px rgba(255, 94, 180, 0.15),
        0 0 80px rgba(88, 166, 255, 0.1),
        0 30px 60px rgba(0, 0, 0, 0.7);
    animation: ps-appear 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
    overflow: hidden;
}

@keyframes ps-appear {
    from { transform: scale(0.85) translateY(20px); opacity: 0; }
    to   { transform: scale(1) translateY(0);       opacity: 1; }
}

.purchase-success-glow {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 200px;
    background: radial-gradient(circle,
        rgba(255, 94, 180, 0.25) 0%,
        rgba(88, 166, 255, 0.1) 50%,
        transparent 70%);
    pointer-events: none;
    animation: ps-glow-pulse 2.5s ease-in-out infinite alternate;
}

@keyframes ps-glow-pulse {
    from { opacity: 0.6; transform: translateX(-50%) scale(0.9); }
    to   { opacity: 1;   transform: translateX(-50%) scale(1.1); }
}

.purchase-success-icon {
    font-size: 52px;
    margin-bottom: 14px;
    display: block;
    animation: ps-icon-bounce 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.2s both;
    filter: drop-shadow(0 0 16px rgba(255, 94, 180, 0.8));
}

@keyframes ps-icon-bounce {
    from { transform: scale(0) rotate(-15deg); opacity: 0; }
    60%  { transform: scale(1.15) rotate(5deg); opacity: 1; }
    to   { transform: scale(1) rotate(0deg); opacity: 1; }
}

.purchase-success-title {
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    letter-spacing: 2px;
    font-family: var(--font-mono);
    margin-bottom: 6px;
    text-shadow: 0 0 15px rgba(255, 94, 180, 0.7);
}

.purchase-success-sub {
    font-size: 13px;
    color: #ff5eb4;
    font-family: var(--font-mono);
    letter-spacing: 1px;
    margin-bottom: 12px;
    font-weight: bold;
}

.purchase-success-desc {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.55);
    font-family: var(--font-mono);
    line-height: 1.6;
    margin-bottom: 18px;
}

.purchase-success-features {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 22px;
    text-align: left;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 12px 14px;
}

.ps-feature {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    font-family: var(--font-mono);
}

.ps-check {
    color: #58a6ff;
    font-weight: bold;
    font-size: 13px;
    text-shadow: 0 0 6px rgba(88, 166, 255, 0.7);
    flex-shrink: 0;
}

.ps-close-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #ff5eb4 0%, #58a6ff 100%);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 20px rgba(255, 94, 180, 0.3);
    min-height: 48px;
}

.ps-close-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 25px rgba(255, 94, 180, 0.45);
}


/* =========================================================
   SESSION RANK (today's score rank shown in game over)
   ========================================================= */
.rank-syncing-box.session-rank {
    border-color: rgba(255, 94, 180, 0.4);
    background: rgba(255, 94, 180, 0.04);
    margin-top: 0;
}

.rank-syncing-box.session-rank.revealed {
    border-color: #ff5eb4;
    color: #ff5eb4;
    text-shadow: 0 0 10px rgba(255, 94, 180, 0.7);
    animation: session-rank-glow 1.5s ease-in-out infinite alternate;
}

@keyframes session-rank-glow {
    from { text-shadow: 0 0 6px rgba(255, 94, 180, 0.5); }
    to   { text-shadow: 0 0 16px rgba(255, 94, 180, 0.9); }
}
