/* puzzle.css - Watershed, everything that is not the board itself
   Ryan Thompson <i@ry.ca> 2026

   The board is painted on a canvas by the game (public/puzzle/). This
   file dresses the
   room it sits in: the toolbar, the rules panel, the messages and the
   banner. The look is meant to read as a brass-and-lacquer instrument
   rather than a terminal: serif throughout, controls that sit up off
   their surface and press in when used, and a deep blue-slate ground
   the animated water shows through.

   Five numbers are published from public/puzzle/ as custom properties on
   the
   body and must be read, never assumed:

     --pw   width the board keeps clear on the left: the sidebar on a
            wide window, the toolbar's own rail on a phone held sideways
     --bh   height the board keeps clear at the top, which is the
            toolbar's measured height and 0 when it is a rail
     --pr   width kept clear on the right for the play rail
     --pb   height kept clear at the foot for the play bar
     --sb   height kept clear at the foot for the status band, above the
            play bar (or the screen edge on a wide window)

   The five together are the space the board was actually given, so
   anything that wants to sit over the middle of the board reads all of
   them rather than assuming the window.
*/

:root {
    --pw: 312px;
    --bh: 52px;
    --pr: 0px;
    --pb: 0px;
    --sb: 34px;
    --vinset: 0px;
    --panel-x: 312px;        /* the sidebar's own edge, which is where the
                                tab rides; not what the board keeps clear */

    --tap: 44px;             /* smallest thing a thumb should have to hit */
}

body.nopanel { --pw: 0px; --panel-x: 0px; }

html, body {
    margin: 0; padding: 0; height: 100%;
    background: var(--bg); color: var(--text);
    overflow: hidden;
    font: 13.5px/1.55 var(--font);
    -webkit-font-smoothing: antialiased;
}

/* The animated water sits at the very back, the board floats over it on
   a canvas that paints no ground of its own. */

#waves {
    position: fixed; inset: 0; z-index: 0;
    pointer-events: none; overflow: hidden;
}

#board {
    position: fixed; inset: 0; z-index: 1;
    display: block; width: 100vw; height: 100dvh;

    /* the board handles its own fingers: no panning, no double-tap zoom,
       and no press-and-hold selection over the top of a long press */
    touch-action: none;
    -webkit-user-select: none; user-select: none;
    -webkit-touch-callout: none;
}

/* The sprite layer sits at the same box as #board, one z-index above
   it so a themed image always shows over the canvas fallback it
   replaces, and below every piece of chrome (z-index 2 and up). It
   never receives a pointer event: the canvas underneath still does
   all of the game's picking. */
#sprites {
    position: fixed; inset: 0; z-index: 1;
    pointer-events: none; overflow: hidden;
}

/* A themed node with no -bad sprite still has to read as a mistake: a
   circular ring in the mistake colour, at the node's own radius, drawn
   by the overlay layer the same way the canvas painter would. */
#sprites img.sprite-bad {
    border-radius: 50%;
    box-shadow: 0 0 0 2.4px var(--bad);
}

/* The pause veil. It only ever sits over the board and the sprite layer,
   never the chrome, and it only blocks input while the timer is paused
   (body.paused). The blur reads as "the board is hidden", and the quick
   opacity fade is the whole animation between the two states. */
#veil {
    position: fixed; inset: 0; z-index: 2;
    pointer-events: none;
    background: rgba(8, 13, 18, 0.82);
    backdrop-filter: blur(48px) saturate(0.2);
    -webkit-backdrop-filter: blur(48px) saturate(0.2);
    opacity: 0;
    transition: opacity .4s ease;
}
body.paused #veil {
    pointer-events: auto;
    opacity: 1;
}

/* Controls

   Every control is the same object: a slab lifted off the surface by a
   pale top lip and a shadow beneath, which presses in when you use it.
   What varies between them is one custom property, --c, the colour it
   answers in. */

.tb {
    --c: var(--text);
    font: 500 13px/1 var(--font);
    letter-spacing: .015em;
    color: var(--c);
    background: linear-gradient(180deg,
                rgba(58, 78, 95, 0.55), rgba(28, 40, 51, 0.72));
    border: 1px solid var(--edge);
    border-top-color: rgba(255, 255, 255, 0.13);
    border-radius: 5px;
    padding: 7px 13px 8px;
    cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
    white-space: nowrap;
    box-shadow: 0 1px 0 var(--lip) inset, 0 1px 2px var(--well);
    transition: color .12s, border-color .12s, background .12s,
                box-shadow .12s, transform .06s;
}

.tb:hover:not(:disabled) {
    border-color: var(--c);
    filter: brightness(1.18);
    box-shadow: 0 1px 0 var(--lip) inset, 0 1px 2px var(--well),
                0 0 11px -2px var(--c);
}

.tb:active:not(:disabled) {
    transform: translateY(1px);
    background: linear-gradient(180deg,
                rgba(14, 22, 32, 0.85), rgba(36, 51, 63, 0.6));
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4) inset;
}

.tb:disabled { opacity: .3; cursor: default; box-shadow: none; }

.tb:focus-visible { outline: 2px solid var(--c); outline-offset: 2px; }

/* Toolbar */

/* The toolbar's own surface is a layer behind it rather than a background
   on it. A backdrop-filter makes an element the containing block for its
   fixed-position descendants, and the two groups inside the bar dock
   themselves to the edges of the screen on a phone: left as a background
   here, the blur would anchor the bottom bar to the bottom of the
   toolbar. The pseudo-element has no descendants to trap. */

#bar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 4;
    display: flex; flex-wrap: wrap; align-items: center; gap: 7px;
    box-sizing: border-box; padding: 9px 16px 10px;
}

/* Note that #bar establishes a stacking context, so every z-index below
   on something inside it -- the sheet, the docked controls, this layer --
   is scoped to the toolbar and cannot be compared with #pin or #banner.
   The whole subtree paints as one layer, at 4. */

