/* Chrome around the game follows the g2806.net look (violet + cyan variant).
   The game canvas itself is always a dark space scene, in both themes. */
:root {
    --background: #050505;
    --foreground: #f0f0f0;
    --muted: #a0a0a0;
    --card-bg: #0a0a0a;
    --card-border: #1a1a1a;
    --hover-bg: rgba(255, 255, 255, 0.05);
    --icon-bg: rgba(255, 255, 255, 0.04);
    --violet: #8b5cf6;
    --violet-strong: #7c3aed;
    --violet-light: #a78bfa;
    --cyan: #06b6d4;
    --cyan-light: #22d3ee;
    --orange: #f97316;
    color-scheme: dark;
}

@media (prefers-color-scheme: light) {
    :root {
        --background: #ffffff;
        --foreground: #0f172a;
        --muted: #475569;
        --card-bg: #f8fafc;
        --card-border: #cbd5e1;
        --hover-bg: #f1f5f9;
        --icon-bg: #ffffff;
        --violet-light: #6d28d9;
        --cyan-light: #0e7490;
        color-scheme: light;
    }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
    width: 400px;
    margin: 0;
    background: var(--background);
    color: var(--foreground);
    font-family: 'Quicksand', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 13px;
    line-height: 1.45;
    overflow: hidden;
}

/* Quiet dot grid fading toward the edges. */
.dots {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: radial-gradient(var(--muted) 1.1px, transparent 1.5px);
    background-size: 22px 22px;
    opacity: 0.22;
    -webkit-mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, black 20%, transparent 100%);
    mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, black 20%, transparent 100%);
}

.glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(60px);
    pointer-events: none;
}

.glow-1 { top: -90px; right: -70px; width: 220px; height: 220px; background: rgba(124, 58, 237, 0.10); }
.glow-2 { bottom: -100px; left: -80px; width: 200px; height: 200px; background: rgba(8, 145, 178, 0.10); }

.container {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 11px 10px;
}

a { color: inherit; }

a:focus-visible, button:focus-visible, canvas:focus-visible {
    outline: 2px solid var(--violet-light);
    outline-offset: 2px;
}

/* ---------- Header ---------- */

.header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 2px;
}

.app-icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: var(--icon-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.app-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 3px;
    user-select: none;
    -webkit-user-drag: none;
}

.header-text { flex: 1; min-width: 0; }

.header h1 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.tagline {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

.icon-btn {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    color: var(--foreground);
    cursor: pointer;
    transition: border-color 0.3s, opacity 0.2s;
}

.icon-btn:hover:not(:disabled) { border-color: color-mix(in srgb, var(--muted) 50%, transparent); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn svg { width: 16px; height: 16px; }

/* ---------- Cards ---------- */

.card {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    transition: border-color 0.3s;
}

.card:hover { border-color: color-mix(in srgb, var(--muted) 50%, transparent); }

.card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 1px;
    background: var(--accent);
    opacity: 0.9;
    z-index: 5;
}

.card.violet { --accent: var(--violet); }

/* ---------- Game stage ---------- */
/* Everything inside the stage is sized in em, so the tab view scales the whole UI
   by changing a single font-size (no zoom hack). The popup keeps 13px. */

.stage { position: relative; width: 100%; height: 378px; font-size: 13px; }

#canvas {
    display: block;
    width: 100%;
    height: 376px;
    background: #04030b;
    touch-action: none;
    cursor: crosshair;
    outline-offset: -3px;
}

.hud {
    position: absolute;
    inset: 0.75em 1.1em auto 1.1em;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    color: #f0f0f0;
    z-index: 2;
}

