/* Tessera: a glass jar on drafting paper (light) and in deep space (dark). house.css loads first. */
:root {
  --bg: #EEF0F7; --panel: #FFFFFF; --panel-2: #F4F5FA; --line: #DCDFEB; --text: #1B1D2E; --muted: #666B83;
  --accent: #6A57D6; --accent-ink: #FFFFFF; --bad: #D0384B; --gold: #C98A12;
  --t-bouncy: #D63B73; --t-heavy: #4A5068; --t-floaty: #1E8CCB; --t-leaf: #2F8F45; --t-magnet: #0E8A8A;
  --t-blink: #7E45D0; --t-wormhole: #2D47C7; --t-sticky: #A86A12; --t-volatile: #E03131;
  --h-bg: var(--panel-2); --h-panel: var(--panel); --h-panel2: var(--panel-2); --h-line: var(--line); --h-text: var(--text); --h-muted: var(--muted);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0D0F1A; --panel: #161A2B; --panel-2: #1C2136; --line: #2A3150; --text: #EEF0FA; --muted: #99A0BD;
  --accent: #A99BFF; --accent-ink: #14122A; --bad: #FF6F7F; --gold: #F5C451;
  --t-bouncy: #FF86AE; --t-heavy: #C2C8E0; --t-floaty: #7FCBFF; --t-leaf: #86D893; --t-magnet: #5FD6D6;
  --t-blink: #C5A3FF; --t-wormhole: #8FA4FF; --t-sticky: #F0BE5A; --t-volatile: #FF6B6B;
  --h-on: #0D0F1A;
  --h-bg: var(--panel-2); --h-panel: var(--panel); --h-panel2: var(--panel-2); --h-line: var(--line); --h-text: var(--text); --h-muted: var(--muted);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--h-sans); line-height: 1.45; min-height: 100vh; min-height: 100dvh; overflow-x: hidden; }
a { color: inherit; }
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.layout { max-width: 960px; margin: 0 auto; padding: 0 16px; }