#bar::before {
    content: ''; position: absolute; inset: 0; z-index: -1;
    background:
        linear-gradient(180deg, rgba(45, 62, 77, 0.5), rgba(19, 28, 37, 0)),
        var(--surface-veil);
    border-bottom: 1px solid var(--deep);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset,
                0 3px 14px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(9px);
}

#bar .lbl {
    color: var(--muted);
    font-size: 10.5px; font-style: italic;
    letter-spacing: .1em; text-transform: uppercase;
    padding-right: 1px;
}

#bar .sep {
    width: 1px; align-self: stretch; margin: 2px 7px;
    background: linear-gradient(180deg,
                transparent, var(--edge) 22%, var(--edge) 78%, transparent);
}

/* The tiers read as one dial with one lit position rather than loose
   buttons, so which one you are on is a matter of where the light is
   rather than of reading all the labels. .seg is the same dial anywhere
   else it is wanted, such as the Touch | Mouse switch in the rules. */

#diffs, .seg { display: flex; }

#diffs .tb, .seg .tb {
    border-radius: 0;
    border-left-width: 0;
    padding: 7px 15px 8px;
    color: var(--muted);
    box-shadow: 0 1px 0 var(--lip) inset;
}
#diffs .tb:first-child, .seg .tb:first-child {
    border-left-width: 1px;
    border-radius: 5px 0 0 5px;
}
#diffs .tb:last-child,
.seg .tb:last-child  { border-radius: 0 5px 5px 0; }

#diffs .tb:hover, .seg .tb:hover { color: var(--c); }
#diffs .tb.on, .seg .tb.on {
    color: var(--c);
    background: linear-gradient(180deg,
                rgba(14, 22, 32, 0.9), rgba(28, 40, 51, 0.55));
    border-color: var(--c);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45) inset,
                0 0 10px -3px var(--c);
}
/* a lit segment owns the divider on both of its sides */
#diffs .tb.on + .tb, .seg .tb.on + .tb { border-left: 1px solid var(--c); }

#d-easy { --c: var(--v3); }
#d-med  { --c: var(--v5); }
#d-hard { --c: var(--v6); }
#d-diab { --c: var(--bad); }
#go     { --c: var(--accent); }
#copy   { --c: var(--accent); padding: 6px 8px; }
#copy svg {
    width: 14px; height: 14px;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
}
#undo,
#redo   { --c: var(--accent); padding: 6px 9px; }
#reset  { --c: var(--v2); }
#hint   { --c: var(--warn); }
#solve  { --c: var(--v1); }

#full   { --c: var(--muted); padding: 6px 9px; }

#undo svg, #redo svg, #full svg, #shut svg {
    display: block; width: 15px; height: 15px;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
}

/* The two arrow sets are the same button; which one shows says which way
   the button goes from here. */
#full .ico-out,
body.full #full .ico-in { display: none; }
body.full #full .ico-out { display: block; }

/* The groups. On a wide window they are two runs of controls in the bar,
   each opened by the same hairline the loose controls use. */

#setup, #dock, #setup .grp {
    display: flex; flex-wrap: wrap; align-items: center; gap: 7px;
}

#setup::before, #dock::before {
    content: ''; width: 1px; align-self: stretch; margin: 2px 7px 2px 0;
    background: linear-gradient(180deg,
                transparent, var(--edge) 22%, var(--edge) 78%, transparent);
}

#newbtn { display: none; }         /* the sheet is a phone idea */
#newbtn .caret {
    width: 0; height: 0; margin-left: 1px;
    border: 4px solid transparent; border-top-color: currentColor;
    border-bottom: none;
}

/* Fullscreen sits where a video player puts it, in the bottom right
   corner, rather than in the row with the rest. */
#full {
    position: fixed; right: 18px; bottom: 18px; z-index: 4;
}

/* The seed is a code, so it gets the one monospace face on the page and
   a recessed well to sit in, the opposite treatment to the raised slabs
   either side of it. */

#seed {
    font: 12px var(--font-code);
    width: 116px; letter-spacing: .1em;
    color: var(--accent);
    background: rgba(8, 14, 20, 0.8);
    border: 1px solid var(--deep);
    border-radius: 4px;
    padding: 7px 9px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45) inset,
                0 1px 0 rgba(255, 255, 255, 0.05);
}
#seed::placeholder { color: var(--muted); letter-spacing: normal; }
#seed:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45) inset,
                0 0 9px -2px var(--accent);
}

/* Sidebar */

#panel {
    position: fixed; top: var(--bh); left: 0; bottom: 0; width: 312px;
    z-index: 3;
    box-sizing: border-box; padding: 20px 20px 28px;
    background: var(--surface-veil);
    border-right: 1px solid var(--deep);
    box-shadow: 3px 0 14px rgba(0, 0, 0, 0.34);
    backdrop-filter: blur(9px);
    overflow-y: auto;
    transition: transform .22s ease;
    scrollbar-width: thin;
    scrollbar-color: var(--edge) transparent;
}
body.nopanel #panel { transform: translateX(-100%); }

#panel::-webkit-scrollbar { width: 9px; }
#panel::-webkit-scrollbar-track { background: transparent; }
#panel::-webkit-scrollbar-thumb {
    background: var(--edge); border-radius: 5px;
    border: 2px solid transparent; background-clip: content-box;
}
#panel::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }

#shut, #quiet { display: none; }

/* only shown where there is no fullscreen to be had, which the game
   works out and nothing else can */
#home {
    display: none;
    margin-top: 26px;
    font-size: 12.5px; font-style: italic; line-height: 1.6;
    color: var(--muted);
}

