@font-face { font-family: "Cabin Sketch"; font-weight: 700; font-display: swap; src: url(fonts/cabin-sketch-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Kalam"; font-weight: 400; font-display: swap; src: url(fonts/kalam-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Kalam"; font-weight: 700; font-display: swap; src: url(fonts/kalam-latin-700-normal.woff2) format("woff2"); }
/* Both families fall back to system faces for scripts they don't cover, so a new language still renders. */
:root {
  --board: #1f4640; --board-deep: #173530; --chalk: #f2f5e6; --chalk-dim: rgba(242, 245, 230, .72);
  --yellow: #ffd84d; --coral: #ff7a66; --ink: #1b2b33; --paper: #eef5f8; --grid: #c6dbe8; --brass: #c8922f; --tape: rgba(255, 216, 77, .62);
  --hand: "Kalam", "Segoe Print", "Bradley Hand", "Noto Sans", system-ui, sans-serif;
  --sketch: "Cabin Sketch", "Kalam", "Segoe Print", "Noto Sans", system-ui, sans-serif;
  --wobble: 255px 18px 225px 18px / 18px 225px 18px 255px;
  --wobble2: 18px 225px 18px 255px / 255px 18px 225px 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--board); color: var(--chalk); font-family: var(--hand); overscroll-behavior: none; }