.hud-item { display: flex; flex-direction: column; line-height: 1.15; min-width: 4.5em; }
.hud-item.right { align-items: flex-end; }
.hud-item.center { align-items: center; padding-top: 0.15em; }
.hud-label { font-size: 0.85em; font-weight: 600; color: #b9b4d6; letter-spacing: 0.04em; text-transform: uppercase; }
.hud-value { font-size: 1.55em; font-weight: 700; font-variant-numeric: tabular-nums; }

.meter {
    display: block;
    width: 8.5em;
    height: 0.55em;
    margin-top: 0.3em;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(167, 139, 250, 0.35);
    overflow: hidden;
}

.meter-fill {
    display: block;
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, #8b5cf6, #22d3ee);
    box-shadow: 0 0 0.8em rgba(139, 92, 246, 0.8);
    transition: width 0.35s ease-out;
}

.meter.grow { animation: meter-pop 0.45s ease-out; }
@keyframes meter-pop {
    0% { box-shadow: 0 0 0 0 rgba(167, 139, 250, 0.9); transform: scaleY(1.7); }
    100% { box-shadow: 0 0 0 0.9em rgba(167, 139, 250, 0); transform: none; }
}

.hud-badge {
    position: absolute;
    z-index: 2;
    left: 50%;
    top: 3.9em;
    transform: translateX(-50%);
    padding: 0.2em 0.9em;
    border-radius: 999px;
    background: rgba(6, 182, 212, 0.18);
    border: 1px solid rgba(34, 211, 238, 0.6);
    color: #67e8f9;
    font-size: 0.95em;
    font-weight: 700;
    pointer-events: none;
    animation: badge-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes badge-in { from { opacity: 0; transform: translate(-50%, -6px) scale(0.85); } to { opacity: 1; transform: translateX(-50%); } }

.hud-hint {
    position: absolute;
    z-index: 2;
    left: 50%;
    bottom: 0.7em;
    transform: translateX(-50%);
    font-size: 0.85em;
    font-weight: 600;
    color: #b9b4d6;
    opacity: 0;
    transition: opacity 0.6s;
    pointer-events: none;
}

.hud-hint.show { opacity: 0.85; }

/* Overlay is dark in both themes: it sits on top of the dark canvas. */
.overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.4em;
    background: rgba(4, 3, 11, 0.5);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    color: #f0f0f0;
}

.overlay.hidden { display: none; }

.panel {
    width: 100%;
    max-width: 23.5em;
    text-align: center;
    animation: panel-in 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.panel h2 { margin: 0 0 0.35em; font-size: 1.5em; font-weight: 700; letter-spacing: -0.01em; }
.panel p { margin: 0 0 0.6em; color: #cfcae8; font-size: 1em; }
.panel .kbd-hint { margin: 0.7em 0 0; font-size: 0.85em; color: #a8a3c8; }

@keyframes panel-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* Mode picker */
.modes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4em;
    margin: 0.5em 0;
}

.mode-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.25em;
    padding: 0.55em 0.2em;
    border-radius: 0.9em;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.04);
    color: #cfcae8;
    font: inherit;
    font-size: 0.92em;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.mode-btn svg { width: 1.3em; height: 1.3em; flex-shrink: 0; }
.mode-btn:hover { background: rgba(255, 255, 255, 0.09); }
.mode-btn[aria-checked="true"] {
    color: #fff;
    border-color: var(--violet);
    background: color-mix(in srgb, var(--violet) 26%, transparent);
    box-shadow: 0 0 1.1em rgba(139, 92, 246, 0.35);
}
.mode-btn[data-mode="corner"][aria-checked="true"] { border-color: #fb923c; box-shadow: 0 0 1.1em rgba(249, 115, 22, 0.3); background: color-mix(in srgb, var(--orange) 18%, transparent); }
.mode-btn[data-mode="singularity"][aria-checked="true"] { border-color: var(--cyan-light); box-shadow: 0 0 1.1em rgba(6, 182, 212, 0.35); background: color-mix(in srgb, var(--cyan) 22%, transparent); }
.mode-btn:focus-visible { outline: 2px solid var(--violet-light); outline-offset: 2px; }

.mode-desc { min-height: 2.9em; font-size: 0.95em !important; color: #cfcae8; }

.mode-chip {
    display: inline-block;
    margin: 0 0 0.5em !important;
    padding: 0.1em 0.8em;
    border-radius: 999px;
    border: 1px solid rgba(167, 139, 250, 0.45);
    background: rgba(139, 92, 246, 0.15);
    color: #ddd6fe !important;
    font-size: 0.85em !important;
    font-weight: 700;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 18.5em;
    margin: 0 auto;
    padding: 0.7em 0.9em 0.7em 1.1em;
    border-radius: 0.95em;
    border: 1px solid color-mix(in srgb, var(--violet) 55%, transparent);
    background: color-mix(in srgb, var(--violet) 18%, transparent);
    color: #f0f0f0;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.action-btn:hover { background: color-mix(in srgb, var(--violet) 30%, transparent); border-color: var(--violet); }
.action-btn svg { width: 1.25em; height: 1.25em; flex-shrink: 0; color: #c4b5fd; transition: transform 0.3s; }
.action-btn:hover svg { transform: translateX(3px); }
.action-btn:focus-visible, .mini-btn:focus-visible { outline: 2px solid var(--violet-light); outline-offset: 2px; }

/* Small link buttons, only shown on the menu, pause and game-over panels. */
.mini-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5em; margin-top: 0.8em; }

.mini-btn {
    padding: 0.3em 0.85em;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    color: #e5e7eb;
    font-size: 0.85em;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s;
}

.mini-btn { font-family: inherit; cursor: pointer; }
.mini-btn.violet { --accent: var(--violet); }
.mini-btn.cyan { --accent: var(--cyan); }
.mini-btn.orange { --accent: var(--orange); }
.mini-btn:hover { background: color-mix(in srgb, var(--accent) 24%, transparent); border-color: var(--accent); }

/* On/off pill: a dot that lights up when the switch is on. */
.toggle { display: inline-flex; align-items: center; gap: 0.45em; }
.toggle i { width: 0.65em; height: 0.65em; border-radius: 50%; background: rgba(255, 255, 255, 0.25); transition: background 0.2s, box-shadow 0.2s; }
.toggle[aria-checked="true"] { border-color: var(--cyan-light); background: color-mix(in srgb, var(--cyan) 18%, transparent); }
.toggle[aria-checked="true"] i { background: var(--cyan-light); box-shadow: 0 0 0.6em var(--cyan-light); }

.badge {
    display: inline-block;
    margin: 0 0 0.3em !important;
    padding: 0.15em 0.8em;
    border-radius: 999px;
    background: rgba(6, 182, 212, 0.16);
    border: 1px solid rgba(34, 211, 238, 0.5);
    color: #67e8f9 !important;
    font-size: 0.95em !important;
    font-weight: 700;
}

.final-score {
    font-size: 3.5em;
    font-weight: 700;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
    background: linear-gradient(135deg, #c4b5fd, #67e8f9);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.final-label { font-size: 0.95em !important; margin-bottom: 0.6em !important; }

.stats {
    display: flex;
    gap: 0.45em;
    margin: 0 0 0.9em;
}

.stats > div {
    flex: 1 1 0;
    padding: 0.4em 0.25em;
    border-radius: 0.8em;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    min-width: 0;
}

.stats dt { font-size: 0.82em; color: #b9b4d6; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats dd { margin: 0; font-size: 1.15em; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Footer ---------- */

.footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    color: var(--muted);
    font-size: 11px;
}

.footer a { text-decoration: none; transition: color 0.2s; }
.footer a:hover { color: var(--foreground); }

/* ---------- Toast ---------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: 40px;
    z-index: 10;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--foreground);
    color: var(--background);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    transform: translate(-50%, 8px);
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
    *, *::before { transition-duration: 0s !important; animation-duration: 0s !important; }
}


/* ---------- Tab view (opened from the popup): the stage fills the window ---------- */

#fullscreenButton, #soundButton { display: none; }
.tab-mode #fullscreenButton, .tab-mode #soundButton { display: flex; }
.tab-mode #openTabButton { display: none; }
.icon-btn .ico-on { display: none; }
.icon-btn[aria-checked="true"] .ico-on { display: block; }
.icon-btn[aria-checked="true"] .ico-off { display: none; }
.icon-btn[aria-checked="true"] { color: var(--cyan-light); }

.tab-mode, .tab-mode body { height: 100%; }
.tab-mode body { width: auto; overflow: hidden; }
.tab-mode .container { height: 100%; padding: 0; gap: 0; }
.tab-mode .header { flex: none; height: 52px; padding: 0 14px; gap: 10px; border-bottom: 1px solid var(--card-border); }
.tab-mode .app-icon { width: 34px; height: 34px; border-radius: 10px; }
.tab-mode .tagline { display: none; }
.tab-mode .header h1 { font-size: 16px; }
.tab-mode .stage { flex: 1 1 auto; min-height: 0; height: auto; border: 0; border-radius: 0; font-size: clamp(13px, calc(9px + 0.75vmin), 24px); }
.tab-mode .overlay { background: rgba(4, 3, 11, 0.38); }
.tab-mode .stage::before { display: none; }
.tab-mode #canvas { position: absolute; width: auto; height: auto; }
.tab-mode .footer { display: none; }
.tab-mode .toast { bottom: 24px; }

/* Fullscreen: the header floats over the stage and slides away while you play;
   hover the top edge (or pause) to bring it back. */
.is-fs .header {
    position: absolute;
    inset: 0 0 auto 0;
    z-index: 20;
    background: rgba(5, 5, 10, 0.86);
    --foreground: #f0f0f0; --muted: #a0a0a0; --card-bg: #0a0a0a; --card-border: #1f1f2a;
    color: #f0f0f0;
    transform: translateY(-100%);
    transition: transform 0.3s;
}
.is-fs .header::after { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 14px; }
.is-fs .header:hover, .is-fs .header:focus-within,
.is-fs[data-status="menu"] .header, .is-fs[data-status="paused"] .header, .is-fs[data-status="over"] .header { transform: none; }

/* Touch screens: bigger targets. */
@media (pointer: coarse) {
    .icon-btn { width: 44px; height: 44px; }
    .mini-btn { padding: 0.55em 1em; }
    .mode-btn { padding: 0.85em 0.5em; }
    .action-btn { padding: 0.95em 1em; }
}

/* The live HUD is hidden behind the menu; the demo scene plays on its own. */
[data-status="menu"] .hud, [data-status="menu"] .hud-badge, [data-status="menu"] .hud-hint { display: none; }
.tab-mode #canvas:focus-visible { outline: none; }

/* ---------- Button readability (opaque fills, white text >= 4.5:1, clear hover/focus) ---------- */
:root {
    --btn-bg: color-mix(in srgb, var(--violet-strong) 62%, #0a0a0a);
    --btn-bg-hover: color-mix(in srgb, var(--violet) 80%, #0a0a0a);
    --btn-border: color-mix(in srgb, var(--violet-light) 75%, transparent);
    --btn-fg: #ffffff;
}

@media (prefers-color-scheme: light) {
    :root {
        --btn-bg: #ede9fe;
        --btn-bg-hover: #ddd6fe;
        --btn-border: #7c3aed;
        --btn-fg: #4c1d95;
    }
}

.icon-btn { background: var(--btn-bg); border-color: var(--btn-border); color: var(--btn-fg); }
.icon-btn:hover:not(:disabled) { background: var(--btn-bg-hover); border-color: #fff; }
.icon-btn:disabled { opacity: 0.45; }
.icon-btn[aria-checked="true"] { color: #fff; background: color-mix(in srgb, var(--cyan) 62%, #0a0a0a); border-color: var(--cyan-light); }

.action-btn {
    background: color-mix(in srgb, var(--violet-strong) 74%, transparent);
    border: 1px solid #c4b5fd;
    color: #fff;
    box-shadow: 0 0 1em rgba(124, 58, 237, 0.35);
}
.action-btn:hover { background: color-mix(in srgb, var(--violet) 90%, transparent); border-color: #fff; }
.action-btn svg { color: #fff; }
.action-btn:focus-visible, .mini-btn:focus-visible, .mode-btn:focus-visible, .switch-row:focus-visible, .link-card:focus-visible, .boost-btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
    box-shadow: 0 0 0 5px rgba(139, 92, 246, 0.6);
}

.mini-btn {
    background: color-mix(in srgb, var(--accent) 62%, #0a0a0a);
    border: 1px solid color-mix(in srgb, var(--accent) 70%, #fff);
    color: #fff;
}
.mini-btn.violet { --accent: var(--violet-strong); }
.mini-btn.cyan { --accent: #0891b2; }
.mini-btn.orange { --accent: #c2410c; }
.mini-btn:hover { background: color-mix(in srgb, var(--accent) 85%, #fff 5%); border-color: #fff; }

.mode-btn { background: rgba(255, 255, 255, 0.13); border: 1px solid rgba(255, 255, 255, 0.38); color: #fff; }
.mode-btn:hover { background: rgba(255, 255, 255, 0.22); border-color: rgba(255, 255, 255, 0.7); }
.mode-btn[aria-checked="true"] { background: color-mix(in srgb, var(--violet-strong) 80%, transparent); border: 2px solid #e9e3ff; box-shadow: 0 0 1.2em rgba(139, 92, 246, 0.55); }
.mode-btn[data-mode="singularity"][aria-checked="true"] { background: color-mix(in srgb, #0891b2 80%, transparent); border-color: #cffafe; box-shadow: 0 0 1.2em rgba(6, 182, 212, 0.5); }
.mode-btn[data-mode="corner"][aria-checked="true"] { background: color-mix(in srgb, #c2410c 82%, transparent); border-color: #ffedd5; box-shadow: 0 0 1.2em rgba(249, 115, 22, 0.45); }
.mode-btn[data-mode="boost"][aria-checked="true"] { background: color-mix(in srgb, #be185d 78%, transparent); border-color: #fce7f3; box-shadow: 0 0 1.2em rgba(236, 72, 153, 0.45); }
.modes { grid-auto-flow: column; grid-auto-columns: 1fr; grid-template-columns: none; }

.stats > div { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.22); }
.stats dt { color: #ddd8f5; }

/* ---------- Boost mode HUD ---------- */
.hud-center { display: flex; flex-direction: column; align-items: center; gap: 0.35em; }
.energy .meter-fill { background: linear-gradient(90deg, #0891b2, #67e8f9); box-shadow: 0 0 0.8em rgba(34, 211, 238, 0.7); transition: width 0.08s linear; }
.energy .meter { border-color: rgba(103, 232, 249, 0.4); transition: box-shadow 0.15s, border-color 0.15s; }
.energy.ready .meter { border-color: #67e8f9; box-shadow: 0 0 0.9em rgba(103, 232, 249, 0.6); }
.energy.boosting .meter-fill { background: linear-gradient(90deg, #67e8f9, #fff); }
.energy.cooling .meter-fill { background: linear-gradient(90deg, #c2410c, #fb923c); box-shadow: 0 0 0.8em rgba(249, 115, 22, 0.7); }
.ready-dot { display: inline-block; width: 0.6em; height: 0.6em; margin: 0 0.15em 0 0.3em; border-radius: 50%; background: rgba(255, 255, 255, 0.3); vertical-align: baseline; }
.energy.ready .ready-dot { background: #67e8f9; box-shadow: 0 0 0.7em #67e8f9; }
.energy.cooling .ready-dot { background: #fb923c; }
#readyText { opacity: 0.55; }
.energy.ready #readyText, .energy.boosting #readyText { opacity: 1; color: #a5f3fc; }

.boost-btn {
    position: absolute;
    z-index: 4;
    right: 1.2em;
    bottom: 1.2em;
    width: 5.2em;
    height: 5.2em;
    border-radius: 50%;
    border: 2px solid #e9e3ff;
    background: color-mix(in srgb, var(--violet-strong) 78%, transparent);
    color: #fff;
    font: inherit;
    font-weight: 700;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    cursor: pointer;
    box-shadow: 0 0 1.4em rgba(139, 92, 246, 0.55);
}
.boost-btn.on { background: #0891b2; border-color: #fff; box-shadow: 0 0 1.8em rgba(34, 211, 238, 0.8); }
.boost-btn:disabled { opacity: 0.5; }

/* Boost is keyboard-only on desktop: the round button is for touch screens. */
html:not(.touch) .boost-btn { display: none !important; }

/* ---------- Header: breadcrumb brand + one glass tool pill (g2806.net navbar look) ---------- */
:root {
    --pill-bg: rgba(12, 10, 26, 0.55);
    --pill-border: rgba(255, 255, 255, 0.14);
    --pill-sep: rgba(255, 255, 255, 0.12);
    --pill-fg: #e8e6f5;
    --pill-fg-hover: #ffffff;
    --pill-hover: rgba(255, 255, 255, 0.1);
    --pill-press: rgba(255, 255, 255, 0.04);
}

@media (prefers-color-scheme: light) {
    :root {
        --pill-bg: rgba(255, 255, 255, 0.72);
        --pill-border: rgba(15, 23, 42, 0.16);
        --pill-sep: rgba(15, 23, 42, 0.12);
        --pill-fg: #334155;
        --pill-fg-hover: #4c1d95;
        --pill-hover: rgba(124, 58, 237, 0.1);
        --pill-press: rgba(124, 58, 237, 0.2);
    }
}

.header { justify-content: space-between; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; }
.app-icon { width: 38px; height: 38px; border-radius: 11px; }
.header-text { flex: 1 1 auto; min-width: 0; }
.header h1 { display: flex; align-items: baseline; gap: 0.4em; margin: 0; font-size: 15px; font-weight: 700; white-space: nowrap; }
.crumb-brand { flex: none; }
.crumb-sep { flex: none; color: var(--muted); font-weight: 500; }
.crumb-mode { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--violet-light); font-weight: 600; }
.tagline { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }

.tool-pill {
    display: flex;
    align-items: stretch;
    flex: none;
    height: 36px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--pill-bg);
    border: 1px solid var(--pill-border);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    backdrop-filter: blur(14px) saturate(1.3);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 6px 18px rgba(0, 0, 0, 0.22);
}

.tool-pill .icon-btn {
    position: relative;
    width: 38px;
    height: auto;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--pill-fg);
    box-shadow: none;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.tool-pill .icon-btn + .icon-btn { border-left: 1px solid var(--pill-sep); }
.tool-pill .icon-btn svg { width: 18px; height: 18px; }

/* small accent underline that grows on hover/active/on */
.tool-pill .icon-btn::after {
    content: '';
    position: absolute;
    left: 28%;
    right: 28%;
    bottom: 4px;
    height: 2px;
    border-radius: 2px;
    background: var(--violet);
    box-shadow: 0 0 8px var(--violet);
    opacity: 0;
    transform: scaleX(0.3);
    transition: opacity 0.2s, transform 0.25s;
}

.tool-pill .icon-btn:hover:not(:disabled) { background: var(--pill-hover); color: var(--pill-fg-hover); box-shadow: inset 0 0 16px rgba(139, 92, 246, 0.28); border-color: var(--pill-sep); }
.tool-pill .icon-btn:hover:not(:disabled)::after { opacity: 1; transform: scaleX(1); }
.tool-pill .icon-btn:active:not(:disabled) { background: var(--pill-press); }
.tool-pill .icon-btn:disabled { opacity: 0.4; }
.tool-pill .icon-btn[aria-checked="true"] { background: transparent; color: var(--cyan-light); }
.tool-pill .icon-btn[aria-checked="true"]::after { opacity: 1; transform: scaleX(1); background: var(--cyan-light); box-shadow: 0 0 8px var(--cyan); }
.tool-pill .icon-btn[aria-checked="true"]:hover:not(:disabled) { color: var(--cyan-light); }
.tool-pill .icon-btn:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--violet-light); background: var(--pill-hover); }

.tab-mode .header { padding: 0 14px; background: color-mix(in srgb, var(--background) 70%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.tab-mode .tagline { display: none; }
.tab-mode .header h1 { font-size: 16px; }
.tab-mode .tool-pill { height: 38px; }
.tab-mode .tool-pill .icon-btn { width: 42px; }

.is-fs .header {
    --pill-bg: rgba(12, 10, 26, 0.55); --pill-border: rgba(255, 255, 255, 0.14); --pill-sep: rgba(255, 255, 255, 0.12);
    --pill-fg: #e8e6f5; --pill-fg-hover: #ffffff; --pill-hover: rgba(255, 255, 255, 0.1); --pill-press: rgba(255, 255, 255, 0.04);
}

/* ---------- Main menu: a little more glass (still >= 4.5:1 text contrast) ---------- */
.action-btn {
    background: color-mix(in srgb, var(--violet-strong) 55%, transparent);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow: 0 0 1em rgba(124, 58, 237, 0.28);
}
.action-btn:hover { background: color-mix(in srgb, var(--violet) 74%, transparent); }

.mode-btn { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.3); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.mode-btn:hover { background: rgba(255, 255, 255, 0.16); }
.mode-btn[aria-checked="true"] { background: color-mix(in srgb, var(--violet-strong) 58%, transparent); }
.mode-btn[data-mode="singularity"][aria-checked="true"] { background: color-mix(in srgb, #0891b2 58%, transparent); }
.mode-btn[data-mode="corner"][aria-checked="true"] { background: color-mix(in srgb, #c2410c 60%, transparent); }
.mode-btn[data-mode="boost"][aria-checked="true"] { background: color-mix(in srgb, #be185d 58%, transparent); }

.stats > div { background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.2); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }

.mode-chip.win { border-color: #fde68a; background: rgba(251, 191, 36, 0.2); color: #fef3c7 !important; }

/* ---------- Settings & extras dialog (glass card, accent line, sections) ---------- */
.modal {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.7em;
    background: rgba(4, 3, 11, 0.62);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    color: #f0f0f0;
    animation: modal-in 0.2s ease-out both;
}
.modal.closing { animation: modal-out 0.17s ease-in both; }

.modal-card {
    position: relative;
    width: 100%;
    max-width: 26em;
    max-height: 100%;
    overflow: auto;
    padding: 0.85em 1em 0.75em;
    border-radius: 1.15em;
    background: rgba(16, 11, 36, 0.8);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    backdrop-filter: blur(18px) saturate(1.4);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 40px rgba(124, 58, 237, 0.18);
    animation: card-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.modal.closing .modal-card { animation: card-out 0.17s ease-in both; }

.modal-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--violet) 25%, var(--cyan) 75%, transparent);
}

@keyframes modal-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes card-in { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes card-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(6px) scale(0.98); } }

.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6em; }
.modal-head h2 { margin: 0; font-size: 1.2em; font-weight: 700; letter-spacing: -0.01em; text-align: left; }

.x-btn {
    flex: none;
    width: 2.1em;
    height: 2.1em;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.07);
    color: #e8e6f5;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.2s;
}
.x-btn svg { width: 1.05em; height: 1.05em; }
.x-btn:hover { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.5); color: #fff; transform: rotate(90deg); }
.x-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 5px rgba(139, 92, 246, 0.6); }

.sec-title { margin: 0.75em 0 0.35em; font-size: 0.7em; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: #a8a3c8; }

.switch-row {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8em;
    width: 100%;
    margin: 0 0 0.4em;
    padding: 0.55em 0.8em 0.55em 0.9em;
    border-radius: 0.9em;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: #f0f0f0;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.25s, background 0.25s;
}
.switch-row::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 1px; background: var(--violet); opacity: 0; transition: opacity 0.25s; }
.switch-row:hover { background: rgba(255, 255, 255, 0.09); border-color: rgba(255, 255, 255, 0.28); }
.switch-row:hover::before, .switch-row[aria-checked="true"]::before { opacity: 0.9; }
.switch-row[aria-checked="true"]::before { background: var(--cyan-light); }
.switch-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.switch-text strong { font-size: 1em; font-weight: 700; }
.switch-text small { font-size: 0.82em; font-weight: 500; color: #b9b4d6; }
.switch { flex: none; position: relative; width: 2.6em; height: 1.45em; border-radius: 999px; background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.4); transition: background 0.2s, border-color 0.2s; }
.switch i { position: absolute; top: 50%; left: 0.2em; width: 1em; height: 1em; margin-top: -0.5em; border-radius: 50%; background: #fff; transition: transform 0.2s; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4); }
.switch-row[aria-checked="true"] .switch { background: #0891b2; border-color: #a5f3fc; }
.switch-row[aria-checked="true"] .switch i { transform: translateX(1.15em); }
.switch-row:focus-visible { outline: 2px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 5px rgba(139, 92, 246, 0.55); }

.modal-sec[aria-labelledby="secCommunity"] { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5em; }
.modal-sec[aria-labelledby="secCommunity"] .sec-title { grid-column: 1 / -1; margin-bottom: 0; }

.link-card {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4em;
    padding: 0.55em 0.7em 0.55em 0.85em;
    border-radius: 0.95em;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #f0f0f0;
    text-decoration: none;
    transition: border-color 0.25s, background 0.25s;
}
.link-card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 1px; background: var(--accent); opacity: 0.9; }
.link-card.secondary { --accent: var(--cyan); }
.link-card.orange { --accent: var(--orange); }
.link-card:hover { background: rgba(255, 255, 255, 0.09); border-color: rgba(255, 255, 255, 0.3); }
.link-card .label { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.link-card .label strong { font-size: 0.98em; font-weight: 700; white-space: nowrap; }
.link-card .label small { font-size: 0.8em; color: #b9b4d6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-card svg { flex: none; width: 1.15em; height: 1.15em; color: #b9b4d6; transition: transform 0.3s, color 0.3s; }
.link-card:hover svg { transform: translateX(3px); color: var(--accent); }
.link-card:focus-visible { outline: 2px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 5px rgba(139, 92, 246, 0.55); }

.modal-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 0.7em; padding-top: 0.55em; border-top: 1px solid rgba(255, 255, 255, 0.08); font-size: 0.78em; color: #a8a3c8; }
.modal-foot a { color: inherit; text-decoration: none; transition: color 0.2s; }
.modal-foot a:hover { color: #fff; }
.modal-foot a:focus-visible { outline: 2px solid var(--violet-light); outline-offset: 2px; border-radius: 4px; }

.tab-mode .modal-card { max-width: 26.5em; }

/* ---------- Boost escape meter ---------- */
.escape .meter { border-color: rgba(221, 214, 254, 0.5); }
.escape .meter-fill { background: linear-gradient(90deg, #a78bfa, #fff); box-shadow: 0 0 0.8em rgba(221, 214, 254, 0.8); }