#panel h1 {
    margin: 0 0 2px;
    font: 400 25px/1.1 var(--font);
    letter-spacing: .04em;
    color: var(--text);
}
#panel h1 + p {
    margin: 0 0 20px;
    font-style: italic; font-size: 13.5px;
    color: var(--muted);
}

/* A heading is a small italic word with a rule running off it to the
   margin, which is how a chart legend is titled. */
#panel h2 {
    display: flex; align-items: center; gap: 10px;
    margin: 0 0 12px;
    font: italic 400 13px/1 var(--font);
    letter-spacing: .1em;
    color: var(--accent);
}
#panel h2::after {
    content: ''; flex: 1; height: 1px;
    background: linear-gradient(90deg, var(--edge), transparent);
}

#legend {
    display: grid; grid-template-columns: 46px 1fr;
    gap: 14px 12px; align-items: center;
}
#legend div { font-size: 13px; line-height: 1.5; color: var(--text); }
#legend b { color: var(--accent); font-weight: 600; }
#legend b.bad { color: var(--bad); }
#legend canvas { display: block; }

/* One themed <img> can sit over a legend canvas without touching the
   grid: the wrapper takes the canvas's own size and stacking context,
   the image inside it is placed by syncLegendSprites() in
   13-paint.js. */
.ico-cell { position: relative; }

/* Anything after the legend is a second section and needs air above it;
   the first heading sits at the top of the panel and does not. */
#panel h2:not(:first-of-type) { margin-top: 26px; }

.keys {
    font-size: 13px; line-height: 1.6;
    color: var(--muted);
}
.keys[hidden] { display: none; }

/* Touch | Mouse sits on the heading's own line, between the word and the
   rule, and is smaller than the toolbar's dial so the line stays a
   heading. */
#ctl .tb {
    --c: var(--accent);
    padding: 4px 10px 5px; font-size: 12px;
}

/* The privacy policy folds away behind its own heading, which wears the
   section-heading face with a chevron that turns down when it opens. */
#privacy summary {
    display: inline-flex; align-items: center; gap: 8px;
    font: italic 400 13px/1 var(--font);
    letter-spacing: .1em;
    color: var(--accent);
    cursor: pointer;
    list-style: none;
}
#privacy summary::-webkit-details-marker { display: none; }
#privacy summary::after {
    content: ''; width: 5px; height: 5px;
    border: solid currentColor; border-width: 0 1.5px 1.5px 0;
    transform: translateX(-1px) rotate(-45deg);
    transition: transform .15s ease;
}
#privacy[open] summary::after { transform: translateY(-2px) rotate(45deg); }
#privacy summary:hover { filter: brightness(1.25); }
#privacy summary:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 3px;
}
#privacy .fineprint { margin-top: 10px; }

/* The tab that puts the rules away and brings them back. It rides the
   panel's own edge, so it is always exactly where the panel just was. */

#pin {
    position: fixed; top: calc(var(--bh) + 14px);
    left: var(--panel-x); z-index: 5;
    display: flex; align-items: center; justify-content: center;
    width: 21px; height: 40px; padding: 0;
    color: var(--muted);
    background: var(--surface-veil);
    border: 1px solid var(--deep); border-left: none;
    border-radius: 0 7px 7px 0;
    box-shadow: 3px 0 10px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(9px);
    cursor: pointer;
    transition: left .22s ease, color .14s, border-color .14s;
}
#pin:hover { color: var(--accent); border-color: var(--accent); }
#pin svg {
    width: 13px; height: 13px;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
    transition: transform .22s ease;
}
body.nopanel #pin svg { transform: rotate(180deg); }

/* What the board has to say */

#status {
    position: fixed; left: var(--pw); right: var(--pr); z-index: 2;
    bottom: calc(var(--vinset) + var(--pb));
    height: var(--sb);
    box-sizing: border-box;
    display: flex; align-items: flex-end; justify-content: center;
    gap: 8px;
    padding: 0 76px 4px;   /* clear of the corner button; lift off the dock */
    text-align: center; pointer-events: none;
    transition: left .22s ease;
}
#alert, #msg { font-size: 16px; line-height: 1.5; }
#alert { color: var(--bad); }
#msg   { color: var(--warn); font-style: italic; }
/* the fallback when the clipboard is out of reach: the link itself, in a
   colour that says it is one */
#msg a { color: var(--accent); font-style: normal; word-break: break-all; }

/* the stopwatch that sits in the message line while nothing needs to say
   something; a hint or a mistake takes the line over */
#timer {
    font: 600 22px/1 var(--font-code);
    letter-spacing: .05em;
    color: #fff;
    white-space: nowrap;
}
#timer[hidden] { display: none; }

/* the reading turns red while paused, the one cue that the clock is
   stopped rather than simply idle */
body.paused #timer { color: var(--bad); }

/* The pause/resume button that sits beside the timer. It is a button in a
   pointer-events:none band, so it claims its own clicks; its two faces are
   the pause bars and the play triangle, swapped by body.paused. */
#pause {
    pointer-events: auto; cursor: pointer;
    flex: 0 0 auto;
    width: 28px; height: 28px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff;
    background: rgba(58, 78, 95, 0.35);
    border: 1px solid var(--edge);
    border-radius: 50%;
}
#pause:hover { color: var(--accent); border-color: var(--accent); }
#pause svg { width: 13px; height: 13px; fill: currentColor; }
#pause .ico-play  { display: none; }
body.paused #pause .ico-pause { display: none; }
body.paused #pause .ico-play  { display: inline; }
#pause[hidden] { display: none; }

/* the [?] that opens the fuller explanation beside the status line */
#more {
    pointer-events: auto; cursor: pointer;
    flex: 0 0 auto;
    width: 28px; height: 28px; padding: 0;
    font: 600 14px/1 var(--font);
    color: var(--muted);
    background: rgba(58, 78, 95, 0.35);
    border: 1px solid var(--edge);
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
}
#more:hover { color: var(--accent); border-color: var(--accent); }
#more[hidden] { display: none; }

