:root {
  --bg: #b6daf6;
  --ink: #1b2340;
  --white: #fff;
  --pink: #f7c6e8;
  --yellow: #ffe896;
  --blue: #c6e1fb;
  --blue-hl: #a9d0f2;
  --green: #c3ecd2;
  --tile: #f3f5f8;
  --display: "Sansita", "Mulish", sans-serif;
  --sans: "Mulish", system-ui, sans-serif;
  --cell: 48px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: default; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* highlight marker (bottom-heavy, like a highlighter swipe) */
.hl { padding: 0 4px; background: linear-gradient(transparent 38%, var(--hc) 38%, var(--hc) 92%, transparent 92%); }
.hl-pink { --hc: var(--pink); }
.hl-yellow { --hc: var(--yellow); }
.hl-blue { --hc: var(--blue-hl); }

.view { max-width: min(640px, calc(100% - 2 * var(--site-logo-space, 0px))); margin: 0 auto; padding: 0 16px; }
.site-link { font: 700 15px/1.2 var(--sans); color: var(--ink); text-decoration: none; opacity: .7; white-space: nowrap; }
.site-link:hover { opacity: 1; text-decoration: underline; }
.home-main > .site-link { display: block; width: max-content; margin: 14px auto 12px; }
/* play header: link centred in the bar; on narrow screens it drops to its own centred row */
.playbar { position: relative; }
.playbar .site-link { position: absolute; left: 50%; transform: translateX(-50%); }
@media (max-width: 560px) {
  .playbar { flex-wrap: wrap; height: auto; padding-top: 10px; row-gap: 2px; }
  .playbar .site-link { position: static; transform: none; order: 5; flex-basis: 100%; text-align: center; padding: 2px 0 10px; }
}

/* ---------- home ---------- */
.link-btn { font: italic 700 20px/1 var(--display); transition: transform .15s; }
.link-btn:hover, .pill:hover:not(:disabled), .tile:hover { transform: scale(.99); }
.link-btn:active, .pill:active:not(:disabled), .tile:active { transform: scale(.98); }
.home-main { padding: 22px 0 32px; }
.card { background: var(--white); border: 3px solid var(--ink); border-radius: 22px; box-shadow: 5px 6px 0 var(--ink); }
.clue-card { padding: 24px 24px; text-align: center; }
.clue-card.swap { animation: swap .3s ease-out; }
@keyframes swap { 0% { transform: translateX(14px) rotate(.6deg); opacity: .4; } }
.clue-card h2 { margin: 4px 0 16px; font-size: 24px; font-weight: 800; line-height: 32px; }
.clue-text { font-size: 24px; line-height: 32px; margin: 0; }
.enum { white-space: nowrap; }
.meta { font-size: 14px; margin: 16px 0 0; line-height: 20px; }
.pill {
  height: 48px; padding: 0 32px; border-radius: 9999px; border: 3px solid var(--ink);
  font: italic 800 20px/1 var(--display); box-shadow: 3px 5px 0 var(--ink);
  transition: transform .15s, opacity .15s, box-shadow .15s;
}
.pill-pink { background: var(--pink); padding: 0 56px; }
.pill-yellow { background: var(--yellow); }
.pill-outline { background: transparent; box-shadow: none; }
.pill-outline:not(:disabled) { box-shadow: 3px 5px 0 var(--ink); background: var(--white); }
.pill:disabled { opacity: .4; }
#home-play { margin-top: 16px; }
.tiles { display: flex; justify-content: center; gap: 12px; flex-wrap: nowrap; margin-top: 32px; }
.archive-empty { text-align: center; font: italic 800 18px/1.4 var(--display); padding: 40px 0; }
.tile {
  width: 80px; min-height: 84px; background: var(--tile); border-radius: 22px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 4px; font-size: 14px; font-weight: 800; transition: transform .15s;
}
.tile .phone { width: 26px; height: 36px; border: 2.5px solid var(--ink); border-radius: 4px; background: var(--white); display: grid; place-items: center; }
.tile .phone i { width: 16px; height: 6px; border: 1.5px solid var(--ink); border-radius: 1px; background: repeating-linear-gradient(90deg, var(--ink) 0 1.5px, transparent 1.5px 3.5px); }
.tile.solved .phone { background: var(--pink); }
.tile .phone b { font: italic 800 15px/1 var(--display); }
.tile svg { width: 28px; height: 28px; }
.tile .dot { fill: currentColor; }

/* ---------- play ---------- */
#play { display: flex; flex-direction: column; min-height: 100dvh; padding-bottom: 0; }
.playbar { display: flex; align-items: center; gap: 12px; height: 56px; }
.titles { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.titles b { font-size: 16px; font-weight: 800; }
.titles small { font-size: 12px; white-space: nowrap; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; }
.icon-btn svg { width: 28px; height: 28px; stroke-width: 2.4; }
.icon-btn .dot { fill: currentColor; }
.clue-box { background: var(--white); border-radius: 18px; padding: 16px 16px; margin-top: 4px; }
.clue-box { display: flex; align-items: center; min-height: 96px; }
.w { border-radius: 3px; transition: background .25s; }
.w.def { background: var(--blue-hl); }
.w.ind { background: var(--pink); }
.w.fod { background: var(--yellow); }
.sc-clue .w { cursor: pointer; }
.sc-clue .w:hover { text-decoration: underline; text-decoration-thickness: 2px; }

.grid { display: flex; justify-content: center; margin: 40px 0 0; --c: min(var(--cell), calc((100vw - 40px) / var(--n))); }
.cell {
  width: var(--c); height: var(--c); border: 3px solid var(--ink); background: var(--white);
  margin-left: -3px; display: grid; place-items: center;
  font: 800 calc(var(--c) * .5)/1 var(--sans); text-transform: uppercase; cursor: pointer;
  transition: background .15s;
}
.cell:first-child { margin-left: 0; border-radius: 9px 0 0 9px; }
.cell:last-child { border-radius: 0 9px 9px 0; }
.cell.active { background: var(--pink); }
.cell.revealed { color: #2563eb; }
.grid.correct .cell { background: var(--green); }
.grid.shake { animation: shake .4s; }
.grid.wrong .cell { background: #ffd2d2; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.grid.correct .cell { animation: pop .35s calc(var(--i) * 60ms) both; }
@keyframes pop { 50% { transform: scale(1.12); } }

.par { position: relative; display: flex; justify-content: center; gap: 9px; margin: 52px 0 0; height: 44px; }
.par .d { width: 18px; height: 18px; border-radius: 50%; background: rgba(255, 255, 255, .55); position: relative; }
.par .d.used { background: var(--ink); }
.par .d.cur { background: transparent; border: 2px solid var(--ink); }
.par .d.over { background: #ff8a8a; }
.par .d.pin::after { content: "par"; position: absolute; top: 22px; left: 50%; transform: translateX(-55%); font: italic 800 18px/1 var(--display); }

.actions { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 36px; }
.round-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--ink); background: #e0eefa;
  box-shadow: 3px 5px 0 var(--ink); display: grid; place-items: center; transition: transform .15s;
}
.round-btn:active { transform: scale(.95); }
.round-btn svg { width: 22px; height: 22px; stroke-width: 2.6; }
.feedback { text-align: center; min-height: 24px; margin: 18px 0 0; font: italic 800 18px/24px var(--display); }

.keyboard { margin-top: auto; padding: 16px 0 8px; display: flex; flex-direction: column; gap: 6px; user-select: none; }
.kb-row { display: flex; gap: 6px; justify-content: center; }
.key {
  flex: 1; max-width: 56px; height: 40px; background: var(--white); border-radius: 5px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .25); font: 300 16px/1 "Helvetica Neue", Helvetica, Arial, sans-serif;
  display: grid; place-items: center; touch-action: manipulation;
}
.key:active, .key.press { background: #e3e7ec; }
.key.wide { flex: 1.5; max-width: 80px; }
.kb-row.mid { padding: 0 2px; }

/* solved */
#play-solved { padding: 12px 0 32px; animation: rise .35s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
.solved-card { padding: 24px; text-align: center; }
.solved-title { font: italic 800 32px/1 var(--display); margin: 4px 0 16px; }
.score-row { display: flex; justify-content: center; gap: 40px; margin-bottom: 18px; }
.score-row div { display: flex; flex-direction: column; align-items: center; }
.score-row .big { font: italic 800 44px/1 var(--display); }
.score-row small { font-size: 13px; font-weight: 700; }
.answer-tiles { display: flex; justify-content: center; margin-bottom: 18px; --c: min(40px, calc((100vw - 96px) / var(--n))); }
.answer-tiles .cell { cursor: default; background: var(--green); }
.solved-clue { font-size: 20px; line-height: 30px; margin-bottom: 8px; }
.steps { text-align: left; padding: 0; margin: 16px 0 24px; list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: 10px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; line-height: 1.45; }
.steps li::before { content: counter(s); width: 26px; height: 26px; border: 2.5px solid var(--ink); border-radius: 50%; display: grid; place-items: center; font: italic 800 14px/1 var(--display); }
.steps b { font-weight: 800; }
.solved-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.solved-actions .pill-pink { padding: 0 32px; }
.replay { margin-top: 20px; font-size: 17px; }
.give-up { display: block; margin: 6px auto 0; font: 700 15px/1.2 var(--sans); opacity: .7; text-decoration: underline; text-underline-offset: 3px; }
.give-up.confirm { opacity: 1; }

/* ---------- archive ---------- */
.archive { list-style: none; padding: 8px 0 40px; margin: 0; display: grid; grid-template-columns: 1fr; gap: 10px; }
.archive button {
  width: 100%; text-align: left; background: var(--white); border: 3px solid var(--ink); border-radius: 14px;
  box-shadow: 3px 5px 0 var(--ink); padding: 12px 14px; display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center;
  transition: transform .15s;
}
.archive button:active { transform: scale(.99); }
.archive .num { font: italic 800 20px/1 var(--display); }
.archive .txt { font-size: 15px; line-height: 1.35; }
.archive .st { font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 99px; background: var(--tile); white-space: nowrap; }
.archive .st.done { background: var(--pink); }
.archive .st.prog { background: var(--yellow); }

/* ---------- sheets / modals ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; padding: 16px; background: rgba(173, 211, 255, .55); }
.sheet-wrap.center { align-items: center; }
.sheet { width: 100%; max-width: 400px; padding: 16px 18px 20px; animation: slideup .22s ease-out; }
.sheet-wrap.center .sheet { animation: rise .22s ease-out; }
@keyframes slideup { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.x-btn svg { width: 28px; height: 28px; stroke-width: 2.4; }
.hint-opt { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 14px 0; font: italic 800 20px/28px var(--display); text-align: left; }
.hint-opt em { font: 700 13px var(--sans); opacity: .55; }
.hint-opt:disabled { opacity: .35; }
.sheet hr { border: 0; border-top: 1px solid #e8e8e8; margin: 10px 0; }
.info-card { max-width: 480px; max-height: calc(100dvh - 32px); overflow-y: auto; font-size: 15px; }
.info-card p { line-height: 1.5; margin: 0 0 12px; }
.info-title { font: italic 800 26px/1 var(--display); }
.info-card .lead { font-size: 16px; }
.example { background: #eef5ff; border-radius: 12px; padding: 14px; margin: 4px 0 16px; }
.ex-clue { font-size: 20px; line-height: 30px; text-align: center; margin: 0 0 10px !important; }
.ex-steps { margin: 0; padding-left: 20px; line-height: 1.5; display: flex; flex-direction: column; gap: 6px; }
.info-card .sub { font: italic 800 19px/1 var(--display); margin: 16px 0 8px; }
.ind-list { list-style: none; padding: 0; margin: 0 0 4px; display: flex; flex-direction: column; gap: 5px; line-height: 1.4; }
.ind-list b { font-weight: 800; }
.ind-list b::after { content: " →"; font-weight: 400; }
.got-it { display: block; margin: 16px auto 4px; }

/* logo */
.logo { text-align: center; padding-top: 18px; }
.logo h1 { font: italic 800 40px/1.1 var(--display); margin: 0; letter-spacing: -.5px; }
.logo p { font: italic 800 20px/1 var(--display); margin: 6px 0 0; }

/* ---------- scribble space ---------- */
.scribble { position: fixed; inset: 0; z-index: 15; display: flex; justify-content: center; padding: 56px 16px 160px; pointer-events: none; }
.scribble-panel {
  pointer-events: auto; width: 100%; max-width: 612px; background: var(--white); border-radius: 12px;
  display: flex; flex-direction: column; padding: 16px; animation: rise .22s ease-out; box-shadow: 0 2px 10px rgba(0,0,0,.08);
}
.scribble-head { display: flex; align-items: center; gap: 10px; }
.scribble-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 800; line-height: 1.05; flex: 1; }
.round-mini { width: 32px; height: 32px; border-radius: 50%; background: #e0eefa; display: grid; place-items: center; }
.round-mini svg { width: 18px; height: 18px; stroke-width: 2.6; }
.scribble-tools { display: flex; gap: 12px; margin-right: 18px; }
.tool { height: 36px; min-width: 36px; border-radius: 99px; display: grid; place-items: center; background: #f1f2f4; }
.tool svg { width: 20px; height: 20px; }
.seg { display: flex; background: #f1f2f4; border-radius: 99px; padding: 0 4px; }
.seg .tool { background: none; opacity: .55; }
.seg .tool.on { opacity: 1; }
.sc-clue { margin: 22px 0 18px; font-size: 22px; line-height: 32px; }
.grid.small { margin: 0; --c: min(46px, calc((100vw - 72px) / var(--n))); }
.grid.small .cell { cursor: default; }
.sc-board { position: relative; flex: 1; min-height: 160px; margin-top: 12px; touch-action: none; overflow: hidden; }
.sc-tile {
  position: absolute; width: 40px; height: 40px; border: 2.5px solid var(--ink); border-radius: 8px; background: var(--yellow);
  display: grid; place-items: center; font: 800 20px/1 var(--sans); cursor: grab; user-select: none; touch-action: none;
  transition: left .35s ease, top .35s ease, transform .1s; box-shadow: 2px 2px 0 var(--ink);
}
.sc-tile.drag { transition: none; transform: scale(1.1); cursor: grabbing; z-index: 5; }
.sc-trash {
  position: absolute; right: 4px; bottom: 4px; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  background: #f1f2f4; transition: background .2s, transform .2s;
}
.sc-trash.hot { background: #ffc9c9; transform: scale(1.15); }
.sc-trash.clearing { animation: charge .8s linear forwards; }
@keyframes charge { to { background: #ff6b6b; transform: scale(1.3); } }
.sc-wheel-ring { position: absolute; border: 2px dashed #d0d4da; border-radius: 50%; pointer-events: none; }
.sc-help { background: #f1f2f4; border-radius: 8px; padding: 12px 14px; font-size: 14px; line-height: 1.45; margin-top: 12px; }
.sc-help p { margin: 0 0 6px; }
.sc-help p:last-child { margin: 0; }

/* ---------- responsive ---------- */
@media (max-width: 560px) {
  .clue-card { padding: 20px 16px; }
  .clue-text { font-size: 21px; line-height: 29px; }
  .tiles { gap: 6px; }
  .tiles { gap: 10px; }
  .tiles { gap: 8px; }
  .tile { flex: 1 1 0; max-width: 90px; min-width: 0; padding: 10px 2px; font-size: 12px; line-height: 1.2; text-align: center; }
  .logo h1 { font-size: 36px; }
  .grid { margin-top: 32px; }
  .par { margin-top: 40px; }
  .actions { margin-top: 28px; }
  .keyboard { padding-bottom: max(8px, env(safe-area-inset-bottom)); gap: 5px; }
  .kb-row { gap: 4px; }
  .key { height: 44px; }
  .scribble { padding: 58px 8px 160px; }
  .sc-clue { font-size: 19px; line-height: 27px; margin: 14px 0; }
  .scribble-tools { margin-right: 4px; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* site logo (../home-button.css): at ≤1000px it sits in flow above the game (~34px incl. margins),
   so keep the play screen one screen tall. On phones it replaces the play bar's own home text link,
   which otherwise wraps onto the clue box. */
@media (max-width: 1000px) { #play { min-height: calc(100dvh - 34px); } }
@media (max-width: 560px) { .playbar .site-link { display: none; } .playbar { padding-top: 0; } }
