/*
  Direction (playful, not a cartoon; every decision has a reason):
  - Shape language: soft and round. Pills for controls, big 22-32px corners for panels and photos, a circle for
    avatars and number badges. Reason: round shapes read as friendly and alive, which is what the owner asked for.
  - Lines: thick near-black outlines (3-4px) on everything that is a "thing" (cards, buttons, photos, canvases),
    plus a small hard offset shadow with no blur on buttons and key cards. Reason: the outline is the one strong,
    consistent graphic idea; blur and glass would soften it away.
  - Colour: warm white paper, near-black ink, and a bright set of fills (sun yellow, electric blue, coral, mint,
    sky, violet). Each section owns one colour so the page is colourful without being noisy. Not pastel, not formal.
    Ink is the --navy variable (the hidden themes override it), sun yellow stays the primary accent.
  - Type: Bricolage Grotesque for titles (heavy, slightly quirky, no outlines or tricks on the letters), Nunito
    for reading (rounded, friendly). Mono only inside the command line.
  - Motion: things bounce, wobble and drift (back-out easing, floating blobs, a scrolling ticker). The 3D slab
    cards, the tunnel intro and the scroll reveals are kept; only their skin changed.
  - Compatibility: variable names (--bg, --fg, --navy, --yellow, --card-*, --band-*, --tile-*...) are unchanged so
    the hidden themes (skins.css, f1.css) and the canvas games keep working.
*/
:root {
    --paper: #FFF9ED;
    --paper-2: #FFEFC9;
    --navy: #12111A;
    --navy-2: #2A2840;
    --blue: #3E7BFF;
    --yellow: #FFD23F;
    --coral: #FF6B57;
    --mint: #3FDC9B;
    --sky: #7CD3FF;
    --violet: #9B7BFF;
    --orange: #FF9A3D;
    --pink: #FF7AAE;
    --lime: #C6F25C;

    --ink: var(--navy);
    --bg: var(--paper);
    --fg: var(--navy);
    --muted: #5C5878;
    --surface: #FFFFFF;
    --edge: #CFC8E8;
    --focus: #E8402B;
    --dots: rgba(18, 17, 26, 0.08);

    --card-bg: #FFFFFF;
    --card-fg: var(--navy);
    --card-muted: #5C5878;
    --card-edge: #CFC8E8;
    --card-focus: #E8402B;
    --card-border: var(--ink);

    --band-bg: #8FD8FF;
    --band-fg: var(--navy);
    --band-muted: #1F4966;
    --band-edge: var(--ink);
    --band-surface: #FFFFFF;
    --band-focus: #E8402B;
    --board: #FFFFFF;
    --plate-a: var(--ink); --plate-b: var(--ink);
    --overlay: rgba(255, 249, 237, 0.94); --overlay-solid: #FFF9ED;
    --tile-up: #7CD3FF; --tile-up-edge: #1B86C9; --tile-up-hover: #A2E0FF; --tile-line: rgba(18, 17, 26, 0.28); --tile-open: #FFF9ED;
    --sea-a: #8FDBFF; --sea-b: #3FA4EC; --sea-line: rgba(18, 17, 26, 0.18); --sea-hull: #5C5878; --sea-hull-2: #9D98C2; --sea-deck: #FFF9ED;
    --sea-hit: #FF5A45; --sea-fire: #FFD23F; --sea-miss: #FFFFFF; --sea-sunk: #3A364F; --sea-aim: #FFD23F;
    --cell-1: #2457D6; --cell-2: #0F8A5A; --cell-3: #D93A3A; --cell-4: #7A44D6; --cell-5: #B85F00;

    --line: 3px solid var(--ink);
    --pop: 4px 4px 0 var(--ink);
    --pop-lg: 7px 7px 0 var(--ink);
    --r-s: 14px; --r-m: 22px; --r-l: 32px; --pill: 999px;

    --display: 'Bricolage Grotesque', 'Arial Rounded MT Bold', system-ui, sans-serif;
    --text: 'Nunito', 'Trebuchet MS', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    --wrap: 1180px;
    --gutter: clamp(1rem, 4vw, 2.5rem);
    --topbar: 68px;
    --bounce: cubic-bezier(.34, 1.56, .64, 1);
}

:root[data-theme="dark"] {
    --ink: #000000;
    --bg: #16151F;
    --fg: #FFF9ED;
    --muted: #C4C0DE;
    --surface: #25233A;
    --edge: #4A4770;
    --focus: var(--yellow);
    --dots: rgba(255, 255, 255, 0.06);

    --card-bg: #2D2B47;
    --card-fg: #FFF9ED;
    --card-muted: #D2CEEA;
    --card-edge: #5A5788;
    --card-focus: var(--yellow);
    --card-border: var(--ink);

    --band-bg: #1F5E86;
    --band-fg: #FFF9ED;
    --band-muted: #CFE7F5;
    --band-edge: var(--ink);
    --band-surface: #16151F;
    --band-focus: var(--yellow);
    --board: #25233A;
    --overlay: rgba(22, 21, 31, 0.94); --overlay-solid: #16151F;
    --tile-up: #4F9BFF; --tile-up-edge: #1B4FA8; --tile-up-hover: #6EB0FF; --tile-line: rgba(255, 255, 255, 0.2); --tile-open: #16151F;
    --sea-a: #2A6AD0; --sea-b: #12347A; --sea-line: rgba(255, 255, 255, 0.14); --sea-hull: #8E8AB8; --sea-hull-2: #D2CEEA; --sea-deck: #25233A;
    --sea-sunk: #47435F; --sea-miss: #D8EAFF;
    --cell-1: #8FB8FF; --cell-2: #6EE7B7; --cell-3: #FF9AA8; --cell-4: #C9B3FF; --cell-5: #FFD23F;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--topbar) + 12px);
    -webkit-text-size-adjust: 100%;
    color-scheme: light;
}
html[data-theme="dark"] { color-scheme: dark; }

body {
    margin: 0;
    background-color: var(--bg);
    background-image: radial-gradient(circle at 1px 1px, var(--dots) 1.6px, transparent 1.9px);
    background-size: 24px 24px;
    color: var(--fg);
    font: 600 1.0625rem/1.6 var(--text);
    overflow-wrap: break-word;
}
::selection { background: var(--yellow); color: var(--navy); }

h1, h2, h3, p, ul, figure { margin: 0; }
ul { padding: 0; list-style: none; }
img, canvas { max-width: 100%; }
a { color: inherit; text-decoration-thickness: 3px; text-underline-offset: 0.2em; text-decoration-color: var(--coral); }

:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; border-radius: 10px; }

.skip-link {
    position: absolute; left: var(--gutter); top: -100px; z-index: 100;
    background: var(--yellow); color: var(--navy); padding: 0.7rem 1.2rem; font-weight: 800;
    border: var(--line); border-radius: var(--pill); box-shadow: var(--pop);
}
.skip-link:focus { top: 10px; outline-color: var(--navy); }

.anchor-top { position: absolute; top: 0; }