/* the expanded explanation grows upward over the board, so it needs a
   ground to stay readable */
body.expanded #msg:not(:empty), body.expanded #alert:not(:empty) {
    background: rgba(16, 25, 34, 0.94);
    border: 1px solid var(--edge);
    border-radius: 6px;
    padding: 4px 10px;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
}

/* The banner, which arrives once the water runs */

#banner {
    position: fixed;
    left: calc(var(--pw) + (100vw - var(--pw) - var(--pr)) / 2);
    top: calc(var(--bh) + (100dvh - var(--bh) - var(--pb) - var(--sb)) / 2);
    transform: translate(-50%, -50%) scale(.94); z-index: 6;
    box-sizing: border-box; min-width: 290px;
    padding: 26px 34px 24px; text-align: center;
    /* the one panel that is not glass: a board showing through the words
       that tell you the board is finished is the wrong kind of clever */
    background:
        linear-gradient(180deg, rgba(48, 66, 82, 0.5), rgba(20, 30, 40, 0)),
        #10192240;
    background-color: #101922;
    backdrop-filter: blur(4px);
    border: 1px solid var(--edge);
    border-top-color: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    box-shadow: 0 1px 0 var(--lip) inset,
                0 18px 50px rgba(0, 0, 0, 0.6),
                0 0 60px -12px var(--accent);
    opacity: 0; pointer-events: none;
    transition: opacity .35s, transform .35s;
}
#banner.on {
    opacity: 1; transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}
#btitle {
    font: 400 21px/1.2 var(--font);
    letter-spacing: .13em; color: var(--accent);
}
#bsub {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 9px 0 18px;
    font: 11.5px var(--font-code);
    letter-spacing: .04em; color: var(--muted);
}
/* the completion readout: time and hint count. Absent on a shown
   solution, so the line is hidden rather than left empty. */
#bstats {
    margin: -6px 0 16px;
    font: 11.5px var(--font-code);
    letter-spacing: .06em; color: var(--muted);
}
#bstats[hidden] { display: none; }
/* the seed and the time are the values that matter, so they get the
   page's brightest text while their labels stay quiet */
#bseed .val, #bstats .val { color: #fff; }
/* the share button sits on the puzzle number it copies a link to */
#bshare {
    display: inline-flex; align-items: center;
    margin-left: 6px; padding: 2px;
    color: var(--muted);
    background: none; border: none; cursor: pointer;
    vertical-align: middle;
}
#bshare:hover { color: var(--accent); }
#bshare svg {
    width: 13px; height: 13px;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
}
#banner .row { display: flex; gap: 8px; }
#banner .row > * { flex: 1; justify-content: center; }
#bclose {
    position: absolute; top: 10px; right: 10px;
    display: flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; padding: 0;
    color: var(--muted);
    background: none; border: none; cursor: pointer;
}
#bclose:hover { color: var(--accent); }
#bclose svg {
    width: 15px; height: 15px;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round;
}
/* The board's fitted difficulty, as a compact pill: the unclamped rating
   and the tier's letter, coloured by tier. Quiet by design -- a fact about
   the puzzle, not a score the player is being held to. */
.pill {
    display: inline-block;
    padding: 1px 8px;
    border: 1px solid transparent;
    border-radius: 999px;
    font: 11.5px var(--font-code);
    letter-spacing: .06em;
    color: var(--muted);
    white-space: nowrap;
}
.pill.t-easy       { color: #6ed07d; background: rgba(110,208,125,.14); border-color: rgba(110,208,125,.35); }
.pill.t-medium     { color: #f2c14e; background: rgba(242,193, 78,.14); border-color: rgba(242,193, 78,.35); }
.pill.t-hard       { color: #f08a4b; background: rgba(240,138, 75,.14); border-color: rgba(240,138, 75,.35); }
.pill.t-diabolical { color: #e5564b; background: rgba(229, 86, 75,.16); border-color: rgba(229, 86, 75,.45); }

#who {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    overflow: visible;
}
#who:empty { display: none; }
#who:empty ~ #rating { margin-left: auto; }
.who-link {
    display: inline-flex; align-items: center; gap: 4px;
    color: inherit; text-decoration: none;
}
.who-link:hover .who-name { text-decoration: underline; }
.who-name {
    max-width: 8em; overflow: hidden; text-overflow: ellipsis;
}
.who-login {
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
}
.who-login:hover { text-decoration: underline; }
.who-avatar {
    width: 12px; height: 12px; display: block; border-radius: 50%;
}
.who-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.who-icon > img { width: 12px; height: 12px; display: block; }
.who-chip {
    display: none;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    align-items: center;
    gap: 6px;
    padding: 4px 8px 4px 4px;
    background: var(--raise);
    border: 1px solid var(--edge);
    border-radius: 6px;
    z-index: 5;
    pointer-events: none;
    color: var(--text);
    font: 11.5px var(--font);
    letter-spacing: 0;
    white-space: nowrap;
}
.who-chip img { width: 32px; height: 32px; display: block; }
.who-icon:hover .who-chip { display: inline-flex; }

/* The toolbar portrait's minimal profile preview (issue #48): the log
   viewer's user-chip layout, but only the avatar, the name, and the
   caller's own last_login. Shown on #who hover; the click target is the
   badge's own /u/<name> link. */
#who { position: relative; }
.who-profile-chip {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--raise);
    border: 1px solid var(--edge);
    border-radius: 6px;
    z-index: 6;
    pointer-events: none;
    color: var(--text);
    font: 13px var(--font);
    letter-spacing: 0;
    white-space: nowrap;
    box-shadow: 0 1px 0 var(--lip) inset, 0 4px 14px var(--well);
}
#who:hover .who-profile-chip { display: flex; }
.who-profile-chip-avatar {
    display: block;
    width: auto;
    height: auto;
    max-width: 40px;
    max-height: 40px;
}
.who-profile-chip-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.who-profile-chip-name {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 15px;
    font-weight: 600;
}
.who-profile-chip-fields {
    display: grid;
    grid-template-columns: auto auto;
    gap: 2px 10px;
    margin: 0;
}
.who-profile-chip-fields dt {
    margin: 0;
    color: var(--muted);
    font-style: italic;
    letter-spacing: .08em;
    text-transform: uppercase;
    font-size: 10px;
}
.who-profile-chip-fields dd {
    margin: 0;
}

#rating {
    min-width: 2.4em; text-align: center;
}

#bagain { --c: var(--v2); }
#bnew   { --c: var(--accent); }
#bdismiss {
    --c: var(--muted);
    width: 100%; margin-top: 8px; justify-content: center;
}