body { position: fixed; inset: 0; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

.icon { position: fixed; width: 44px; height: 44px; padding: 9px; border: 2px solid var(--chalk-dim); border-radius: var(--wobble); background: rgba(10, 25, 25, .32); color: var(--chalk); z-index: 12; }
.icon svg { width: 100%; height: 100%; display: block; fill: currentColor; }
#btnMute { top: calc(8px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); }
#btnPause { top: calc(8px + env(safe-area-inset-top)); right: calc(60px + env(safe-area-inset-right)); }
#btnMute .off { display: none; } #btnMute.muted .off { display: block; } #btnMute.muted .on { display: none; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud button { pointer-events: auto; }
#hudScoreWrap { position: fixed; line-height: 1; max-width: 46vw; }
#hudLabel { font-size: .85rem; color: var(--chalk-dim); }
#hudScore { font-family: var(--hand); font-weight: 700; font-size: clamp(1.9rem, 6.6vmin, 2.9rem); color: var(--chalk); font-variant-numeric: tabular-nums; margin-top: 2px; white-space: nowrap; }
#hudScore.bump { animation: bump .22s ease-out; }
@keyframes bump { 30% { transform: scale(1.18) rotate(-2deg); color: var(--yellow); } }
#hudBest { font-size: .92rem; color: var(--chalk-dim); margin-top: 3px; white-space: nowrap; }
#hudDuel { position: fixed; display: flex; gap: 12px; }
.pl { padding: 3px 10px 2px; border: 2px dashed transparent; border-radius: var(--wobble); line-height: 1.05; min-width: 74px; }
.pl .n { display: block; font-size: .8rem; color: var(--chalk-dim); white-space: nowrap; }
.pl b { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.pl.on { border-color: var(--yellow); } .pl.on b { color: var(--yellow); }
#hudNextLabel { position: fixed; font-size: .85rem; color: var(--chalk-dim); text-align: center; line-height: 1; }
#note { position: fixed; margin: 0; color: var(--chalk); opacity: .9; font-size: clamp(.86rem, 2.5vmin, 1rem); line-height: 1.22; overflow: hidden; }
#note.warn { color: var(--coral); font-weight: 700; }

#hint { position: fixed; left: 50%; transform: translateX(-50%); z-index: 6; padding: 6px 14px 3px; pointer-events: none; font-size: 1.1rem; font-weight: 700; color: var(--yellow); text-align: center; max-width: 92vw; animation: hintIn .5s ease-out both; text-shadow: 0 1px 4px rgba(0, 0, 0, .6); }
@keyframes hintIn { from { opacity: 0; transform: translateX(-50%) translateY(6px); } }

#banner { position: fixed; left: 50%; top: calc(14% + env(safe-area-inset-top)); width: min(92vw, 400px); transform: translateX(-50%) rotate(-1.2deg); z-index: 8; background: var(--paper); color: var(--ink); padding: 14px 18px 10px; text-align: center; pointer-events: none; box-shadow: 0 8px 22px rgba(0, 0, 0, .35); background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 18px 18px; animation: stick .32s cubic-bezier(.2, 1.5, .4, 1) both; }
#banner::before { content: ""; position: absolute; top: -10px; left: 50%; width: 92px; height: 22px; margin-left: -46px; background: var(--tape); transform: rotate(1.5deg); }
@keyframes stick { from { opacity: 0; transform: translateX(-50%) rotate(4deg) scale(.7); } }
#banner b { display: block; font-size: .95rem; color: #2a6078; }
#banner span { display: block; font-family: var(--sketch); font-size: 2rem; line-height: 1.1; color: var(--ink); }
#banner em { display: block; font-style: normal; font-size: 1rem; line-height: 1.22; margin-top: 4px; }

#menu { position: fixed; inset: 0; z-index: 4; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding: calc(10px + env(safe-area-inset-top)) 16px calc(10px + env(safe-area-inset-bottom)); overflow-y: auto; touch-action: pan-y; }
.menu-head { text-align: center; width: 100%; max-width: 560px; flex: none; }
#logo { margin: 0; font-family: var(--sketch); font-size: clamp(2.7rem, min(14vw, 11vh), 5rem); line-height: .98; color: var(--chalk); font-weight: 700; }
#tagline { margin: 4px auto 10px; font-size: clamp(1rem, 2.6vmin, 1.2rem); line-height: 1.22; color: var(--chalk); opacity: .92; max-width: 34ch; }
.menu-actions { width: 100%; max-width: 440px; flex: none; }
.btn { display: block; width: 100%; padding: 11px 16px 7px; border: 2.5px solid var(--chalk); background: transparent; border-radius: var(--wobble); color: var(--chalk); text-align: center; font-weight: 700; font-size: 1.15rem; line-height: 1.12; transition: transform .08s; }
.btn:active { transform: scale(.975) rotate(-.4deg); }
.btn.big { margin-bottom: 9px; }
.btn.big .t { display: block; font-size: 1.32rem; }
.btn.big .s { display: block; font-weight: 400; font-size: .94rem; margin-top: 1px; opacity: .88; }
.btn:nth-of-type(even), .btn.alt { border-radius: var(--wobble2); }
#btnDaily, .btn.primary { background: var(--yellow); border-color: var(--yellow); color: #1c2a1e; }
#menuLinks { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 18px; margin: 2px 0 2px; }
.link { background: none; border: none; padding: 7px 3px 3px; min-height: 40px; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; font-size: 1.05rem; color: var(--chalk); }
#stats { margin: 0; text-align: center; font-size: .96rem; color: var(--chalk-dim); }
#byline { margin: 1px 0 0; text-align: center; font-size: .84rem; color: var(--chalk-dim); line-height: 1.2; }

/* Results and notes are a page torn out of the lab book and taped to the blackboard. */
#panel { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: calc(14px + env(safe-area-inset-top)) 12px calc(10px + env(safe-area-inset-bottom)); background: rgba(8, 22, 22, .55); touch-action: pan-y; }
.card { position: relative; width: 100%; max-width: 460px; max-height: 100%; overflow-y: auto; background-color: var(--paper); background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 20px 20px; color: var(--ink); padding: 16px 18px 12px; box-shadow: 0 14px 34px rgba(0, 0, 0, .4); transform: rotate(-.5deg); }
.card.wide { max-width: 720px; }
#pTitle { margin: 0 0 6px; font-family: var(--sketch); font-size: clamp(1.8rem, 6.4vmin, 2.5rem); line-height: 1.04; color: #16343f; }
#pBody { font-size: 1.06rem; line-height: 1.26; }
#pBody p { margin: 6px 0; }
#pBody h3 { margin: 12px 0 4px; font-family: var(--hand); font-weight: 700; font-size: 1.22rem; color: #16343f; }
#pBtns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
#pBtns .btn { flex: 1 1 46%; border-color: var(--ink); color: var(--ink); padding: 9px 10px 5px; font-size: 1.08rem; min-height: 46px; }
#pBtns .btn.primary { flex-basis: 100%; background: var(--ink); color: var(--paper); border-color: var(--ink); font-size: 1.22rem; }
#pBtns .link { flex-basis: 100%; color: var(--ink); text-align: center; }
#pToast { margin: 6px 0 0; min-height: 1.1em; font-size: .95rem; font-weight: 700; color: #1d6a4c; }
.bigscore { font-weight: 700; font-size: clamp(2.8rem, 12vmin, 4.2rem); line-height: 1; color: #16343f; font-variant-numeric: tabular-nums; }
.bigscore.duelhead { font-size: 2rem; line-height: 1.1; margin: 2px 0; }
.bigscore small { font-size: 1.1rem; font-weight: 400; margin-left: 6px; }
.flagline { font-weight: 700; color: #b23a26; }
.verdict { font-size: 1.08rem; }
.factrow { display: flex; flex-wrap: wrap; gap: 3px 16px; margin: 4px 0; font-size: 1rem; }
.factrow b { font-weight: 700; }
.ladderc { display: block; width: 100%; height: auto; margin: 2px 0; }
#panel textarea { width: 100%; height: 76px; font: inherit; font-size: .9rem; margin-top: 6px; user-select: text; -webkit-user-select: text; background: #fff; color: var(--ink); border: 1px solid var(--ink); }
.book { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 7px; grid-template-columns: 1fr; }
.book li { display: grid; grid-template-columns: 58px 1fr; gap: 8px; align-items: center; }
.book canvas { width: 58px; height: 58px; display: block; }
.book b { display: block; font-size: 1.12rem; line-height: 1.1; }
.book span { display: block; font-size: .96rem; line-height: 1.18; }
.book .eq { color: #2a6078; }
.book .unk b { color: #5c6d76; }
.looks { list-style: none; margin: 4px 0; padding: 0; display: grid; gap: 6px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.looks button { display: block; width: 100%; padding: 7px 10px 4px; text-align: left; background: rgba(255, 255, 255, .6); border: 2px solid var(--ink); border-radius: var(--wobble); color: var(--ink); line-height: 1.14; min-height: 48px; }
.looks button[disabled] { border-style: dashed; opacity: .78; cursor: default; }
.looks button.on { background: var(--yellow); }
.looks b { display: block; font-size: 1.04rem; }
.looks span { display: block; font-size: .9rem; }
@media (min-width: 760px) { .book { grid-template-columns: 1fr 1fr; } }
@media (prefers-reduced-motion: reduce) { #hudScore.bump, #banner, #hint { animation: none; } .btn { transition: none; } }
/* Wide screens: the picture and name on the left, the choices on the right. */
@media (min-aspect-ratio: 11/10) {
  #menu { flex-direction: row; justify-content: center; align-items: stretch; gap: clamp(16px, 4vw, 56px); }
  .menu-head { flex: 1 1 50%; max-width: 620px; display: flex; flex-direction: column; justify-content: flex-end; padding-bottom: 9vh; }
  #tagline { margin-bottom: 4px; }
  .menu-actions { flex: 0 1 420px; align-self: center; padding-top: 44px; }
}
@media (max-height: 480px) {
  #menu { justify-content: flex-start; }
  .menu-actions { padding-top: 0; padding-right: 52px; align-self: flex-start; }
  .menu-head { padding-bottom: 0; }
  .btn.big { margin-bottom: 5px; padding: 6px 10px 3px; }
  .btn.big .t { font-size: 1.12rem; } .btn.big .s { font-size: .82rem; line-height: 1.05; }
  .link { min-height: 32px; padding-top: 4px; font-size: .95rem; }
  #stats { font-size: .82rem; } #byline { font-size: .72rem; }
  .card:not(.wide) { max-width: 700px; display: grid; grid-template-columns: 1.3fr 1fr; grid-template-rows: auto 1fr auto; column-gap: 14px; padding: 10px 14px 8px; }
  .card:not(.wide) #pTitle { grid-column: 1; grid-row: 1; }
  .card:not(.wide) #pBody { grid-column: 1; grid-row: 2 / span 2; }
  .card:not(.wide) #pBtns { grid-column: 2; grid-row: 1 / span 2; align-content: start; margin-top: 2px; }
  .card:not(.wide) #pToast { grid-column: 2; grid-row: 3; }
  .card.wide { padding: 10px 14px 8px; }
  .bigscore { font-size: 2.3rem; }
  #pBody p { margin: 3px 0; }
  #banner { top: 6px; padding: 8px 14px 4px; }
  #banner span { font-size: 1.4rem; }
  #banner em { font-size: .9rem; }
}