/* Top bar */
.topbar {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; justify-content: space-between;
    min-height: var(--topbar);
    padding: 0 var(--gutter);
    background: var(--bg);
    border: 4px solid var(--ink); border-top: 0; border-radius: 0 0 30px 30px;
}
.brand { display: inline-flex; align-items: center; gap: 0.7rem; text-decoration: none; font: 800 1.4rem/1 var(--display); letter-spacing: -0.02em; min-height: 44px; }
.brand img { border-radius: 50%; display: block; border: var(--line); background: #fff; transition: transform 0.5s var(--bounce); }
.brand:hover img { transform: rotate(-16deg) scale(1.14); }

.menu-toggle {
    min-height: 46px; padding: 0 1.2rem;
    font: 800 1rem var(--text); color: var(--ink);
    background: var(--yellow); border: var(--line); border-radius: var(--pill); box-shadow: 3px 3px 0 var(--ink); cursor: pointer;
}
.menu-toggle[aria-expanded="true"] { background: var(--coral); transform: translate(3px, 3px); box-shadow: none; }

.site-menu {
    display: none;
    position: absolute; left: 0; right: 0; top: 100%;
    flex-direction: column; gap: 1rem;
    padding: 0.75rem var(--gutter) 1.25rem;
    background: var(--bg);
    border: 4px solid var(--ink); border-top: 0; border-radius: 0 0 30px 30px;
}
.site-menu.open { display: flex; }

.site-nav { display: flex; flex-direction: column; gap: 0.4rem; }
.site-nav a {
    display: flex; align-items: center; min-height: 48px; padding: 0 1.2rem;
    text-decoration: none; font: 800 1.15rem var(--display);
    border: 3px solid transparent; border-radius: var(--pill);
    transition: transform 0.2s var(--bounce);
}
.site-nav a[aria-current="true"] { background: var(--yellow); color: var(--navy); border-color: var(--ink); box-shadow: 3px 3px 0 var(--ink); }

.tools { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.lang-switch { display: inline-flex; border: var(--line); border-radius: var(--pill); overflow: hidden; background: var(--surface); box-shadow: 3px 3px 0 var(--ink); }
.lang-switch button {
    min-width: 48px; min-height: 44px; padding: 0 0.7rem;
    font: 800 0.95rem var(--text); color: var(--fg); background: transparent; border: 0; cursor: pointer;
}
.lang-switch button + button { border-left: 3px solid var(--ink); }
.lang-switch button[aria-pressed="true"] { background: var(--blue); color: var(--navy); }
.lang-switch button:focus-visible { outline-offset: -6px; }

.tool-btn {
    min-height: 44px; padding: 0 1rem;
    font: 800 0.95rem var(--text); color: var(--fg);
    background: var(--surface); border: var(--line); border-radius: var(--pill); box-shadow: 3px 3px 0 var(--ink); cursor: pointer;
    transition: transform 0.2s var(--bounce), box-shadow 0.2s;
}
.tool-btn:hover { transform: translate(-1px, -3px) rotate(-1.5deg); box-shadow: 5px 6px 0 var(--ink); }
.tool-btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
/* Round icon button (sound effects on/off) */
.icon-btn { width: 44px; padding: 0; display: inline-grid; place-items: center; border-radius: 50%; }
.icon-btn .slash { display: none; }
.icon-btn.off .slash { display: block; }
.icon-btn.off .waves { opacity: 0.35; }
.music-tool { display: inline-flex; align-items: center; gap: 0.6rem; }
.music-tool input[type="range"] { width: 96px; accent-color: var(--coral); min-height: 44px; }

/* Layout helpers */
.hero, .gallery, .games-inner, .desk { width: 100%; max-width: calc(var(--wrap) + var(--gutter) * 2); margin-inline: auto; padding-inline: var(--gutter); }

/* Round number badges, a different colour per section */
.no {
    display: inline-grid; place-items: center;
    min-width: 3rem; height: 3rem; padding: 0 0.5rem;
    background: var(--yellow); color: var(--navy);
    font: 800 1.2rem/1 var(--display);
    border: var(--line); border-radius: 50%; box-shadow: 3px 3px 0 var(--ink);
    transition: transform 0.5s var(--bounce);
}
.no:hover { transform: rotate(360deg); }
.live-card .no, .no.n2 { background: var(--coral); color: var(--navy); }
.gallery .no, .no.n3 { background: var(--blue); color: var(--navy); }
.games .no, .no.n1 { background: var(--yellow); }
.desk .no, .no.n4 { background: var(--mint); }
.guestbook .no { background: var(--violet); color: var(--navy); }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 50px; padding: 0 1.5rem;
    font: 800 1.02rem var(--text);
    border: var(--line); border-radius: var(--pill); cursor: pointer;
    background: var(--surface); color: var(--fg); box-shadow: var(--pop);
    transition: transform 0.2s var(--bounce), box-shadow 0.2s, background 0.2s;
}
.btn:hover { transform: translate(-2px, -3px) rotate(-1deg); box-shadow: 6px 7px 0 var(--ink); }
.btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
.btn-accent { background: var(--yellow); color: var(--navy); }
.btn-accent:hover { background: #FFE070; }
.btn-ghost { background: var(--surface); }
.btn[aria-pressed="true"] { background: var(--blue); color: var(--navy); transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }

/* Hero */
.hero {
    display: grid; gap: 2.5rem;
    padding-top: clamp(2.2rem, 6vw, 4.5rem);
    padding-bottom: clamp(3rem, 6vw, 4.5rem);
    position: relative;
}
.hero-copy { min-width: 0; }

.hero h1 {
    font: 800 clamp(3.6rem, 17vw, 10rem)/0.88 var(--display);
    letter-spacing: -0.045em; font-variation-settings: 'opsz' 96;
    margin-left: -0.04em;
    text-shadow: 0.04em 0.05em 0 var(--yellow);
    animation: rise 0.7s cubic-bezier(.2,.7,.2,1) both;
}
.handle {
    margin-top: 1.3rem; display: inline-block;
    padding: 0.3rem 1.2rem 0.4rem;
    font: 800 clamp(1.2rem, 3vw, 1.5rem) var(--display); letter-spacing: -0.01em; color: var(--navy);
    background: var(--coral); border: var(--line); border-radius: var(--pill); box-shadow: var(--pop);
    transform: rotate(-2deg);
    transition: transform 0.4s var(--bounce);
}
.handle:hover { transform: rotate(3deg) scale(1.06); }
.lede { margin-top: 1.7rem; max-width: 34ch; font-size: clamp(1.15rem, 2.4vw, 1.4rem); font-weight: 700; line-height: 1.45; }
.where { margin-top: 1.4rem; display: flex; flex-wrap: wrap; gap: 0.5rem; font-weight: 800; }
.where > span:not(.sep) {
    padding: 0.2rem 0.95rem; background: var(--mint); color: var(--navy);
    border: 3px solid var(--ink); border-radius: var(--pill); font-size: 0.95rem;
}
.where > #local-time { background: var(--sky); }
.sep { display: none; }

.mini-title { margin-top: 2.2rem; font: 800 1.2rem var(--display); letter-spacing: -0.01em; color: var(--fg); }
.links { margin-top: 0.9rem; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem; }
.links a, .links .soon {
    display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
    min-height: 58px; padding: 0 1.2rem;
    font: 800 1.2rem var(--display); letter-spacing: -0.01em; text-decoration: none; color: var(--navy);
    background: var(--yellow); border: var(--line); border-radius: var(--pill); box-shadow: var(--pop);
    transition: transform 0.2s var(--bounce), box-shadow 0.2s;
}
.links li:nth-child(2) a { background: var(--coral); color: var(--navy); }
.links li:nth-child(3) a { background: var(--blue); color: var(--navy); }
.links li:nth-child(4) a { background: var(--mint); }
.links a:hover { transform: translate(-2px, -4px) rotate(-1.5deg); box-shadow: 6px 8px 0 var(--ink); }
.links a:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
.links .soon { background: var(--surface); color: var(--muted); border-style: dashed; box-shadow: none; }
.links .soon small { font: 800 0.85rem var(--text); }

/* Soft blobs drifting behind the hero */
.hero::before, .hero::after {
    content: ""; position: absolute; z-index: -1; pointer-events: none; border: 4px solid var(--ink);
    animation: morph 11s ease-in-out infinite, float 7s ease-in-out infinite;
}
.hero::before { width: clamp(150px, 24vw, 300px); aspect-ratio: 1; right: 1%; top: 2%; background: var(--sky); }
.hero::after { width: clamp(90px, 12vw, 150px); aspect-ratio: 1; right: 3%; bottom: 7%; background: var(--lime); animation-duration: 9s, 6s; animation-delay: -3s; }
@keyframes morph {
    0%, 100% { border-radius: 58% 42% 55% 45% / 50% 58% 42% 50%; }
    50% { border-radius: 42% 58% 45% 55% / 58% 44% 56% 42%; }
}
@keyframes float { 0%, 100% { translate: 0 0; rotate: 0deg; } 50% { translate: 0 -16px; rotate: 8deg; } }

/* Live card: the focal block */
.live-card {
    --focus: var(--card-focus);
    background: var(--card-bg); color: var(--card-fg);
    border-radius: var(--r-l);
    border: 4px solid var(--card-border);
    padding: 1.5rem;
    display: flex; flex-direction: column; gap: 1.25rem;
    min-width: 0;
}
.live-card h2 { display: flex; align-items: center; gap: 0.8rem; font: 800 1.7rem/1 var(--display); letter-spacing: -0.025em; }
.live-row { display: flex; gap: 1rem; align-items: center; }
.avatar { width: 92px; height: 92px; border-radius: 50%; object-fit: cover; background: var(--yellow); flex: none; border: 4px solid var(--ink); }
.live-text { min-width: 0; }
.presence { display: flex; align-items: center; gap: 0.55rem; font-size: 1.2rem; font-weight: 800; }
.activity { margin-top: 0.3rem; color: var(--card-muted); overflow-wrap: anywhere; font-weight: 700; }

.status-dot { width: 18px; height: 18px; flex: none; border-radius: 50%; background: #9A94C2; border: 3px solid var(--ink); }
.status-dot[data-status="online"] { background: var(--mint); }
.status-dot[data-status="idle"] { background: var(--yellow); border-radius: 50% 50% 50% 0; }
.status-dot[data-status="dnd"] { background: var(--coral); border-radius: 5px; }
.status-dot[data-status="offline"] { background: transparent; }

.card-btn {
    align-self: flex-start;
    min-height: 44px; padding: 0 1.2rem;
    font: 800 0.95rem var(--text); color: var(--navy);
    background: var(--yellow); border: var(--line); border-radius: var(--pill); box-shadow: 3px 3px 0 var(--ink); cursor: pointer;
    transition: transform 0.2s var(--bounce), box-shadow 0.2s;
}
.card-btn:hover { transform: translate(-1px, -3px) rotate(-2deg); box-shadow: 5px 6px 0 var(--ink); }
.card-btn:active { transform: translate(3px, 3px); box-shadow: none; }

.weather { border-top: 3px dashed var(--card-edge); padding-top: 1.1rem; display: flex; flex-direction: column; gap: 0.35rem; }
.weather h3 { font: 800 1rem var(--display); letter-spacing: -0.01em; color: var(--card-muted); }
.weather-main { font: 800 2rem/1.15 var(--display); letter-spacing: -0.03em; }
.weather-sub { color: var(--card-muted); font-weight: 700; }
.weather .card-btn { margin-top: 0.6rem; }

/* MacBook battery: streamed live from the owner's Mac (see app.js) */
.battery { border-top: 3px dashed var(--card-edge); padding-top: 1.1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.battery h3 { font: 800 1rem var(--display); letter-spacing: -0.01em; color: var(--card-muted); }
.battery-row { display: flex; align-items: center; gap: 1.1rem; }
.batt { --k: 0; position: relative; flex: none; width: 88px; height: 40px; border: 4px solid var(--ink); border-radius: 13px; background: var(--card-bg); }
.batt::after { content: ""; position: absolute; right: -11px; top: 8px; width: 7px; height: 16px; background: var(--ink); border-radius: 0 5px 5px 0; }
.batt i {
    position: absolute; left: 3px; top: 3px; bottom: 3px; width: calc((100% - 6px) * var(--k)); border-radius: 7px;
    background: var(--mint); transition: width 0.9s var(--bounce), background 0.3s;
}
.battery[data-level="mid"] .batt i { background: var(--yellow); }
.battery[data-level="low"] .batt i { background: var(--coral); }
.batt b { position: absolute; inset: 0; margin: auto; width: 15px; height: 24px; background: var(--ink); clip-path: polygon(58% 0, 12% 56%, 44% 56%, 34% 100%, 88% 38%, 56% 38%); display: none; }
.battery.charging .batt b { display: block; animation: zap 1.2s ease-in-out infinite; }
.battery.charging .batt i { background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.45) 0 9px, transparent 9px 18px); background-size: 26px 26px; animation: charge 0.9s linear infinite; }
@keyframes charge { to { background-position: 26px 0; } }
@keyframes zap { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.25) rotate(-6deg); } }
.batt-pct { font: 800 2.2rem/1 var(--display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.batt-sub { color: var(--card-muted); font-weight: 700; }
.battery.stale { opacity: 0.6; }
@media (prefers-reduced-motion: reduce) { .battery.charging .batt b, .battery.charging .batt i { animation: none; } }

/* Section heads */
.sec-head { display: grid; gap: 1rem; align-items: start; margin-bottom: 2rem; }
.sec-head h2 { font: 800 clamp(2.5rem, 8vw, 4.75rem)/0.95 var(--display); letter-spacing: -0.04em; font-variation-settings: 'opsz' 96; text-shadow: 0.04em 0.05em 0 var(--yellow); }
.sec-head p { color: var(--muted); max-width: 40ch; font-weight: 700; }
.sec-head > .no { justify-self: start; }

/* Ticker between hero and gallery */
.ticker {
    position: relative; margin: 0 -2%; overflow: hidden; transform: rotate(-1.6deg);
    background: var(--coral); color: var(--navy); border-block: 4px solid var(--ink); padding: 0.7rem 0;
    white-space: nowrap; user-select: none;
}
.ticker .track { display: inline-flex; animation: ticker 26s linear infinite; font: 800 1.5rem/1 var(--display); letter-spacing: -0.01em; }
.ticker span { padding-right: 1.6rem; }
.ticker:hover .track { animation-play-state: paused; }
@keyframes ticker { to { transform: translateX(-50%); } }

/* Gallery */
.gallery { padding-top: clamp(3.5rem, 6vw, 5.5rem); padding-bottom: clamp(3.5rem, 7vw, 6rem); position: relative; }
.shots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem; }
.shot { position: relative; border-radius: var(--r-l); background: var(--yellow); border: 4px solid var(--ink); min-width: 0; }
.shot button { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; overflow: hidden; border-radius: 26px; }
.shot button:focus-visible { outline-offset: -8px; }
.shot img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 0.55s var(--bounce); }
.shot:hover img { transform: scale(1.07) rotate(-0.8deg); }
.shot.s0 { grid-column: 1 / -1; aspect-ratio: 4 / 5; rotate: -1deg; background: var(--coral); }
.shot.s1 { grid-column: 1 / -1; aspect-ratio: 16 / 9; rotate: 0.8deg; background: var(--blue); }
.shot.s2, .shot.s3 { aspect-ratio: 3 / 4; }
.shot.s2 { rotate: 1deg; background: var(--mint); }
.shot.s3 { rotate: -0.8deg; background: var(--violet); }
.shot.sx { aspect-ratio: 4 / 3; }