/* Options screen

   The settings cog sits at the top right and opens a small panel,
   like the win banner, over the middle of the board. */

#opts { --c: var(--muted); padding: 6px 9px; }
#opts svg {
    display: block; width: 15px; height: 15px;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
}

#options {
    position: fixed; z-index: 6;
    left: calc(var(--pw) + (100vw - var(--pw) - var(--pr)) / 2);
    top: calc(var(--bh) + (100dvh - var(--bh) - var(--pb) - var(--sb)) / 2);
    transform: translate(-50%, -50%) scale(.96);
    box-sizing: border-box; width: 300px;
    max-width: calc(100vw - var(--pw) - var(--pr) - 32px);
    padding: 20px 22px 16px;
    background:
        linear-gradient(180deg, rgba(48, 66, 82, 0.5), rgba(20, 30, 40, 0)),
        #10192240;
    background-color: #101922;
    backdrop-filter: blur(4px);
    border: 1px solid var(--edge);
    border-top-color: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    box-shadow: 0 1px 0 var(--lip) inset,
                0 18px 50px rgba(0, 0, 0, 0.6),
                0 0 60px -12px var(--accent);
    opacity: 0; pointer-events: none;
    transition: opacity .3s, transform .3s;
}
#options.on {
    opacity: 1; transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

#options h2 {
    margin: 0 0 14px;
    font: 400 17px/1.2 var(--font);
    letter-spacing: .12em; color: var(--accent);
    text-align: center;
}

#opts-shut {
    position: absolute; top: 11px; right: 11px;
    display: flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; padding: 0;
    color: var(--muted);
    background: none; border: none; cursor: pointer;
}
#opts-shut:hover { color: var(--accent); }
#opts-shut svg {
    width: 15px; height: 15px;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round;
}

.opt {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin: 0 0 12px;
    font: 13.5px/1.4 var(--font); color: var(--muted);
}
.opt[hidden] { display: none; }
.opt > span { color: var(--text); }
.opt a { color: var(--accent); text-decoration: none; }
.opt a:hover { text-decoration: underline; }
#logout.off { display: none; }

/* The binary Options controls are proper switches: the track is the
   button (role="switch"), the knob is its ::after, and it slides right
   and lights jade when on. The track keeps the recessed-well look the
   seed field has, so a switch reads as a thing you flick rather than a
   thing you press. */
.sw {
    --c: var(--accent);
    appearance: none; -webkit-appearance: none;
    position: relative;
    flex: 0 0 auto;
    box-sizing: border-box;
    width: 46px; height: 26px;
    padding: 0;
    border: 1px solid var(--edge);
    border-radius: 999px;
    background: rgba(8, 14, 20, 0.8);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45) inset,
                0 1px 0 rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: border-color .16s ease, box-shadow .16s ease;
}
.sw::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--muted);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5),
                0 1px 0 var(--lip) inset;
    transition: left .18s ease, background .18s ease, box-shadow .18s ease;
}
.sw:hover { border-color: var(--c); }
.sw:active { box-shadow: 0 3px 7px rgba(0, 0, 0, 0.55) inset; }
.sw.on {
    border-color: var(--c);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45) inset,
                0 0 11px -3px var(--c);
}
.sw.on::after {
    left: 23px;
    background: var(--c);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5),
                0 0 9px -1px var(--c);
}
.sw:focus-visible {
    outline: 2px solid var(--c);
    outline-offset: 2px;
}

#volume { flex: 1; accent-color: var(--accent); }

#vollabel {
    display: block; margin: -6px 0 14px; text-align: right;
    font: 11.5px var(--font-code); letter-spacing: .06em;
    color: var(--muted);
}
#vollabel.muted { color: var(--warn); }

.opt.credit, .opt.credit a {
    color: var(--muted); font-size: 12.5px;
}
/* Google's fine print stands in for the reCAPTCHA badge, which would
   float over the board on a phone; the page shows it once the script has
   actually loaded. */
.opt-note, .opt-note a {
    font: 11.5px/1.5 var(--font); color: var(--muted);
    margin: 0 0 12px;
}
.grecaptcha-badge { visibility: hidden; }

/* Instructions footer: the fine print sits under a low-contrast rule at
   the bottom of the rules panel. */
hr.fine {
    border: 0; border-top: 1px solid var(--edge);
    margin: 26px 0 14px;
}
.fineprint {
    font-size: 12px; line-height: 1.6; color: var(--muted);
    margin: 0 0 12px;
}
.copyright {
    font-size: 11.5px; color: var(--muted);
    opacity: .8; margin: 0;
}