/* header mark: a tesseract in two strokes */
.hbrand .logo .mark { width: 30px; height: 30px; flex: none; }
.mark path { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.mark .m-out { stroke: var(--accent); stroke-width: 2.4; }
.mark .m-in { stroke: #E0607E; stroke-width: 1.8; opacity: .85; }
.mark .m-join { stroke: var(--muted); stroke-width: 1.3; }
.mark .m-dot { fill: var(--gold); }

/* daily / practice */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 4px auto 10px; max-width: 460px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; }
.mode { border: 0; background: transparent; border-radius: 10px; padding: 6px 8px; cursor: pointer; display: flex; gap: 6px; align-items: baseline; justify-content: center; color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; }
.mode b { color: var(--text); font-weight: 700; }
.mode span { font-size: .8rem; overflow: hidden; text-overflow: ellipsis; }
.mode.on { background: var(--panel); box-shadow: 0 1px 4px rgba(20, 20, 50, .12); }
.mode.on b { color: var(--accent); }

.stage { display: grid; gap: 16px; justify-items: center; }
@media (min-width: 820px) { .stage { grid-template-columns: auto 320px; align-items: start; justify-content: center; gap: 28px; } }
.play { width: min(100%, calc((100svh - 236px) * 400 / 620)); min-width: 240px; max-width: 440px; }
@supports not (height: 100svh) { .play { width: min(100%, calc((100vh - 236px) * 400 / 620)); } }

/* score, best shape, next */
.hud { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-bottom: 8px; min-height: 44px; }
.hud .lbl { display: block; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); line-height: 1; }
.hscore b { font: 700 1.55rem/1.1 var(--h-serif); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.hscore b.bump { animation: bump .35s var(--h-spring); }
@keyframes bump { 40% { transform: scale(1.12); } }
.hscore b { display: inline-block; transform-origin: 0 60%; }
.hbest { font-size: .82rem; color: var(--muted); text-align: center; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbest b { color: var(--text); }
.hnextbox { justify-self: end; display: flex; align-items: center; gap: 8px; }
.hnextbox .lbl { text-align: right; }
.hnextbox .lbl small { display: block; margin-top: 3px; font-size: 11px; letter-spacing: .02em; text-transform: none; font-weight: 700; min-height: 1em; }
.nextwrap { position: relative; display: block; }
#next { width: 44px; height: 44px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); display: block; }
#next-badge { position: absolute; right: -6px; bottom: -6px; width: 18px; height: 18px; }
#next-badge[hidden] { display: none; }

/* physics traits: an icon per trait, coloured by trait */
.tc-bouncy { color: var(--t-bouncy); } .tc-heavy { color: var(--t-heavy); } .tc-floaty { color: var(--t-floaty); } .tc-leaf { color: var(--t-leaf); } .tc-magnet { color: var(--t-magnet); }
.tc-blink { color: var(--t-blink); } .tc-wormhole { color: var(--t-wormhole); } .tc-sticky { color: var(--t-sticky); } .tc-volatile { color: var(--t-volatile); }
.ticon { width: 100%; height: 100%; display: block; fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.tbadge { display: grid; place-items: center; border-radius: 50%; background: var(--panel); box-shadow: 0 0 0 1.5px currentColor; padding: 2px; }

/* the jar */
.board-wrap { position: relative; width: 100%; }
#board { display: block; width: 100%; aspect-ratio: 400 / 620; border-radius: 22px; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: grab;
  background: var(--panel-2); box-shadow: 0 0 0 1px var(--line), 0 18px 40px -26px rgba(10, 10, 40, .45); }
#board:focus-visible { outline-offset: 3px; }
#board.ended { cursor: default; }
.banner { position: absolute; left: 12%; right: 12%; top: 34%; background: color-mix(in srgb, var(--panel) 94%, transparent); border: 1px solid var(--line); border-radius: 18px; padding: 10px 14px; text-align: center; box-shadow: 0 12px 30px -16px rgba(0,0,0,.4); animation: hUp .4s var(--h-ease) both; pointer-events: none; }
.banner[hidden] { display: none; }
.banner b { display: block; font: 700 1.2rem/1.2 var(--h-serif); }
.banner span { color: var(--muted); font-size: .85rem; }
/* the win card: over the bottom of the jar, under the showpiece turning at centre stage */
.wincard { position: absolute; left: 7%; right: 7%; bottom: 4.5%; background: color-mix(in srgb, var(--panel) 95%, transparent); border: 1px solid color-mix(in srgb, var(--gold) 45%, var(--line));
  border-radius: 20px; padding: 12px 16px 14px; text-align: center; box-shadow: 0 16px 36px -18px rgba(0,0,0,.5); }
.wincard[hidden] { display: none; }
.wincard.pop { animation: hUp .45s var(--h-ease) both; }
.wc-eye { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.wc-h { display: block; font: 700 1.3rem/1.2 var(--h-serif); margin-top: 2px; }
.wc-score { font: 700 1.5rem/1.2 var(--h-serif); color: var(--gold); font-variant-numeric: tabular-nums; }
.wc-score small { font: 600 .8rem var(--h-sans); color: var(--muted); }
.wc-line { margin: 4px 0 10px; color: var(--muted); font-size: .85rem; line-height: 1.35; }
.wincard .hcta { height: 46px; font-size: 15px; }
@media (max-width: 400px) { .wincard { padding: 9px 12px 11px; } .wc-h { font-size: 1.12rem; } .wc-score { font-size: 1.25rem; } .wc-line { font-size: .8rem; margin-bottom: 8px; } .wincard .hcta { height: 42px; } }
@media (prefers-reduced-motion: reduce) { .wincard.pop { animation: tfade .3s ease both; } }
/* the secret badge in Your stats (only once found) */
.stats div.secret { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 10px; background: linear-gradient(120deg, color-mix(in srgb, #4FE3FF 18%, var(--panel-2)), color-mix(in srgb, #FF5FD2 16%, var(--panel-2)), color-mix(in srgb, #FFD24F 16%, var(--panel-2))); }
.stats div.secret dd { order: -1; font-size: 1.3rem; color: #B86BFF; }
.stats div.secret dt { color: var(--text); font-weight: 600; }

/* the ladder strip under the jar */
.ladder { list-style: none; margin: 10px 0 0; padding: 6px; display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.ladder li { display: grid; place-items: center; position: relative; border-radius: 8px; padding: 2px 0; }
.ladder canvas { width: 100%; max-width: 30px; aspect-ratio: 1; display: block; opacity: .28; filter: grayscale(.9); transition: opacity .4s, filter .4s, transform .4s var(--h-spring); }
.ladder li.got canvas { opacity: 1; filter: none; }
.ladder li.top { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.ladder li.top canvas { transform: scale(1.12); }
.ladder .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.ladder .tbadge { position: absolute; right: -2px; top: -4px; width: 14px; height: 14px; padding: 1.5px; box-shadow: 0 0 0 1px currentColor; }
.ladder li.dim::before { content: ""; position: absolute; left: -2px; top: 18%; bottom: 18%; width: 1px; background: var(--line); }

/* the day's traits, under the ladder */
.traits { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.traits li { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 5px; border-radius: 99px; background: var(--panel); border: 1px solid color-mix(in srgb, currentColor 40%, var(--line)); font-size: .78rem; line-height: 1.2; max-width: 100%; }
.traits li .ticon { width: 16px; height: 16px; flex: none; }
.traits li b { font-weight: 700; }
.traits li span { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.traitlist { list-style: none; padding: 0; margin: 0 0 1em; display: grid; gap: 8px; color: var(--muted); }
.traitlist li { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; }
.traitlist li .tbadge { width: 22px; height: 22px; flex: none; margin-top: 1px; padding: 3px; }
.traitlist li .tx { color: var(--muted); }
.traitlist li b { color: var(--text); }
.traitlist li.off { opacity: .62; }

/* the day's intro: badges and chips pop on as their shapes land in the jar */
.ladder.intro-hide .tbadge, .traits.intro-hide li { opacity: 0; transform: scale(.2); }
.ladder.intro-hide .tbadge.on, .traits.intro-hide li.on { opacity: 1; transform: none; animation: tpop .5s var(--h-spring) both; }
@keyframes tpop { 0% { opacity: 0; transform: scale(.2); } 60% { opacity: 1; transform: scale(1.35); } 100% { opacity: 1; transform: scale(1); } }
@keyframes tfade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ladder.intro-hide .tbadge, .traits.intro-hide li { transform: none; } .ladder.intro-hide .tbadge.on, .traits.intro-hide li.on { animation: tfade .35s ease both; } }
.hrep { margin: -.4em 0 1em; }

/* side: end card + note */
.side { width: min(100%, 440px); display: grid; gap: 14px; }
@media (min-width: 820px) { .side { width: 320px; position: sticky; top: 16px; } }
.note { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 12px 16px; color: var(--muted); font-size: .9rem; }
.note p { margin: 0; }
.note b { color: var(--text); }
.hsum [hidden] { display: none !important; }
.hsum .hbtns:has(> [hidden]) { grid-template-columns: 1fr; }
.hsum .big small { font-family: var(--h-sans); font-size: 15px; color: var(--muted); }
.hsum .glyphs { font-size: 18px; letter-spacing: 2px; margin-top: 8px; }

/* ads + footer */
.ad-inline { margin-top: 26px; }
.ad-slot { display: block; margin: 0 auto; overflow: hidden; }
.ad-banner { width: 100%; max-width: 728px; min-height: 100px; }
.ad-slot.placeholder { border: 1.5px dashed var(--line); border-radius: 12px; display: grid; place-items: center; color: var(--muted); font-size: 0.85rem; }
.ad-slot.placeholder::before { content: "Ad space " attr(data-size); }
.ad-slot.collapsed { min-height: 0; }
.ad-slot ins[data-ad-status="unfilled"] { display: none !important; }
.ad-label { font-size: 11px; color: var(--muted); text-align: center; margin: 0 0 4px; }
.foot { display: flex; justify-content: center; gap: 22px; padding: 26px 0 40px; color: var(--muted); font-size: .9rem; }

/* dialogs */
.dlg { border: 1px solid var(--line); border-radius: 22px; padding: 22px; width: min(440px, calc(100vw - 32px)); background: var(--panel); color: var(--text); }
.dlg::backdrop { background: rgba(10, 12, 30, .5); }
.dlg h2 { font-family: var(--h-serif); font-weight: 700; margin: 0 0 10px; font-size: 1.6rem; }
.dlg p { color: var(--muted); }
.dlg p b { color: var(--text); }
.dlg .x { position: absolute; right: 10px; top: 8px; border: 0; background: transparent; font-size: 26px; cursor: pointer; color: var(--muted); width: 40px; height: 40px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 0; }
.stats div { display: flex; flex-direction: column-reverse; background: var(--panel-2); border-radius: 12px; padding: 10px; }
.stats dt { color: var(--muted); font-size: .85rem; }
.stats dd { margin: 0; font: 700 1.4rem/1.2 var(--h-serif); font-variant-numeric: tabular-nums; }
/* seven header icons (settings, archive and leaderboard joined) stay on one row beside the wordmark on phones */
@media (max-width: 440px) { .hbar { gap: 6px; } .hicons { gap: 3px; } .hicon { width: 30px; height: 30px; border-radius: 10px; } .hicon svg { width: 16px; height: 16px; }
  .hbrand .logo { font-size: 22px; gap: 5px; } .hbrand .logo .mark { width: 20px; height: 20px; } .hbrand .by { letter-spacing: .16em; } }
@media (max-width: 380px) { .hbrand .logo { font-size: 20px; } .hbrand .logo .mark { display: none; } .hbrand .by { letter-spacing: .1em; } .mode span { display: none; } }
@media (prefers-reduced-motion: reduce) { .banner, .hscore b.bump { animation: none; } .ladder canvas { transition: none; } }
/* very narrow phones (320px): let the icon row drop under the logo instead of running off the screen */
@media (max-width: 350px) { .hbar { flex-wrap: wrap; row-gap: 6px; } .hicons { margin-left: auto; } }

/* mobile pass: the close button is 44px and stays in the corner while a tall dialog (landscape phones) scrolls under it */
.dlg > form:first-child { position: sticky; top: 22px; height: 0; z-index: 3; background: inherit; }
.dlg .x { top: -16px; right: -14px; width: 44px; height: 44px; border-radius: 50%; background: inherit; touch-action: manipulation; }
/* mobile pass: viewport-fit=cover lets the page run under a landscape notch; keep the content clear of it */
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
/* mobile pass: quick repeated taps on game buttons must not double-tap-zoom the page (pinch zoom still works) */
html { touch-action: manipulation; }
/* mobile pass: the end-card Leaderboard link is a 40px tap target */
.hlink { min-height: 40px; padding: 10px 8px; }
/* mobile pass: the header keeps its seven small icons beside the wordmark (the jar needs the height), but each
   one takes taps over about 34 x 42px */
@media (max-width: 440px) { .hicon { position: relative; } .hicon::after { content: ""; position: absolute; inset: -6px -2px; } }
/* mobile pass: a phone on its side: the jar fits the screen height once scrolled to (it can't be scrolled by dragging on it) */
@media (orientation: landscape) and (max-height: 520px) { .play { width: min(100%, calc((100svh - 12px) * 400 / 620)); min-width: 200px; } }
.lede{font-style:italic;opacity:.82;line-height:1.55}

/* mobile pass: the 30px header icons get a bigger tap area than they draw */
.hicon { position: relative; }   /* without it, on a wide screen the ::before below covered the whole page and took every click */
.hicon::before { content: ""; position: absolute; inset: -7px -3px; }