/* Games band: a big rounded panel */
.games {
    position: relative; overflow: clip;
    margin-inline: clamp(0.5rem, 2vw, 1.6rem);
    background-color: var(--band-bg);
    background-image: radial-gradient(circle at 1px 1px, rgba(18, 17, 26, 0.16) 2.2px, transparent 2.6px);
    background-size: 26px 26px;
    color: var(--band-fg); padding-block: clamp(3.5rem, 8vw, 6.5rem); --focus: var(--band-focus);
    border: 4px solid var(--ink); border-radius: clamp(28px, 5vw, 56px);
}
:root[data-theme="dark"] .games { background-image: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.1) 2.2px, transparent 2.6px); }
.games .sec-head p { color: var(--band-muted); }
.sec-head-split > div { display: grid; gap: 1rem; justify-items: start; }

.tabs { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-bottom: 1.6rem; }
.tabs [role="tab"] { touch-action: manipulation; }
.tabs [role="tab"] {
    min-height: 50px; padding: 0 1.5rem;
    font: 800 1.05rem var(--display); letter-spacing: -0.01em; color: var(--ink);
    background: var(--band-surface); border: var(--line); border-radius: var(--pill); box-shadow: var(--pop); cursor: pointer;
    transition: transform 0.2s var(--bounce), box-shadow 0.2s;
}
:root[data-theme="dark"] .tabs [role="tab"] { color: var(--fg); }
.tabs [role="tab"]:hover { transform: translate(-1px, -3px) rotate(-1.5deg); box-shadow: 5px 7px 0 var(--ink); }
.tabs [role="tab"][aria-selected="true"] { background: var(--yellow); color: var(--navy); transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
:root[data-theme="dark"] .tabs [role="tab"][aria-selected="true"] { color: var(--navy); }

.panel { display: grid; gap: 1.6rem; }
/* One column that may shrink below the board's width, so a wide board scrolls inside its frame instead of spilling off the screen */
.panel-mines { grid-template-columns: minmax(0, 1fr); }
.stage { position: relative; min-width: 0; width: 100%; max-width: 440px; }
.stage-wide { max-width: 640px; }
.stage canvas { display: block; width: 100%; max-width: 440px; aspect-ratio: 1; height: auto; border-radius: var(--r-l); background: var(--board); border: 4px solid var(--ink); touch-action: pan-y; }
.stage-wide canvas { max-width: 640px; aspect-ratio: 560 / 320; }
canvas.capturing { touch-action: none; }
.side { display: flex; flex-direction: column; gap: 1.1rem; align-items: flex-start; min-width: 0; }
.game-msg { min-height: 1.6em; color: var(--band-fg); font-weight: 800; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 0.7rem; }
.hint { color: var(--band-muted); max-width: 46ch; font-weight: 700; }
.games .slab { --p1: var(--plate-a); --p2: var(--plate-b); }

/* Score tiles */
.stats { display: flex; flex-wrap: wrap; gap: 0.8rem; }
.stat {
    display: flex; flex-direction: column; gap: 0.1rem; min-width: 96px; margin: 0; --d: 6px;
    padding: 0.55rem 1.1rem 0.7rem; background: var(--band-surface); border: var(--line); border-radius: var(--r-m);
}
.stat span { font: 800 0.78rem var(--text); color: var(--band-muted); letter-spacing: 0.05em; text-transform: uppercase; }
.stat strong { font: 800 2.1rem/1 var(--display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--band-fg); }
.stat.bump strong { animation: bump 0.45s var(--bounce); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.5) rotate(-6deg); color: var(--coral); } 100% { transform: scale(1); } }