/* The phone

   Below 820px the room is rearranged rather than shrunk. The rules stop
   being a sidebar and take the whole screen. The toolbar keeps two
   buttons and the rating, and hands its setup controls to a sheet that
   hangs below it. The three controls used while solving dock where a
   thumb already is: along the foot in portrait, and down the right hand
   margin when the phone is turned on its side, where a 1.35:1 board in a
   2:1 window leaves the margins empty anyway.

   A phone on its side is 844 across and 390 down, which is wide by the
   first number and nowhere near tall enough for a sidebar and a wrapping
   toolbar, so a short window comes here too.

   820 and 560 are WIDE_MIN and SHORT_MAX in public/puzzle/, and all four
   must
   agree: the stylesheet decides what the chrome looks like, and the
   script measures what it took and hands the rest to the board. */

@media (max-width: 819px), (max-height: 560px) {

    /* the rules are an overlay now, so they reserve nothing */
    body, body.nopanel { --pw: 0px; --panel-x: 0px; }

    /* a control has to be worth aiming a thumb at */
    .tb {
        min-height: var(--tap);
        padding: 10px 15px; font-size: 14px;
    }
    #diffs .tb { padding: 10px 12px; }
    #ctl .tb { padding: 10px 14px; font-size: 14px; }
    #undo, #redo, #full, #opts { padding: 10px 13px; }
    #undo svg, #redo svg, #full svg, #opts svg { width: 18px; height: 18px; }

    #bar {
        flex-wrap: nowrap; gap: 8px;
        padding: 7px 12px 8px;
        padding-left:  max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
        padding-top:   max(7px,  env(safe-area-inset-top));
    }

    #newbtn { display: inline-flex; }
    #setup::before, #dock::before { display: none; }

    /* The sheet hangs from the toolbar rather than growing it, so the
       board keeps the height it was given while the sheet is open. */
    #setup {
        position: fixed; top: var(--bh); left: 0; right: 0; z-index: 4;
        flex-direction: column; align-items: stretch;
        flex-wrap: nowrap; gap: 14px;
        box-sizing: border-box; padding: 16px;
        padding-left:  max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
        background: var(--surface-veil);
        border-bottom: 1px solid var(--deep);
        box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
        backdrop-filter: blur(9px);
        opacity: 0; transform: translateY(-8px); pointer-events: none;
        transition: opacity .16s ease, transform .16s ease;
    }
    body.sheet #setup {
        opacity: 1; transform: none; pointer-events: auto;
    }

    #setup .sep { display: none; }
    #setup .grp { flex-wrap: nowrap; }
    #setup .lbl { width: 4.6em; }
    #diffs, #seed { flex: 1; }
    #diffs .tb, #reset, #solve { flex: 1; justify-content: center; }
    #seed {
        width: auto; min-width: 0;
        box-sizing: border-box; min-height: var(--tap);
    }

    /* The play controls along the foot, floated like the bar: undo, redo
       and hint on the left, fullscreen on the right. */
    #dock {
        position: fixed; left: 0; right: 0; bottom: var(--vinset); z-index: 4;
        flex-wrap: nowrap; gap: 8px;
        justify-content: flex-start; align-items: center;
        box-sizing: border-box; padding: 8px 10px;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        background:
            linear-gradient(0deg, rgba(45, 62, 77, 0.5),
                                  rgba(19, 28, 37, 0)),
            var(--surface-veil);
        border-top: 1px solid var(--deep);
        box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.05) inset,
                    0 -3px 14px rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(9px);
    }

    /* it rides at the right end of the dock down here, not in the corner
       of the board */
    #full { position: static; right: auto; bottom: auto; margin-left: auto; }

    /* The rules, over everything, edge to edge. */
    #panel {
        top: 0; left: 0; right: 0; bottom: 0; width: auto; z-index: 7;
        padding: 22px 20px 32px;
        padding-top:    max(22px, env(safe-area-inset-top));
        padding-bottom: max(32px, env(safe-area-inset-bottom));
        padding-left:   max(20px, env(safe-area-inset-left));
        padding-right:  max(20px, env(safe-area-inset-right));
        border-right: none;
        transform: none;
        /* This is the one surface that scrolls, and a live blur behind it
           re-samples the moving water every frame -- the phone drops
           frames and the scroll stutters. Opaque here, so it scrolls
           cleanly. */
        backdrop-filter: none;
        background: var(--surface);
    }
    body.nopanel #panel { transform: translateY(101%); }

    #pin { display: none; }

    /* An absolutely positioned child is laid out against the padding
       box, whose top edge is the panel's own, so the panel's inset
       padding does not move this: it has to clear the notch itself. */
    #shut {
        display: flex; align-items: center; justify-content: center;
        position: absolute;
        top:   max(14px, env(safe-area-inset-top));
        right: max(14px, env(safe-area-inset-right));
        width: var(--tap); height: var(--tap); padding: 0;
        color: var(--muted);
        background: none; border: none; cursor: pointer;
    }
    #shut:hover { color: var(--accent); }
    #panel h1 { padding-right: var(--tap); }

    #quiet { display: block; margin-top: 30px; }
    #quiet .tb { width: 100%; justify-content: center; --c: var(--muted); }

    #status { padding: 0 18px 4px; }
    #banner {
        max-width: calc(100vw - var(--pw) - var(--pr) - 32px);
    }
    #options {
        width: min(320px, calc(100vw - 32px));
        max-width: calc(100vw - var(--pw) - var(--pr) - 32px);
    }
}

/* Sideways. The bars become rails in the margins the board cannot use,
   so the whole height of the screen goes to the puzzle. */

@media (max-width: 819px) and (orientation: landscape),
       (max-height: 560px) and (orientation: landscape) {

    #bar {
        top: 0; bottom: 0; right: auto;
        flex-direction: column; align-items: stretch;
        justify-content: flex-start; gap: 8px;
        padding: 10px 10px;
        padding-top:    max(10px, env(safe-area-inset-top));
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        padding-left:   max(10px, env(safe-area-inset-left));
    }
    #bar::before {
        border-bottom: none; border-right: 1px solid var(--deep);
        box-shadow: 1px 0 0 rgba(255, 255, 255, 0.05) inset,
                    3px 0 14px rgba(0, 0, 0, 0.4);
    }

    #rules, #newbtn { padding: 10px 11px; }
    #rules, #newbtn, #hint { justify-content: center; }
    #newbtn { order: 1; }
    #rating { order: 2; margin: 0; }
    #rules  { order: 3; margin-top: auto; }

    #setup {
        top: 0; left: var(--pw); right: auto; width: 300px;
        max-width: calc(100vw - var(--pw) - 20px);
        border-bottom: none; border-right: 1px solid var(--deep);
        border-radius: 0 0 10px 0;
        transform: translateX(-8px);       /* it slides out sideways here */
    }

    /* The two ribbons. Settings and hint each live in the other ribbon's
       markup, so they are pinned with fixed in this orientation: settings
       above undo and redo, hint under the rating on the left. #dock
       drops its blur so hint is not trapped by it. */
    #dock {
        top: 0; bottom: 0; left: auto; right: 0;
        flex-direction: column; justify-content: flex-start;
        gap: 8px;
        padding: calc(10px + var(--tap) + 8px) 10px 10px;
        padding-right: max(10px, env(safe-area-inset-right));
        border-top: none; border-left: 1px solid var(--deep);
        box-shadow: -1px 0 0 rgba(255, 255, 255, 0.05) inset,
                    -3px 0 14px rgba(0, 0, 0, 0.4);
        backdrop-filter: none;
    }

    #full { margin-left: 0; margin-top: auto; }
    #opts {
        position: fixed; z-index: 5;
        top: 10px;
        right: max(10px, env(safe-area-inset-right));
        width: calc(var(--pr) - max(10px, env(safe-area-inset-right)) - 10px);
        box-sizing: border-box;
        justify-content: center;
    }
    #hint {
        position: fixed; z-index: 5;
        top: calc(10px + var(--tap) + 32px);
        left: max(10px, env(safe-area-inset-left));
        width: calc(var(--pw) - max(10px, env(safe-area-inset-left)) - 10px);
        box-sizing: border-box;
        padding: 10px 9px;
    }
}

/* Sign-in page (template/login.tt). No toolbar, no board. */

body.login {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    min-height: 100dvh; margin: 0;
    background: var(--bg); color: var(--text); font-family: var(--font);
}
.login-card {
    width: 320px; max-width: calc(100vw - 32px);
    padding: 28px 26px 22px;
    background: var(--surface-veil);
    border: 1px solid var(--deep); border-radius: 10px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}
.login-card h1 {
    margin: 0 0 18px; font-size: 22px; font-weight: 600;
    color: var(--text);
}
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-field { display: flex; flex-direction: column; gap: 5px; }
.login-field span {
    color: var(--muted); font-size: 10.5px; font-style: italic;
    letter-spacing: .1em; text-transform: uppercase;
}
.login-field input {
    font: 14px var(--font);
    color: var(--text);
    background: rgba(8, 14, 20, 0.8);
    border: 1px solid var(--deep); border-radius: 4px;
    padding: 9px 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45) inset;
}
.login-field input:focus {
    outline: none; border-color: var(--accent);
}
.login-card button[type=submit] { margin-top: 6px; justify-content: center; }
.login-status {
    min-height: 1.4em; margin: 14px 0 0;
    color: var(--bad); font-size: 13px;
}
.login-signup {
    margin-top: 16px; text-align: center;
}
.login-signup p {
    margin: 0 0 10px; color: var(--muted); font-size: 14px;
}
.login-signup .tb {
    width: 100%; box-sizing: border-box;
    text-decoration: none; justify-content: center;
}
.login-intro {
    margin: 0 0 14px; color: var(--text); font-size: 14px; line-height: 1.5;
}
.login-field textarea {
    font: 14px var(--font);
    color: var(--text);
    background: rgba(8, 14, 20, 0.8);
    border: 1px solid var(--deep); border-radius: 4px;
    padding: 9px 10px; resize: vertical;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45) inset;
}
.login-field textarea:focus {
    outline: none; border-color: var(--accent);
}
.login-status.ok { color: var(--good, #2ecc71); }

/* Error pages (templates/not_found.html.ep, exception.html.ep) reuse the
   login card; the only extras are the missing path and the
   development-mode trace. */

.login-card a.tb { text-decoration: none; }
.login-card .error-path {
    font: 12.5px var(--font-code);
    color: var(--accent);
    word-break: break-all;
}
.login-card .error-trace {
    font: 12px/1.5 var(--font-code);
    color: var(--muted);
    text-align: left;
    white-space: pre-wrap;
    word-break: break-word;
    background: rgba(8, 14, 20, 0.8);
    border: 1px solid var(--deep);
    border-radius: 4px;
    padding: 10px 11px;
    margin: 0 0 14px;
}
.login-contact {
    margin-top: 16px;
}
.login-contact-note {
    margin: 0 0 12px; color: var(--muted); font-size: 13px; line-height: 1.5;
}

/* ---- Tutorial (issue #17) ---- */

/* The offer. A modal in the spirit of the banner: opaque enough to read,
   with three clearly labelled ways out. */
#tut-offer {
    position: fixed; z-index: 7;
    left: 50%; top: calc(var(--bh) + 40px);
    transform: translateX(-50%);
    width: min(430px, calc(100vw - 40px));
    box-sizing: border-box; padding: 22px 24px 20px; text-align: center;
    background:
        linear-gradient(180deg, rgba(48, 66, 82, 0.5), rgba(20, 30, 40, 0)),
        #101922;
    backdrop-filter: blur(4px);
    border: 1px solid var(--edge);
    border-top-color: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    box-shadow: 0 1px 0 var(--lip) inset, 0 18px 50px rgba(0, 0, 0, 0.6);
}
#tut-offer[hidden] { display: none; }
#tut-offer p { margin: 0 0 16px; font-size: 16px; line-height: 1.5; }
#tut-offer .row {
    display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
}
#tut-offer .row .tb { flex: 1 1 auto; justify-content: center; }
#tut-offer #tut-yes { --c: var(--accent); }