/* In-board messages: the whole overlay is one big button */
.overlay {
    position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.8rem;
    padding: 1rem; border: 0; border-radius: var(--r-l); background: var(--overlay); color: var(--band-fg);
    text-align: center; cursor: pointer; font: inherit; transform: translateZ(2px);
    animation: ov-in 0.45s var(--bounce) both;
}
.overlay:focus-visible { outline-offset: -8px; }
.ov-title { font: 800 clamp(2.2rem, 6.5vw, 3.3rem)/1 var(--display); letter-spacing: -0.04em; text-shadow: 0.04em 0.05em 0 var(--yellow); }
.ov-sub { max-width: 24ch; color: var(--band-fg); font-weight: 800; line-height: 1.35; }
.ov-cta { pointer-events: none; margin-top: 0.3rem; }
.overlay:hover .ov-cta { transform: translate(-2px, -3px) rotate(-2deg); box-shadow: 6px 7px 0 var(--ink); }
.overlay.banner {
    position: relative; inset: auto; width: 100%; margin-top: 1rem; flex-direction: row; flex-wrap: wrap; justify-content: space-between; gap: 0.6rem 1rem;
    background: var(--tile-open); border: var(--line); box-shadow: var(--pop); border-radius: var(--r-m); text-align: left; transform: none;
    animation: banner-in 0.45s var(--bounce) both;
}
.overlay.banner .ov-title { font-size: 1.7rem; }
.overlay.banner .ov-sub { max-width: none; flex: 1 1 8rem; }
.overlay.banner .ov-cta { margin: 0; min-height: 46px; }
@keyframes banner-in { from { opacity: 0; transform: translateY(12px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes ov-in { from { opacity: 0; transform: translateZ(2px) scale(0.88); } to { opacity: 1; transform: translateZ(2px); } }

.shake { animation: shake 0.45s ease; }
@keyframes shake { 0%, 100% { translate: 0 0; } 20% { translate: -7px 2px; } 40% { translate: 6px -2px; } 60% { translate: -4px 1px; } 80% { translate: 3px 0; } }

.dpad { display: grid; grid-template-columns: repeat(3, 60px); gap: 0.55rem; margin-top: 0.25rem; }
.dpad [data-dir="up"] { grid-column: 2; grid-row: 1; }
.dpad [data-dir="left"] { grid-column: 1; grid-row: 2; }
.dpad [data-dir="down"] { grid-column: 2; grid-row: 2; }
.dpad [data-dir="right"] { grid-column: 3; grid-row: 2; }
.dpad button {
    min-width: 60px; min-height: 60px; font-size: 1.2rem; color: var(--ink);
    background: var(--band-surface); border: var(--line); border-radius: 50%; box-shadow: 0 5px 0 var(--ink); cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
}
:root[data-theme="dark"] .dpad button { color: var(--fg); }
.dpad button:active { background: var(--yellow); color: var(--navy); transform: translateY(5px); box-shadow: none; }

/* Player name and the shared record boards */
.player-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.9rem; margin: -0.4rem 0 1.8rem; }
.player-row label { font: 800 1.05rem var(--display); letter-spacing: -0.01em; }
.player-row input {
    min-height: 46px; width: min(100%, 15rem); padding: 0 1.1rem; font: 800 1rem var(--text); color: var(--ink);
    background: var(--band-surface); border: var(--line); border-radius: var(--pill); box-shadow: 3px 3px 0 var(--ink);
}
:root[data-theme="dark"] .player-row input { color: var(--fg); }
.player-row input::placeholder { color: var(--band-muted); }
.player-hint { color: var(--band-muted); font-size: 0.9rem; font-weight: 700; }
.top-board { width: 100%; max-width: 24rem; }
.top-title { font: 800 1.2rem var(--display); letter-spacing: -0.02em; margin-bottom: 0.6rem; }
.top-list { list-style: none; margin: 0; padding: 0; background: var(--band-surface); border: var(--line); border-radius: var(--r-m); box-shadow: var(--pop); overflow: hidden; }
.top-list li {
    display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto; gap: 0.6rem; align-items: center;
    min-height: 42px; padding: 0.25rem 0.9rem; border-bottom: 2px dashed var(--tile-line); font-variant-numeric: tabular-nums;
}
.top-list li:last-child { border-bottom: 0; }
.top-list .top-rank { color: var(--band-muted); font: 800 1.05rem var(--display); }
.top-list .top-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.top-list .top-score { font: 800 1.1rem var(--display); }
.top-list li.me { background: var(--yellow); color: var(--navy); }
.top-list li.me .top-rank { color: var(--navy); }
.top-list li.fresh { animation: top-fresh 0.5s var(--bounce) 3; }
.top-list .top-note { display: block; padding: 0.7rem 0.9rem; color: var(--band-muted); font-weight: 700; }
@keyframes top-fresh { 50% { transform: scale(1.05) rotate(-1deg); } }
@media (prefers-reduced-motion: reduce) { .top-list li.fresh { animation: none; } }

.matrix-fx { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 10000; pointer-events: none; }
.lightbox img { touch-action: pan-y; }

/* Minesweeper */
.mines-top { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; }
.chips { display: inline-flex; border: var(--line); border-radius: var(--pill); overflow: hidden; background: var(--band-surface); box-shadow: var(--pop); }
.chips button { min-height: 46px; padding: 0 1.2rem; font: 800 1rem var(--text); color: var(--band-fg); background: transparent; border: 0; cursor: pointer; }
.chips button + button { border-left: 3px solid var(--ink); }
.chips button[aria-pressed="true"] { background: var(--yellow); color: var(--navy); }
.chips button:focus-visible { outline-offset: -6px; }

/* The board is a precision tool: it stays flat, no tilt, no 3D plates, so the cell under the pointer never moves */
.mine-stage { position: relative; width: fit-content; max-width: 100%; padding: 0.9rem; background: var(--band-surface); border: 4px solid var(--ink); border-radius: var(--r-l); box-shadow: var(--pop-lg); }
.mine-scroll { overflow-x: auto; max-width: 100%; padding: 4px 4px 8px; }
.mine-board { display: grid; gap: 5px; width: max-content; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.cell {
    width: var(--cell); height: var(--cell); padding: 0; display: grid; place-items: center;
    font: 800 calc(var(--cell) * 0.52)/1 var(--display); color: var(--band-fg);
    background: var(--tile-up); border: 3px solid var(--ink); border-radius: 12px; box-shadow: 0 3px 0 var(--ink); cursor: pointer;
    transition: transform 0.15s var(--bounce), background 0.12s;
    touch-action: manipulation;
}
.cell svg { width: 62%; height: 62%; display: block; }
.cell:hover:not(.open) { transform: translateY(-3px) rotate(-3deg); background: var(--tile-up-hover); }
.cell:active:not(.open) { transform: translateY(2px); box-shadow: none; }
.cell.open {
    background: var(--tile-open); border-color: var(--tile-line); box-shadow: none; cursor: default; transform: none;
    animation: tile-flip 0.45s var(--d, 0ms) var(--bounce) both;
}
.cell.flag { background: var(--yellow); color: var(--navy); }
.cell.bomb { background: var(--coral); border-color: var(--ink); color: var(--navy); }
.cell.boom { background: var(--orange); color: var(--navy); animation: boom-pop 0.5s var(--bounce); }
.cell.wrong { background: transparent; border: 3px dashed var(--band-fg); color: var(--band-fg); box-shadow: none; }
.cell:focus-visible { outline: 4px solid var(--focus); outline-offset: 1px; z-index: 1; }
.cell[data-n="1"] { color: var(--cell-1); } .cell[data-n="2"] { color: var(--cell-2); } .cell[data-n="3"] { color: var(--cell-3); }
.cell[data-n="4"] { color: var(--cell-4); } .cell[data-n="5"], .cell[data-n="6"], .cell[data-n="7"], .cell[data-n="8"] { color: var(--cell-5); }
@keyframes tile-flip { from { transform: perspective(320px) rotateX(-90deg) scale(0.8); opacity: 0.2; } to { transform: none; opacity: 1; } }
@keyframes boom-pop { 0% { transform: scale(1); } 40% { transform: scale(1.35) rotate(8deg); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .cell.open, .cell.boom, .overlay, .overlay.banner, .shake, .stat.bump strong { animation: none; } }

/* Desk */
.desk { padding-top: clamp(3.5rem, 6vw, 5.5rem); padding-bottom: clamp(3.5rem, 7vw, 5.5rem); position: relative; }
.sec-head-small { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.8rem; }
.sec-head-small h2 { font-size: clamp(2rem, 5.5vw, 3rem); }
.desk-grid { display: grid; gap: 2.2rem; }
.field-label { display: block; margin-bottom: 0.6rem; font: 800 1.2rem var(--display); letter-spacing: -0.02em; }
.notes textarea {
    display: block; width: 100%; min-height: 220px; resize: vertical; padding: 1.1rem 1.3rem;
    font: 700 1.05rem/1.6 var(--text); color: var(--fg); background: var(--surface);
    border: var(--line); border-radius: var(--r-l);
}
.field-state { margin-top: 0.6rem; min-height: 1.5em; color: var(--muted); font-size: 0.95rem; font-weight: 700; }
.field-state.warn { color: #D12C18; font-weight: 800; }
:root[data-theme="dark"] .field-state.warn { color: var(--coral); }

.shell-log {
    height: 250px; overflow-y: auto; padding: 1.1rem 1.3rem;
    font: 600 0.95rem/1.55 var(--mono); white-space: pre-wrap;
    background: var(--surface); color: var(--fg); border: var(--line); border-radius: var(--r-l);
}
.shell-log .cmd { color: #D12C18; font-weight: 800; }
:root[data-theme="dark"] .shell-log .cmd { color: var(--yellow); }
.shell-log p { margin: 0 0 0.35rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.shell-form { display: grid; grid-template-columns: 1fr auto; gap: 0.7rem; margin-top: 1rem; align-items: center; }
.shell-form .prompt { grid-column: 1 / -1; font: 800 0.9rem var(--mono); color: var(--muted); }
.shell-form input {
    min-height: 50px; min-width: 0; padding: 0 1.2rem;
    font: 700 1rem var(--mono); color: var(--fg); background: var(--surface);
    border: var(--line); border-radius: var(--pill); box-shadow: 3px 3px 0 var(--ink);
}

/* Guestbook (shares the .desk layout and slabs) */
.gb-intro { margin-bottom: 1.8rem; color: var(--muted); max-width: 48ch; font-weight: 700; }
.gb-form { display: grid; gap: 0.6rem; align-content: start; }
.gb-form input, .gb-form textarea {
    display: block; width: 100%; padding: 1rem 1.3rem;
    font: 700 1.05rem/1.6 var(--text); color: var(--fg); background: var(--surface);
    border: var(--line); border-radius: var(--r-l);
}
.gb-form textarea { resize: vertical; min-height: 140px; }
.gb-form .btn { justify-self: start; }
.gb-log {
    height: 380px; overflow-y: auto; padding: 1.1rem;
    background: var(--surface); color: var(--fg); border: var(--line); border-radius: var(--r-l);
}
.gb-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.9rem; }
.gb-list li {
    padding: 0.8rem 1.1rem 0.9rem; background: #FFF0C2; color: var(--navy);
    border: 3px solid var(--ink); border-radius: var(--r-m);
}
.gb-list li:nth-child(4n + 2) { background: #CFF5E4; }
.gb-list li:nth-child(4n + 3) { background: #D7E6FF; }
.gb-list li:nth-child(4n + 4) { background: #FFD8D2; }
.gb-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.25rem 1rem; font-size: 0.9rem; color: #5C5878; font-weight: 700; }
.gb-head strong { color: var(--navy); font: 800 1.05rem var(--display); letter-spacing: -0.01em; overflow-wrap: anywhere; }
.gb-toggle { margin-top: 0.4rem; min-height: 32px; padding: 0; background: none; border: 0; color: #5C5878; font: 800 0.85rem var(--text); text-decoration: underline; cursor: pointer; }
.gb-toggle:hover { color: var(--navy); }
.gb-msg { margin-top: 0.35rem; white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 700; }

/* Footer */
.footer {
    display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; justify-content: space-between;
    margin-top: 1.5rem; padding: 1.8rem var(--gutter) 2.4rem;
    background: var(--coral); color: var(--navy);
    border: 4px solid var(--ink); border-bottom: 0; border-radius: 40px 40px 0 0;
    font-size: 0.95rem; font-weight: 800;
}
.footer a { display: inline-flex; align-items: center; min-height: 44px; color: var(--navy); font-weight: 800; text-decoration-color: var(--ink); }
.footer p { display: flex; align-items: center; gap: 0.4rem; }

/* Lightbox */
.lightbox {
    width: min(94vw, 1000px); max-height: 94dvh; padding: 0; border: 4px solid var(--ink); border-radius: var(--r-l);
    background: #25233A; color: #FFF9ED; overflow: auto; box-shadow: var(--pop-lg);
    --focus: var(--yellow);
}
.lightbox::backdrop { background: rgba(14, 12, 30, 0.8); }
.lightbox figure { padding: 4.2rem 1rem 0; }
.lightbox img { display: block; width: 100%; max-height: 68dvh; object-fit: contain; background: #16151F; border: 3px solid var(--ink); border-radius: var(--r-m); }
.lightbox figcaption { padding: 0.9rem 0.25rem; color: #D2CEEA; font-weight: 700; }
.lb-close { position: absolute; top: 0.9rem; right: 0.9rem; }
.lb-close, .lb-nav button {
    min-height: 48px; padding: 0 1.3rem; font: 800 1rem var(--text); color: var(--navy);
    background: var(--yellow); border: var(--line); border-radius: var(--pill); box-shadow: 3px 3px 0 var(--ink); cursor: pointer;
    transition: transform 0.2s var(--bounce), box-shadow 0.2s;
}
.lb-close:hover, .lb-nav button:hover { transform: translate(-1px, -3px) rotate(-2deg); box-shadow: 5px 6px 0 var(--ink); background: #FFE070; }
.lb-nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.4rem 1rem 1.2rem; }
.lb-nav span { color: #D2CEEA; font: 800 1.05rem var(--display); font-variant-numeric: tabular-nums; }

/* Features */
.feat-open { min-height: 44px; padding: 0; background: none; border: 0; color: var(--navy); font: 800 0.95rem var(--text); text-decoration: underline; text-decoration-color: var(--ink); text-decoration-thickness: 3px; cursor: pointer; }
.features { width: min(94vw, 720px); }
.feat-body { padding: 4.2rem 1.4rem 1.6rem; }
.feat-body h2 { font: 800 1.9rem var(--display); letter-spacing: -0.03em; margin-bottom: 1.1rem; color: var(--yellow); }
.feat-secret { padding: 1rem 1.2rem; margin-bottom: 1.3rem; border: 3px dashed var(--yellow); border-radius: var(--r-m); }
.feat-secret h3 { color: var(--yellow); font: 800 1.1rem var(--display); margin-bottom: 0.5rem; }
.feat-secret ul, .feat-list { display: grid; gap: 0.6rem; list-style: none; padding: 0; margin: 0; }
.feat-list li { padding-bottom: 0.6rem; border-bottom: 2px dashed #4A4770; color: #E6E2F8; font-weight: 700; }
.feat-secret li { color: #E6E2F8; font-weight: 700; }
.feat-body strong { color: var(--yellow); }

/* Motion */
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.live-card { animation: rise 0.6s 0.12s cubic-bezier(.2,.7,.2,1) both; }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Tablet: 640px+ */
@media (min-width: 640px) {
    .links { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .links a, .links .soon { padding: 0 1rem; font-size: 1.1rem; }
    .shots { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .shot.s0 { grid-column: 1 / 5; aspect-ratio: 4 / 5; }
    .shot.s1 { grid-column: 1 / -1; }
    .shot.s2, .shot.s3 { grid-column: span 3; aspect-ratio: 4 / 5; }
    .shot.sx { grid-column: span 2; }
    .panel { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
    .panel-mines { grid-template-columns: minmax(0, 1fr); }
    .desk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 640px) and (max-width: 899px) {
    .shot.s0 { grid-column: 1 / -1; aspect-ratio: 16 / 10; }
}
@media (max-width: 899px) { .hero::after { display: none; } .hero::before { opacity: 0.7; } }

/* Desktop: 900px+ */
@media (min-width: 1280px) {
    .menu-toggle { display: none; }
    .site-menu {
        position: static; display: flex; flex-direction: row; align-items: center; gap: 0.8rem;
        padding: 0; border: 0; background: transparent; border-radius: 0;
    }
    .site-nav { flex-direction: row; gap: 0.2rem; }
    .site-nav a { padding: 0 0.75rem; font-size: 0.98rem; min-height: 44px; }
    .site-nav a:hover:not([aria-current="true"]) { background: var(--surface); border-color: var(--ink); transform: rotate(-2deg); }
    .tools { flex-wrap: nowrap; gap: 0.45rem; }
    .tools .tool-btn { padding: 0 0.8rem; font-size: 0.88rem; white-space: nowrap; }
    .tools .icon-btn { padding: 0; }
    .tools .skin-select { padding-right: 2rem; background-position: right 0.7rem center; }
    .lang-switch button { min-width: 42px; padding: 0 0.5rem; }
    .music-tool { gap: 0.4rem; }
    .music-tool input[type="range"] { width: 64px; }
    .brand { font-size: 1.25rem; gap: 0.55rem; }
}
@media (min-width: 1500px) {
    .site-menu { gap: 1.2rem; }
    .site-nav a { padding: 0 1rem; font-size: 1.02rem; }
    .tools { gap: 0.6rem; }
    .tools .tool-btn { padding: 0 1rem; font-size: 0.95rem; }
    .music-tool input[type="range"] { width: 96px; }
}
@media (min-width: 900px) {
    .hero { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(2rem, 5vw, 4.5rem); align-items: start; padding-top: clamp(3rem, 7vw, 6rem); }
    .live-card { margin-top: clamp(0.5rem, 3vw, 2.5rem); padding: 1.9rem; }
    .links { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    .sec-head { grid-template-columns: auto 1fr; align-items: end; gap: 1.5rem 2rem; }
    .gallery .sec-head { grid-template-columns: auto auto 1fr; }
    .gallery .sec-head p { justify-self: end; text-align: right; }
    .sec-head-split { grid-template-columns: 1fr 1fr; align-items: end; }
    .sec-head-split p { justify-self: end; }
    .sec-head-small { display: flex; }

    .shots { grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-rows: clamp(120px, 15vw, 190px); gap: 1.2rem; }
    .shot.s0 { grid-column: 1 / 6; grid-row: 1 / 5; aspect-ratio: auto; }
    .shot.s1 { grid-column: 6 / 13; grid-row: 1 / 3; aspect-ratio: auto; }
    .shot.s2 { grid-column: 6 / 10; grid-row: 3 / 5; aspect-ratio: auto; }
    .shot.s3 { grid-column: 10 / 13; grid-row: 3 / 5; aspect-ratio: auto; }
    .shot.sx { grid-column: span 4; grid-row: auto; aspect-ratio: 4 / 3; }

    .panel { grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 3rem; }
    .panel:has(.stage-wide) { grid-template-columns: minmax(0, 640px) minmax(0, 1fr); }
    .panel-mines { grid-template-columns: minmax(0, 1fr); }
    .desk-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 3rem; }
    .dpad { display: none; }
}

/* On wide pointers the d-pad is redundant; keep it for touch devices of any width */
@media (min-width: 900px) and (pointer: coarse) { .dpad { display: grid; } }

/* Narrow phones */
@media (max-width: 420px) {
    .live-card { padding: 1.2rem; }
    .avatar { width: 76px; height: 76px; }
    .weather-main { font-size: 1.6rem; }
    .mines-top .btn, .mines-top .chips { flex: 1 1 auto; }
    .mines-top .chips button { flex: 1 1 0; }
}

::placeholder { color: var(--muted); opacity: 1; }

/* Scroll intro (see app.js)
   Only active when JS is present and motion is not reduced (html.js-intro). */
.intro { display: none; }
.js-intro .intro { display: block; height: 540vh; position: relative; }
.intro-stage {
    position: sticky; top: var(--topbar); height: calc(100vh - var(--topbar)); height: calc(100dvh - var(--topbar));
    overflow: hidden; background: transparent; display: grid; place-items: center;
}
.scene { position: relative; width: 100%; height: 100%; display: grid; place-items: center; perspective: 1000px; }
.tunnel { position: absolute; inset: 0; transform-style: preserve-3d; will-change: transform; }
.t-item { position: absolute; left: 50%; top: 50%; opacity: 0; will-change: opacity; backface-visibility: hidden; }
.intro-title {
    font: 800 clamp(4rem, 20vw, 15rem)/0.9 var(--display); letter-spacing: -0.045em; font-variation-settings: 'opsz' 96;
    text-shadow: 0.04em 0.05em 0 var(--yellow);
    white-space: nowrap; text-align: center; transform-style: preserve-3d; padding-bottom: 0.08em; opacity: 1;
}
.intro-title span { display: inline-block; will-change: transform; }
/* Once the intro has scrolled far away it gives its GPU layers back */
.intro.away .tunnel, .intro.away .t-item, .intro.away .intro-title span { will-change: auto; }
.intro.away .scene { visibility: hidden; }
.t-frame {
    --fc: var(--yellow);
    width: min(78vw, 980px); aspect-ratio: 16 / 10; border: 6px solid var(--ink); border-radius: 56px;
    box-shadow: inset 0 0 0 9px var(--fc);
}
.t-frame.c1 { --fc: var(--coral); }
.t-frame.c2 { --fc: var(--blue); }
.t-frame.c3 { --fc: var(--mint); }
.t-word { display: flex; align-items: center; gap: 1.2rem; white-space: nowrap; font: 800 clamp(2.6rem, 11vw, 9rem)/1 var(--display); letter-spacing: -0.04em; text-shadow: 0.04em 0.05em 0 var(--yellow); }
.t-word .no { min-width: 0; height: auto; padding: 0.22em 0.4em; font-size: 0.42em; text-shadow: none; }
.intro-hint {
    position: absolute; left: 0; right: 0; bottom: 2.2rem; display: flex; justify-content: center; align-items: center; gap: 0.7rem;
    font: 800 1rem var(--display); letter-spacing: 0.01em; color: var(--fg);
}
.intro-hint .arrow {
    display: inline-grid; place-items: center; width: 40px; height: 40px; border: var(--line); border-radius: 50%; color: var(--navy);
    background: var(--yellow); box-shadow: 3px 3px 0 var(--ink); animation: hop 1.1s var(--bounce) infinite;
}
@keyframes hop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(7px); } }
.intro-rail { position: absolute; left: 14px; right: 14px; bottom: 10px; height: 14px; background: var(--surface); border: 3px solid var(--ink); border-radius: var(--pill); overflow: hidden; }
.intro-rail i { display: block; height: 100%; transform-origin: 0 50%; transform: scaleX(0); background: var(--coral); border-radius: var(--pill); }

/* Reveal on scroll: every block pops in from depth and overshoots a little */
.js-intro .hero h1, .js-intro .live-card { animation: none; }
.js-intro [data-reveal] {
    --ease: cubic-bezier(.3, 1.45, .55, 1);
    opacity: 0;
    transform: perspective(1000px) translate3d(0, 64px, -180px) rotateX(38deg);
    transform-origin: 50% 100%;
    transition: opacity 0.7s ease, transform 1.05s var(--ease);
    transition-delay: calc(var(--i, 0) * 110ms);
}
.js-intro [data-reveal="card"] { transform: perspective(1000px) translate3d(90px, 0, -260px) rotateY(-45deg); transform-origin: 100% 50%; }
.js-intro [data-reveal="zoom"] { transform: perspective(1000px) translate3d(0, 70px, -280px) rotateX(26deg) rotateY(-14deg) scale(0.9); }
.js-intro [data-reveal="left"] { transform: perspective(1000px) translate3d(-100px, 0, -220px) rotateY(42deg); transform-origin: 0 50%; }
.js-intro [data-reveal="right"] { transform: perspective(1000px) translate3d(100px, 0, -220px) rotateY(-42deg); transform-origin: 100% 50%; }
.js-intro [data-reveal].in { opacity: 1; transform: perspective(1100px) rotateX(var(--tx, 0deg)) rotateY(var(--ty, 0deg)); }
.js-intro [data-reveal].in.settled { transition: transform 0.3s ease-out, opacity 0.3s ease; transition-delay: 0s; }
/* Tilted and flying-in cards reach past the screen edge. Phones ignore overflow on body (they zoom out or pan
   sideways instead), so the clipping happens on the content itself. clip, unlike hidden, keeps position: sticky working. */
html, body { overflow-x: clip; }
main, .footer { overflow-x: clip; }
@supports not (overflow-x: clip) { main > section, .footer { overflow-x: hidden; } }
@media (prefers-reduced-motion: reduce) { .js-intro [data-reveal] { transition: none; } }

/* Hero name: the letters tumble in one by one */
.js-intro .hero h1 span {
    display: inline-block; opacity: 0;
    transform: perspective(900px) translate3d(0, 50px, -380px) rotateX(-85deg);
    transition: opacity 0.6s ease, transform 1.1s var(--bounce);
    transition-delay: calc(var(--l, 0) * 70ms);
}
.js-intro .hero h1.in span { opacity: 1; transform: none; }
.js-intro .hero h1[data-reveal] { opacity: 1; transform: none; transition: none; }

/* Persistent 3D: every card is a slab. It rests tilted, has stacked ink plates behind it for thickness,
   and leans toward the pointer. --tx / --ty are written by app.js. */
.slab {
    --p1: var(--ink); --p2: var(--ink); --d: 9px;
    position: relative; transform-style: preserve-3d;
    transform: perspective(1100px) rotateX(var(--tx, 0deg)) rotateY(var(--ty, 0deg));
    transition: transform 0.3s ease-out;
}
.slab::before, .slab::after { content: ""; position: absolute; inset: -3px; border-radius: inherit; pointer-events: none; }
.slab::before { background: var(--p1); transform: translateZ(calc(var(--d) * -1)); }
.slab::after { background: var(--p2); transform: translateZ(calc(var(--d) * -2)); }
.live-card.slab { --p1: var(--ink); --p2: var(--coral); --d: 12px; }
.shot.slab { --d: 14px; --p2: var(--yellow); }
.no.slab { --p1: var(--ink); --p2: var(--ink); --d: 5px; }
.stage.slab, .desk .slab { border-radius: var(--r-l); }
.desk .slab { --d: 7px; --p2: var(--mint); }
.guestbook .slab { --p2: var(--violet); }
.desk .slab > textarea, .desk .slab > input, .desk .slab > .shell-log, .desk .slab > .gb-log { transform: translateZ(0.1px); }
.stat.slab { --p2: var(--blue); }

/* Content floats in front of the card face */
.live-card h2 { transform: translateZ(26px); }
.live-card .avatar { transform: translateZ(38px); }
.live-card .weather-main { transform: translateZ(24px); }
.live-card .card-btn { transform: translateZ(14px); }
.live-card .card-head, .live-card .live-row, .live-card .live-text, .live-card .weather { transform-style: preserve-3d; }
@media (prefers-reduced-motion: reduce) { .slab { transition: none; } }


.footer-note { font-size: 0.85rem; opacity: 0.75; }
.ban-wall { position: fixed; inset: 0; z-index: 99999; display: grid; place-items: center; padding: 1.5rem; text-align: center; background: var(--coral); color: var(--ink); }
.ban-wall div { max-width: 28rem; background: var(--bg); border: 4px solid var(--ink); border-radius: 32px; padding: 2rem; box-shadow: 6px 6px 0 var(--ink); color: var(--fg); }
.ban-wall h1 { font: 800 2rem var(--display); margin-bottom: 0.6rem; }
html.banned { overflow: hidden; }

.player-row.need #player-hint { color: var(--coral); font-weight: 800; }
.player-row.need #player-name { border-color: var(--coral); animation: nudge 0.4s var(--bounce); }
@keyframes nudge { 30% { transform: translateX(-5px); } 60% { transform: translateX(5px); } }

/* entry gate */
html.gated { overflow: hidden; }
.gate { position: fixed; inset: 0; z-index: 9000; display: grid; place-items: center; padding: 1.5rem; overflow: hidden; cursor: pointer; background: var(--bg); background-image: radial-gradient(circle at 1px 1px, var(--dots) 2px, transparent 2.4px); background-size: 28px 28px; transition: opacity 0.55s ease, transform 0.55s var(--bounce); }
.gate.leaving { opacity: 0; transform: scale(1.08); pointer-events: none; }
.gate-box { position: relative; z-index: 1; display: grid; gap: 1.4rem; justify-items: center; text-align: center; }
.gate-name { font: 800 clamp(3rem, 13vw, 7.5rem)/0.95 var(--display); letter-spacing: -0.04em; color: var(--fg); text-shadow: 5px 5px 0 var(--yellow); }
.gate-btn { font: 800 clamp(1.1rem, 3.4vw, 1.5rem) var(--display); color: var(--navy); background: var(--yellow); border: 4px solid var(--ink); border-radius: 999px; padding: 0.9rem 2.2rem; box-shadow: 5px 5px 0 var(--ink); cursor: pointer; animation: gate-bob 1.6s ease-in-out infinite; transition: transform 0.2s var(--bounce), box-shadow 0.2s; }
.gate-btn:hover { transform: translate(-2px, -3px) scale(1.04); box-shadow: 8px 8px 0 var(--ink); animation-play-state: paused; }
.gate-btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.gate-note { color: var(--muted); font-weight: 700; }
.gate-blob { position: absolute; border: 4px solid var(--ink); border-radius: 58% 42% 55% 45% / 48% 56% 44% 52%; animation: gate-float 9s ease-in-out infinite; }
.gate-blob.b1 { width: 26vmin; height: 26vmin; background: var(--coral); left: 8%; top: 12%; }
.gate-blob.b2 { width: 20vmin; height: 20vmin; background: var(--mint); right: 10%; top: 18%; animation-delay: -3s; }
.gate-blob.b3 { width: 30vmin; height: 30vmin; background: var(--sky); right: 16%; bottom: 8%; animation-delay: -6s; }
@keyframes gate-bob { 50% { transform: translateY(-7px); } }
@keyframes gate-float { 50% { transform: translate(14px, -18px) rotate(14deg) scale(1.06); border-radius: 44% 56% 42% 58% / 58% 44% 56% 42%; } }
@media (prefers-reduced-motion: reduce) { .gate-btn, .gate-blob { animation: none; } .gate { transition: opacity 0.2s; } }

.notice { position: fixed; left: 50%; bottom: 1rem; z-index: 60; display: flex; align-items: center; gap: 0.4rem; max-width: min(34rem, calc(100% - 1.5rem)); padding: 0.3rem 0.4rem 0.3rem 1.2rem; background: var(--yellow); color: var(--navy); border: 3px solid var(--ink); border-radius: 999px; box-shadow: 4px 4px 0 var(--ink); transform: translateX(-50%); font-weight: 800; }
.notice p { margin: 0; padding: 0.3rem 0; overflow-wrap: anywhere; }
.notice button { flex: none; width: 44px; height: 44px; font: 800 1rem var(--text); color: var(--navy); background: transparent; border: 0; border-radius: 50%; cursor: pointer; }
html.gated .notice { display: none; }

/* The special button at the very bottom of the footer */
.footer .rick-row { flex-basis: 100%; justify-content: center; margin-top: 0.8rem; }
.special-btn {
    position: relative; overflow: hidden; min-height: 58px; padding: 0 2.4rem;
    font: 800 1.25rem var(--display); letter-spacing: -0.01em; color: var(--navy); cursor: pointer;
    border: 4px solid var(--ink); border-radius: 999px; box-shadow: 5px 5px 0 var(--ink);
    background: linear-gradient(110deg, var(--yellow) 0 12.5%, var(--mint) 12.5% 25%, var(--sky) 25% 37.5%, var(--violet) 37.5% 50%, var(--yellow) 50% 62.5%, var(--mint) 62.5% 75%, var(--sky) 75% 87.5%, var(--violet) 87.5% 100%);
    background-size: 200% 100%;
    animation: special-slide 3.2s linear infinite, special-wobble 2.6s ease-in-out infinite;
    transition: box-shadow 0.2s;
}
.special-btn::after { content: ""; position: absolute; top: -20%; bottom: -20%; left: -40%; width: 22%; background: rgba(255, 255, 255, 0.6); transform: skewX(-24deg); animation: special-shine 3.2s ease-in-out infinite; }
.special-btn:hover { animation-play-state: running, paused; transform: scale(1.1) rotate(0deg); box-shadow: 8px 9px 0 var(--ink); }
.special-btn:active { transform: translate(4px, 4px); box-shadow: 1px 1px 0 var(--ink); }
@keyframes special-slide { to { background-position: -200% 0; } }
@keyframes special-wobble { 0%, 100% { transform: rotate(-2.5deg) scale(1); } 50% { transform: rotate(2.5deg) scale(1.06); } }
@keyframes special-shine { 0%, 55% { left: -40%; } 100% { left: 130%; } }
@media (prefers-reduced-motion: reduce) { .special-btn, .special-btn::after { animation: none; } }

.rick { width: min(760px, calc(100% - 1.5rem)); max-width: none; padding-bottom: 1rem; }
.rick h2 { margin: 0; padding: 1rem 5.5rem 0.8rem 1rem; font: 800 1.5rem/1.1 var(--display); }
.rick-frame { display: block; width: calc(100% - 2rem); max-height: 72dvh; margin: 0 1rem; object-fit: contain; background: #000; border: 3px solid var(--ink); border-radius: var(--r-m); }

.rick-fail { margin: 0.8rem 1rem 0; padding: 0.7rem 1rem; background: var(--coral); color: var(--navy); border: 3px solid var(--ink); border-radius: var(--r-m); font-weight: 800; }

/* Grand Prix tab (see f1race.js): available in every theme */
#race-canvas { aspect-ratio: 440 / 560; background: #060B1D; }
.race-tower { display: grid; gap: 2px; width: 100%; max-width: 20rem; padding: 0.4rem; margin: 0; list-style: none; background: rgba(6, 11, 29, 0.78); color: #F6F3EC; border: 3px solid #F6F3EC; border-radius: 16px; font: 800 0.85rem/1.2 var(--display); }
.race-tower li { display: grid; grid-template-columns: 1.6rem 0.9rem 2.6rem 1.15rem 1fr; align-items: center; gap: 0.4rem; padding: 0.12rem 0.4rem; border-radius: 8px; }
.race-tower .rt-pos { text-align: right; color: #FFC906; }
.race-tower .rt-chip { width: 0.9rem; height: 0.9rem; border: 2px solid; border-radius: 50%; }
.race-tower .rt-tyre { box-sizing: border-box; width: 1.15rem; height: 1.15rem; display: grid; place-items: center; border: 2px solid transparent; border-radius: 50%; font-size: 0.62rem; line-height: 1; }
.race-tower li.me .rt-tyre:not(:empty) { background: #0A0F2B; }
.race-tower .rt-gap { text-align: right; color: #C4C0DE; font-variant-numeric: tabular-nums; white-space: pre; }
.race-tower li.me { background: #FFC906; color: #0A0F2B; }
.race-tower li.me .rt-pos, .race-tower li.me .rt-gap { color: #0A0F2B; }
.race-tower li.last { box-shadow: inset 0 0 0 2px #E10A3C; }

/* Online racing panel */
.race-online { display: grid; gap: 0.8rem; width: 100%; max-width: 20rem; }
.race-online[hidden] { display: none; }
.race-online .ro-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.race-online label { font-weight: 800; color: var(--band-fg); }
.race-online input[type="text"] { flex: 1 1 6rem; min-height: 46px; padding: 0 1rem; font: 800 1.1rem var(--display); letter-spacing: 0.15em; text-transform: uppercase; color: var(--band-fg); background: var(--band-surface); border: var(--line); border-radius: 16px; }
.race-online input[readonly] { letter-spacing: 0; text-transform: none; font: 600 0.8rem var(--text); }
.race-online .ro-codebox { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; padding: 0.6rem 1rem; color: #F6F3EC; background: rgba(6, 11, 29, 0.78); border: 3px solid #FFC906; border-radius: 16px; font-weight: 800; }
.race-online .ro-code { font: 800 2rem/1 var(--display); letter-spacing: 0.2em; color: #FFC906; }
.ro-players { display: grid; gap: 4px; padding: 0.4rem; margin: 0; list-style: none; color: #F6F3EC; background: rgba(6, 11, 29, 0.78); border: 3px solid #F6F3EC; border-radius: 16px; font: 800 0.95rem var(--display); }
.ro-players li { display: flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0.5rem; border-radius: 8px; }
.ro-players li.me { background: #FFC906; color: #0A0F2B; }
.ro-players li.empty { opacity: 0.6; font-weight: 600; }
.ro-players .rt-chip { flex: none; width: 0.9rem; height: 0.9rem; border: 2px solid; border-radius: 50%; }
.ro-players .ro-name { flex: 1; overflow-wrap: anywhere; }
.ro-players em { font-style: normal; font-size: 0.75rem; opacity: 0.85; }
.ro-status { min-height: 1.4em; margin: 0; font-weight: 800; color: var(--band-fg); }
.ro-status.bad { color: #8E1B10; }
:root[data-theme="dark"] .ro-status.bad { color: #FFB4A8; }

/* Theme picker in the top bar: the same pill as the other tools, with its own arrow */
.skin-select {
    appearance: none; -webkit-appearance: none; padding-right: 2.2rem; max-width: 100%; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2312111A' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 0.85rem center; background-size: 12px 8px;
}
:root[data-theme="dark"] .skin-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23FFF9ED' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.skin-select option { background: var(--surface); color: var(--fg); }

/* Pause and reset sit right at the top of the column beside the track, where a hand can reach them mid-race */
.race-actions { width: 100%; max-width: 20rem; }
.race-actions .btn { flex: 1 1 0; min-height: 56px; font-size: 1.1rem; }

.race-tower li.out { opacity: 0.55; }
.race-tower li.out .rt-gap { color: #FF9C8F; font-weight: 800; }

/* Race settings and pit controls */
.race-setup { display: grid; gap: 0.55rem; width: 100%; max-width: 20rem; }
.race-setup[hidden] { display: none; }
.rs-row { display: grid; gap: 0.25rem; }
.rs-label { font-weight: 800; font-size: 0.85rem; color: var(--band-fg); }
.race-setup .chips { width: 100%; }
.race-setup .chips button { flex: 1 1 0; padding: 0 0.6rem; min-height: 44px; }


/* Race: touch controls under the track, and a full screen mode for phones */
.race-shell { width: 100%; max-width: 440px; min-width: 0; }
.race-touch { display: none; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.7rem; margin-top: 1rem; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
@media (pointer: coarse) { .race-touch { display: grid; } }
.race-touch button { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; font-family: var(--display); cursor: pointer; }
.rt-steer { position: relative; min-height: 176px; display: grid; place-items: center; overflow: hidden; background: #0A0F2B; border: 3px solid var(--ink); border-radius: 28px; touch-action: none; }
.rt-steer::before { content: ""; position: absolute; left: 14%; right: 14%; top: 50%; height: 6px; margin-top: -3px; border-radius: 3px; background: rgba(246, 243, 236, 0.16); }
.rt-knob { width: 76px; height: 76px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #FFE27A, #FFC906 60%, #D19A00); border: 3px solid var(--ink); box-shadow: 0 6px 0 rgba(0, 0, 0, 0.35); transform: translateX(var(--sx, 0px)); transition: transform 0.09s ease-out; }
.rt-steer.on .rt-knob { transition: none; }
.rt-hint { position: absolute; left: 0; right: 0; bottom: 0.55rem; text-align: center; font: 800 0.75rem var(--text); letter-spacing: 0.04em; color: #C4C0DE; pointer-events: none; }
.rt-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; align-content: stretch; }
.rt-tools { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.4rem; }
.rt-tools button:last-child { grid-column: 1 / -1; }
.rt-tools button { min-width: 0; min-height: 44px; padding: 0 0.3rem; font-size: 1.05rem; font-weight: 800; line-height: 1.1; color: #0A0F2B; background: #FFFFFF; border: 3px solid var(--ink); border-radius: 14px; }
.rt-tools button:last-child { font-size: 0.78rem; }
.rt-big { min-height: 66px; font-size: 1.15rem; font-weight: 800; letter-spacing: 0.02em; border: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 5px 0 var(--ink); }
.rt-big:active, .rt-big.down { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.rt-boost { grid-column: 1 / -1; color: #0A0F2B; background: #FFC906; }
.rt-brake { color: #fff; background: #E10A3C; }
.rt-pit { color: #fff; background: #2F6BFF; }
.rt-pit[aria-pressed="true"] { color: #0A0F2B; background: #FFC906; }
.rt-pit:disabled { opacity: 0.5; }
.rt-pit[hidden] { display: none; }
.rt-next { display: flex; align-items: center; justify-content: center; gap: 0.5rem; min-height: 44px; grid-column: 1 / -1; font-size: 0.8rem; font-weight: 800; color: #0A0F2B; background: #FFFFFF; border: 3px solid var(--ink); border-radius: 14px; }
.rt-next[hidden] { display: none; }
.rt-next i { display: inline-grid; place-items: center; box-sizing: border-box; width: 1.6rem; height: 1.6rem; font-style: normal; font-size: 0.8rem; color: #F6F3EC; background: #05070f; border: 3px solid; border-radius: 50%; }
html.race-lock, html.race-lock body { overflow: hidden; overscroll-behavior: none; }
.race-shell.race-full { position: fixed; inset: 0; z-index: 900; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; width: auto; max-width: none; padding: max(0.4rem, env(safe-area-inset-top)) 0.5rem max(0.5rem, env(safe-area-inset-bottom)); overflow: hidden; background: #05070F; }
.race-shell.race-full .stage { flex: none; width: min(100%, calc((100dvh - 250px) * 440 / 560)); max-width: none; }
.race-shell.race-full canvas { width: 100%; max-width: none; border-width: 3px; }
.race-shell.race-full .race-touch { display: grid; flex: 1 1 auto; width: 100%; min-height: 0; margin: 0; }
.race-shell.race-full .rt-steer { min-height: 0; height: 100%; }
@media (orientation: landscape) and (max-height: 620px) {
    .race-shell.race-full { flex-direction: row; align-items: stretch; justify-content: center; }
    .race-shell.race-full .stage { align-self: center; width: calc((100dvh - 1rem) * 440 / 560); }
    .race-shell.race-full .race-touch { display: contents; }
    .race-shell.race-full .rt-steer { order: -1; flex: 1 1 0; min-width: 0; }
    .race-shell.race-full .rt-btns { order: 1; flex: 1 1 0; min-width: 0; }
}

/* Bilardo */
.pool-shell { width: 100%; max-width: 640px; min-width: 0; }
.pool-shell .stage { max-width: none; }
#pool-canvas { max-width: none; aspect-ratio: 900 / 500; background: #3b200d; touch-action: none; cursor: crosshair; }
.pool-power { display: grid; grid-template-columns: 3.2rem minmax(0, 1fr) 3.2rem; gap: 0.5rem; margin-top: 1rem; user-select: none; -webkit-user-select: none; touch-action: none; }
.pool-power button { min-height: 52px; font: 800 1.4rem var(--display); color: var(--band-fg); background: var(--band-surface); border: var(--line); border-radius: 16px; cursor: pointer; touch-action: none; }
.pp-bar { position: relative; min-height: 52px; overflow: hidden; background: #0A0F2B; border: var(--line); border-radius: 16px; cursor: ew-resize; touch-action: none; }
.pp-bar i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #3fdc9b, #ffc906 60%, #e10a3c); }
.pp-bar span { position: relative; display: grid; place-items: center; height: 100%; padding: 0 0.6rem; font: 800 0.82rem var(--text); color: #F6F3EC; text-align: center; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8); pointer-events: none; }
.pool-players { display: grid; gap: 0.4rem; width: 100%; max-width: 20rem; padding: 0; margin: 0; list-style: none; }
.pool-players li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.6rem; padding: 0.55rem 0.9rem; color: var(--band-fg); background: var(--band-surface); border: var(--line); border-radius: 14px; }
.pool-players li.on { color: #0A0F2B; background: #FFC906; }
.pool-players strong { font: 800 1.05rem var(--display); }
.pool-players span { font-weight: 700; font-size: 0.85rem; opacity: 0.85; }
.pool-players em { margin-left: auto; font-style: normal; font-weight: 800; font-size: 0.75rem; }
#pool-levels[hidden], #pool-online[hidden], #pool-new[hidden] { display: none; }

/* Amiral Battı: two 10 x 10 seas. The cells are buttons over a water layer; the ships sit between the two, so the hit and
   miss marks on the cells land on top of them. Colours come from the --sea-* tokens, which the themes in skins.css change. */
#panel-sea.panel { grid-template-columns: minmax(0, 1fr); gap: 1.1rem; }
.sea-top { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; }
#sea-levels[hidden], #sea-online[hidden], #sea-new[hidden], .sea-firebar[hidden] { display: none; }
#sea-online { max-width: 26rem; }
.sea-stage { position: relative; min-width: 0; min-height: 18rem; padding: clamp(0.7rem, 2vw, 1.3rem); background: var(--band-surface); border: 4px solid var(--ink); border-radius: var(--r-l); box-shadow: var(--pop-lg); }
.sea-stage > .overlay:not(.banner) { border-radius: calc(var(--r-l) - 4px); }
.sea-stage > .overlay.sea-cover { background: var(--overlay-solid); }
.sea-boards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.2rem 1.8rem; align-items: start; }
@media (min-width: 760px) { .sea-boards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.sea-boards:not(.placing) .sea-dock, .sea-boards.placing .sea-foe { display: none; }
@media (max-width: 759px) {
    .sea-boards:not(.placing) .sea-foe { order: -1; }
    .sea-boards:not(.placing) .sea-own .sea-grid, .sea-boards:not(.placing) .sea-own .sea-head { max-width: 18rem; }
}
.sea-board { display: grid; gap: 0.6rem; justify-items: center; min-width: 0; }
.sea-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; width: 100%; max-width: 30rem; }
.sea-title { display: flex; align-items: center; gap: 0.45em; margin: 0; font: 800 1.15rem/1.15 var(--display); letter-spacing: -0.01em; color: var(--band-fg); }
.sea-tag { font-weight: 800; font-size: 0.8rem; color: var(--band-muted); white-space: nowrap; }
.sea-board.on .sea-title::before { content: ''; flex: none; width: 0.6em; height: 0.6em; border: 2px solid var(--ink); border-radius: 50%; background: var(--sea-hit); animation: sea-blink 1s ease-in-out infinite alternate; }
.sea-grid {
    position: relative; display: grid; width: 100%; max-width: 30rem; aspect-ratio: 1;
    grid-template-columns: 1.4rem repeat(10, minmax(0, 1fr)); grid-template-rows: 1.4rem repeat(10, minmax(0, 1fr));
    user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
}
.sea-lab { display: grid; place-items: center; font: 800 0.72rem/1 var(--display); color: var(--band-muted); }
.sea-water {
    grid-area: 2 / 2 / -1 / -1; margin: -3px; border: 3px solid var(--ink); border-radius: 14px;
    background:
        radial-gradient(ellipse 45% 18% at 25% 30%, rgba(255, 255, 255, 0.2), transparent 70%),
        radial-gradient(ellipse 40% 16% at 72% 72%, rgba(255, 255, 255, 0.14), transparent 70%),
        linear-gradient(160deg, var(--sea-a), var(--sea-b));
    background-size: 220% 220%, 220% 220%, 100% 100%;
    animation: sea-drift 16s ease-in-out infinite alternate;
}
.sea-board.on .sea-water { box-shadow: 0 0 0 4px var(--sea-aim); }
.sea-own.on .sea-water { box-shadow: 0 0 0 4px var(--sea-hit); }
@keyframes sea-drift { to { background-position: 100% 70%, 0% 30%, 0 0; } }
@keyframes sea-blink { from { opacity: 0.35; } to { opacity: 1; } }

.sea-cell {
    position: relative; z-index: 2; min-width: 0; min-height: 0; padding: 0; margin: 0;
    background: transparent; border: 0; border-radius: 0; box-shadow: inset -1px -1px 0 var(--sea-line); cursor: default; color: inherit; font: inherit;
}
.sea-grid.can .sea-cell { cursor: crosshair; }
.sea-own .sea-grid.can .sea-cell { cursor: pointer; }
.sea-foe .sea-grid.can .sea-cell:not(.miss):not(.hit):hover { background: rgba(255, 255, 255, 0.3); }
.sea-cell:focus-visible { z-index: 3; outline: 3px solid var(--focus); outline-offset: -3px; }
.sea-cell.pv { background: rgba(63, 220, 155, 0.45); }
.sea-cell.pv.bad { background: rgba(255, 70, 70, 0.5); }
.sea-cell::before, .sea-cell::after { content: none; position: absolute; inset: 0; margin: auto; border-radius: 50%; pointer-events: none; }
.sea-cell.miss::after { content: ''; width: 28%; height: 28%; background: var(--sea-miss); box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.22); }
.sea-cell.miss.fresh::before { content: ''; inset: 8%; border: 2px solid var(--sea-miss); animation: sea-ripple 0.9s ease-out both; }
.sea-cell.hit::after {
    content: ''; width: 64%; height: 64%;
    background: radial-gradient(circle, #FFFFFF 0 14%, var(--sea-fire) 32%, var(--sea-hit) 62%, transparent 72%);
    animation: sea-flicker 0.9s ease-in-out infinite alternate;
}
.sea-cell.hit.down::after { width: 52%; height: 52%; background: radial-gradient(circle, var(--sea-hit) 0 28%, rgba(10, 8, 14, 0.75) 34% 62%, transparent 68%); animation: none; }
.sea-cell.hit.fresh::before {
    content: ''; z-index: 4; inset: -40%;
    background: radial-gradient(circle, #FFFFFF 0 10%, var(--sea-fire) 30%, var(--sea-hit) 52%, transparent 70%);
    animation: sea-boom 0.65s ease-out both;
}
.sea-cell.aim::before { content: ''; inset: 10%; border: 3px dashed var(--sea-aim); animation: sea-spin 3s linear infinite; }
.sea-cell.aim::after { content: ''; width: 20%; height: 20%; background: var(--sea-aim); box-shadow: 0 0 0 2px var(--ink); }
@keyframes sea-ripple { from { transform: scale(0.3); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
@keyframes sea-boom { 0% { transform: scale(0.2); opacity: 1; } 60% { opacity: 0.9; } 100% { transform: scale(1.35); opacity: 0; } }
@keyframes sea-flicker { from { transform: scale(0.88); filter: brightness(0.95); } to { transform: scale(1.06); filter: brightness(1.15); } }
@keyframes sea-spin { to { transform: rotate(360deg); } }

.sea-ship {
    --n: 3; position: relative; z-index: 1; display: grid; place-items: center; pointer-events: none;
    border: 3px solid var(--ink); background: linear-gradient(180deg, var(--sea-hull-2), var(--sea-hull)); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.28);
}
.sea-ship.h { margin: 14% 1px; margin: clamp(3px, 0.6vw, 6px) 2px; border-radius: 10px 999px 999px 10px; }
.sea-ship.v { margin: 2px clamp(3px, 0.6vw, 6px); border-radius: 999px 999px 10px 10px; background: linear-gradient(90deg, var(--sea-hull-2), var(--sea-hull)); }
.sea-ship.len5 { --n: 5; } .sea-ship.len4 { --n: 4; } .sea-ship.len2 { --n: 2; }
.sea-ship i { display: block; }
.sea-ship.h i { width: 80%; height: 34%; background: radial-gradient(circle closest-side, var(--sea-deck) 62%, transparent 70%) 0 0 / calc(100% / var(--n)) 100% repeat-x; }
.sea-ship.v i { width: 34%; height: 80%; background: radial-gradient(circle closest-side, var(--sea-deck) 62%, transparent 70%) 0 0 / 100% calc(100% / var(--n)) repeat-y; }
.sea-ship.ghost { z-index: 1; opacity: 0.7; border-style: dashed; box-shadow: none; }
.sea-ship.ghost.bad { background: #FF5A5A; }
.sea-ship.sunk { background: var(--sea-sunk); box-shadow: none; filter: saturate(0.5); }
.sea-ship.sunk i { opacity: 0.35; }
.sea-ship.sinking { animation: sea-sink 1.2s ease-in-out both; }
@keyframes sea-sink { 0% { transform: none; filter: none; } 25% { transform: rotate(-3deg) scale(1.03); } 55% { transform: rotate(2.5deg) translateY(2px); } 100% { transform: none; } }

.sea-fleet { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.35rem; max-width: 30rem; padding: 0; margin: 0; list-style: none; }
.sea-fleet li { display: flex; align-items: center; gap: 0.35rem; padding: 0.18rem 0.55rem; font-weight: 800; font-size: 0.78rem; color: var(--band-fg); background: var(--tile-open); border: 2px solid var(--ink); border-radius: var(--pill); }
.sea-fleet b { display: flex; gap: 2px; }
.sea-fleet b i { width: 7px; height: 7px; border-radius: 2px; background: var(--sea-hull); }
.sea-fleet li.down { opacity: 0.6; text-decoration: line-through; }
.sea-fleet li.down b i { background: var(--sea-hit); }
.sea-firebar { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
.sea-fire { min-width: 9rem; }

.sea-dock { display: grid; align-content: start; gap: 0.8rem; min-width: 0; }
.sea-dock-title { margin: 0; font: 800 1.15rem var(--display); color: var(--band-fg); }
.sea-yard { display: grid; gap: 0.45rem; }
.sea-pick {
    display: flex; align-items: center; gap: 0.75rem; min-height: 46px; padding: 0.35rem 0.85rem; text-align: left;
    font: 800 0.95rem var(--text); color: var(--band-fg); background: var(--tile-open); border: var(--line); border-radius: 14px; cursor: pointer;
    transition: transform 0.18s var(--bounce);
}
.sea-pick:hover { transform: translateX(3px); }
.sea-pick[aria-pressed="true"] { color: var(--navy); background: var(--yellow); box-shadow: var(--pop); }
.sea-pick.placed { opacity: 0.6; }
.sea-pick.placed span:last-child::after { content: ' ✓'; }
.sea-mini { --n: 3; flex: none; width: calc(var(--n) * 15px); height: 15px; border: 2px solid var(--ink); border-radius: 4px 999px 999px 4px; background: linear-gradient(180deg, var(--sea-hull-2), var(--sea-hull)); }
.sea-mini.len5 { --n: 5; } .sea-mini.len4 { --n: 4; } .sea-mini.len2 { --n: 2; }
.sea-dock-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.sea-dock .btn:disabled, .sea-firebar .btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.sea-dock .hint { margin: 0; font-size: 0.85rem; }

.sea-pop {
    position: absolute; z-index: 5; left: 50%; top: 50%; opacity: 0; pointer-events: none; white-space: nowrap;
    transform: translate(-50%, -50%); font: 800 clamp(1.5rem, 4.5vw, 2.6rem)/1 var(--display); letter-spacing: -0.02em;
    color: var(--sea-fire); text-shadow: 3px 3px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink);
}
.sea-pop.hit { color: var(--sea-hit); }
.sea-pop.miss { color: var(--sea-miss); font-size: clamp(1.2rem, 3.4vw, 1.9rem); }
.sea-pop.big { font-size: clamp(1.9rem, 6vw, 3.4rem); }
.sea-pop.go { animation: sea-pop 0.8s var(--bounce) both; }
.sea-pop.big.go { animation-duration: 1.5s; }
@keyframes sea-pop {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4) rotate(-8deg); }
    22% { opacity: 1; transform: translate(-50%, -50%) scale(1.1) rotate(-3deg); }
    72% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-3deg); }
    100% { opacity: 0; transform: translate(-50%, -70%) scale(1) rotate(-3deg); }
}
@media (prefers-reduced-motion: reduce) {
    .sea-water, .sea-board.on .sea-title::before, .sea-cell.hit::after, .sea-cell.aim::before, .sea-ship.sinking { animation: none; }
    .sea-cell.hit.fresh::before, .sea-cell.miss.fresh::before { animation-duration: 0.01s; }
    .sea-pop.go, .sea-pop.big.go { animation: sea-pop 1.2s steps(1) both; }
}

/* Race: the 3D view lies under the 2D canvas, which then only carries the panels */
.stage canvas.race-3d { position: absolute; z-index: 0; display: none; width: auto; max-width: none; aspect-ratio: auto; border: 0; border-radius: calc(var(--r-l) - 4px); background: #8cc4f0; pointer-events: none; }
#race-canvas { position: relative; z-index: 1; }

/* Game room tools: the game volume and full screen (full screen is for computers; phones have the race's own) */
.game-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 0.9rem; margin: -0.4rem 0 1.4rem; color: var(--band-fg); font-weight: 800; }
.game-tools input[type="range"] { width: min(12rem, 40vw); accent-color: var(--yellow); }
.game-tools output { min-width: 3ch; font-variant-numeric: tabular-nums; }
#game-fs { margin-left: auto; }
@media (pointer: coarse) { #game-fs { display: none; } }
#game-fs[hidden] { display: none; }
.panel:fullscreen { position: relative; display: grid; grid-template-columns: auto minmax(15rem, 22rem); align-items: center; justify-content: center; gap: 2rem; padding: 4.2rem 2rem 1.5rem; overflow: hidden; background: var(--band-bg); }
.panel:fullscreen > .side { max-height: calc(100vh - 6rem); overflow: auto; padding: 0.4rem 0.6rem 0.6rem 0.2rem; }
.panel:fullscreen[hidden] { display: none; }
.panel-mines:fullscreen { grid-template-columns: minmax(0, 1fr); align-content: start; overflow: auto; }
.panel:fullscreen .stage, .panel:fullscreen .stage canvas { max-width: none; }
#panel-snake:fullscreen .stage { max-width: none; width: min(62vw, calc(100vh - 6.5rem)); }
#panel-pong:fullscreen .stage { max-width: none; width: min(68vw, calc((100vh - 6.5rem) * 1.75)); }
#panel-race:fullscreen .race-shell { max-width: none; width: min(60vw, calc((100vh - 6.5rem) * 440 / 560)); }
#panel-pool:fullscreen .pool-shell { max-width: none; width: min(68vw, calc((100vh - 11rem) * 1.8)); }
#panel-sea:fullscreen { grid-template-columns: minmax(0, 1fr); align-content: start; justify-content: stretch; overflow: auto; }
#panel-sea:fullscreen .sea-grid, #panel-sea:fullscreen .sea-head { max-width: min(34rem, calc(100vh - 12rem)); }
.game-fs-exit { position: absolute; top: 1rem; right: 1rem; z-index: 5; }

/* Race: the main menu over the track */
.race-menu { position: absolute; inset: 0; z-index: 3; overflow: auto; overscroll-behavior: contain; padding: 1.1rem 1rem 1.3rem; color: #F6F3EC; background: linear-gradient(180deg, rgba(10, 15, 43, 0.93), rgba(6, 11, 29, 0.97)); border-radius: var(--r-l); }
.race-menu[hidden] { display: none; }
.rm-inner { display: grid; gap: 0.75rem; max-width: 23rem; margin: 0 auto; }
.rm-title { margin: 0; text-align: center; font: 800 2.2rem/1 var(--display); letter-spacing: -0.03em; color: #FFC906; }
.rm-sub { margin: 0 0 0.2rem; text-align: center; font-weight: 700; font-size: 0.9rem; line-height: 1.35; color: #C4C0DE; }
.rm-settings { display: grid; gap: 0.75rem; }
.race-menu .rs-row { display: grid; gap: 0.3rem; }
.race-menu .rs-row[hidden] { display: none; }
.race-menu .rs-label, .race-menu .race-online label, .race-menu .hint { color: #F6F3EC; }
.race-menu .chips { width: 100%; }
.race-menu .chips button { flex: 1 1 0; min-height: 40px; padding: 0 0.4rem; font-size: 0.92rem; }
.race-menu .race-online { max-width: none; }
.rm-go { min-height: 58px; margin-top: 0.3rem; font-size: 1.2rem; }
.rm-go[hidden] { display: none; }