/* The run overlay floats above the board without eating its clicks: the
   player still plays on the canvas, which is the whole point of the
   input steps. Only the buttons reach for the pointer. */
#tut-run {
    position: fixed; inset: 0; z-index: 5;
    pointer-events: none;
}
#tut-run[hidden] { display: none; }
#tut-run > * { pointer-events: auto; }

#tut-close {
    position: absolute; top: calc(var(--bh) + 10px); right: 18px;
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; padding: 0;
    color: var(--muted);
    background: var(--surface-veil);
    border: 1px solid var(--edge); border-radius: 6px; cursor: pointer;
}
#tut-close:hover { color: var(--bad); border-color: var(--bad); }
#tut-close svg {
    width: 15px; height: 15px;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round;
}

/* The touch/mouse choice: two big animated panels. */
#tut-choice {
    position: absolute; left: 0; right: 0;
    top: calc(var(--bh) + 60px);
    bottom: calc(var(--vinset) + var(--pb) + var(--sb) + 120px);
    display: flex; gap: 18px; align-items: center; justify-content: center;
    padding: 8px 24px;
    overflow-y: auto;
}
#tut-choice[hidden] { display: none; }

.tut-mode {
    flex: 1 1 0; max-width: 420px; min-height: 210px;
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 16px;
    padding: 22px 18px 18px;
    color: var(--text);
    background:
        linear-gradient(180deg, rgba(48, 66, 82, 0.5), rgba(20, 30, 40, 0)),
        rgba(16, 25, 34, 0.55);
    backdrop-filter: blur(4px);
    border: 1px solid var(--edge);
    border-top-color: rgba(255, 255, 255, 0.15);
    border-radius: 12px; cursor: pointer;
    box-shadow: 0 1px 0 var(--lip) inset, 0 14px 36px rgba(0, 0, 0, 0.5);
    transition: border-color .15s, box-shadow .15s, transform .08s;
}
.tut-mode:hover { border-color: var(--accent); }
.tut-mode:active { transform: translateY(1px); }
.tm-label {
    font: 500 15px/1 var(--font); letter-spacing: .06em;
    color: var(--accent);
}

.tm-scene { position: relative; width: 200px; height: 90px; display: block; }
.tm-node {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 40px; height: 40px; border-radius: 50%;
    background: radial-gradient(circle at 34% 30%, #2c3f50, #0b1218);
    border: 1.8px solid #4a6076;
}
.tm-node.a { left: 12px; }
.tm-node.b { right: 12px; }
.tm-line {
    position: absolute; left: 52px; right: 52px; top: 50%; height: 0;
    border-top: 2px dashed rgba(160, 190, 214, 0.35);
}
.tm-cursor {
    position: absolute; left: 40px; top: 34px;
    width: 0; height: 0;
    border-left: 9px solid #fff;
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
    animation: tm-slide 1.9s ease-in-out infinite;
}
.tm-finger {
    position: absolute; left: 40px; top: 40px;
    width: 26px; height: 26px;
    border-radius: 50% 50% 50% 44%;
    background: radial-gradient(circle at 35% 30%, #f2c8a8, #d9a77e);
    border: 1px solid rgba(0, 0, 0, 0.25);
    animation: tm-slide 1.9s ease-in-out infinite;
}
@keyframes tm-slide {
    0%   { left: 40px; }
    45%  { left: 152px; }
    55%  { left: 152px; }
    100% { left: 40px; }
}

/* The callout arrows' little windows, placed over the board. */
#tut-callouts { position: absolute; inset: 0; pointer-events: none; }
.tut-callout {
    position: absolute; transform: translate(-50%, -50%);
    max-width: 240px; padding: 7px 11px;
    font-size: 13px; line-height: 1.45;
    color: var(--text);
    background: rgba(16, 25, 34, 0.92);
    border: 1px solid var(--edge);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5);
}

/* The instruction box and the Prev / Next navigation, docked above the
   status band. */
#tut-dock {
    position: absolute; left: 0; right: 0;
    bottom: calc(var(--vinset) + var(--pb) + var(--sb) + 8px);
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    padding: 0 16px;
    pointer-events: none;   /* only the nav buttons below reach out */
}
#tut-note {
    max-width: 560px; text-align: center;
    color: var(--muted); font-size: 12.5px; font-style: italic; line-height: 1.5;
}
#tut-note[hidden] { display: none; }
#tut-text {
    max-width: 640px; text-align: center;
    font-size: 16px; line-height: 1.5;
    color: var(--text);
    padding: 12px 18px;
    background: linear-gradient(180deg,
                rgba(58, 78, 95, 0.55), rgba(28, 40, 51, 0.72));
    border: 1px solid var(--edge);
    border-top-color: rgba(255, 255, 255, 0.13);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    box-shadow: 0 1px 0 var(--lip) inset, 0 8px 22px rgba(0, 0, 0, 0.5);
}
#tut-nav {
    display: flex; align-items: center; gap: 12px;
    pointer-events: auto;
}
#tut-nav #tut-count {
    min-width: 44px; text-align: center;
    font: 600 14px/1 var(--font-code);
    letter-spacing: .05em; color: var(--muted);
}
#tut-next[hidden] { display: none; }

/* Narrow: the two choice panels stack so each is still big enough to
   read, and the scene shrinks a touch. */
@media (max-width: 819px) {
    #tut-choice { flex-direction: column; align-items: center; }
    .tut-mode { width: min(340px, 100%); flex: 0 0 auto; min-height: 180px; }
    .tm-scene { width: 180px; }
}
