:root {
  --ink: #1e293b;
  --muted: #5b6678;
  --line: #dde3ea;
  --bg: #ffffff;
  --soft: #f3f6f9;
  --teal: #0f7f86;
  --teal-d: #0b5f65;
  --coral: #e46f5a;
  --mustard: #e0a21b;
  --navy: #1e3a5f;
  --display: Futura, "Avenir Next", "Century Gothic", system-ui, sans-serif;
  --body: "Avenir Next", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); line-height: 1.45; }
a { color: var(--teal-d); }
.logo { font-family: var(--display); font-weight: 800; letter-spacing: 0.12em; color: var(--navy); font-size: 40px; }
.logo.sm { font-size: 18px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 10px; border: 2px solid var(--navy); background: #fff; color: var(--navy); font: 600 15px var(--body); text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-d); }
.btn.ghost { border-color: var(--line); color: var(--muted); }

/* First-visit practice */
#tutorial { width: min(760px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 20px; border: 2px solid var(--line); border-radius: 14px; color: var(--ink); background: var(--bg); overflow-y: auto; }
#tutorial::backdrop { background: rgba(30, 41, 59, 0.65); }
.tutorial-top, .tutorial-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tutorial-top { color: var(--muted); }
#tutorial h1 { margin: 8px 0; font: 700 24px var(--display); color: var(--navy); }
#tutorial-copy { margin: 8px 0 16px; }
.tutorial-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.practice-pieces { display: grid; gap: 8px; }
.practice-piece { display: flex; align-items: center; gap: 8px; padding: 8px; min-height: 48px; border: 2px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); text-align: left; font: inherit; cursor: pointer; }
.practice-piece .av { flex-shrink: 0; }
.practice-piece.sel { border-color: var(--teal); background: var(--soft); }
.practice-at { display: block; font-size: 13px; color: var(--teal-d); }
#practice-board, [data-practice-token] { touch-action: none; user-select: none; -webkit-user-select: none; }
#practice-board .practice-drop { fill: var(--teal); fill-opacity: 0.3; stroke: var(--teal-d); stroke-width: 4; }
#tutorial-status { min-height: 42px; margin: 12px 0; font-size: 14px; color: var(--teal-d); }
.tutorial-actions { justify-content: flex-end; flex-wrap: wrap; }
#tutorial .btn { min-height: 44px; }
#tutorial .btn:disabled { opacity: 0.55; cursor: default; }
#tutorial :focus-visible { outline: 3px solid var(--teal-d); outline-offset: 3px; }
#tutorial h1:focus { outline: none; }
#practice-board [data-cell]:focus-visible { outline: none; stroke: var(--teal-d); stroke-width: 4; }
@media (max-width: 600px) {
  #tutorial { padding: 14px; }
  .tutorial-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  #practice-board { width: min(100%, 254px); margin: 0 auto; }
  #tutorial h1 { font-size: 22px; }
  #tutorial-copy { font-size: 15px; margin-bottom: 10px; }
  .practice-piece { padding: 6px 8px; }
  .practice-piece .clue { font-size: 13px; }
}

/* home */
.hero { display: grid; grid-template-columns: 1fr 1.1fr; align-items: stretch; background: var(--teal); color: #fff; }
.hero-text { padding: 48px 40px; align-self: center; }
.hero .logo { color: #fff; font-size: 56px; }
.hero h1 { font-family: var(--display); font-size: 26px; margin: 6px 0 12px; font-weight: 600; }
.hero p { max-width: 460px; margin: 0 0 20px; opacity: 0.95; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero .btn { border-color: #fff; }
.hero .btn.primary { background: var(--mustard); border-color: var(--mustard); color: var(--navy); }
.hero-img { width: 100%; height: 100%; max-height: 420px; object-fit: cover; display: block; }
.home { max-width: 1180px; margin: 0 auto; padding: 24px 20px 40px; }
.shelf { padding: 28px 0; border-bottom: 1px solid var(--line); }
.shelf-head { display: grid; grid-template-columns: 120px 1fr; gap: 20px; align-items: center; margin-bottom: 18px; }
.cover { width: 120px; border-radius: 8px; box-shadow: 0 6px 18px rgba(30, 41, 59, 0.18); }
.ed-name { font-family: var(--display); font-size: 28px; font-weight: 800; color: var(--navy); }
.ed-sub { font-size: 17px; font-weight: 600; color: var(--coral); }
.ed-blurb { margin: 6px 0; max-width: 560px; }
.ed-aud { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; text-decoration: none; color: inherit; background: #fff; }
.card:hover { border-color: var(--teal); box-shadow: 0 4px 14px rgba(15, 127, 134, 0.15); }
.card-board { padding: 10px 10px 0; }
.card-body { padding: 8px 12px 12px; }
.card-title { font-weight: 700; }
.card-meta { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; border: 2px solid; }
.dot-easy { border-color: #22a35a; } .dot-medium { border-color: #2f7fd6; } .dot-hard { border-color: #e0711b; } .dot-expert { border-color: #b4234a; }
.dot.started { background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
.dot.started.dot-easy { color: #22a35a; } .dot.started.dot-medium { color: #2f7fd6; } .dot.started.dot-hard { color: #e0711b; } .dot.started.dot-expert { color: #b4234a; }
.dot.done.dot-easy { background: #22a35a; } .dot.done.dot-medium { background: #2f7fd6; } .dot.done.dot-hard { background: #e0711b; } .dot.done.dot-expert { background: #b4234a; }
.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 24px; }

/* shared top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 20px; border-bottom: 1px solid var(--line); }
.back { text-decoration: none; font-weight: 600; }

/* art directions */
.artpage { max-width: 1240px; margin: 0 auto; padding: 20px 20px 50px; }
.artpage h1 { font-family: var(--display); color: var(--navy); margin: 0 0 4px; }
.dirs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.dir { border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.dir-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.dir-key { width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; }
.dir-name { font-family: var(--display); font-weight: 800; font-size: 19px; color: var(--navy); }
.dir-fit { font-size: 13px; color: var(--coral); font-weight: 700; }
.dir-cover { width: 70%; display: block; margin: 0 auto 10px; border-radius: 8px; box-shadow: 0 6px 18px rgba(30, 41, 59, 0.18); }
.dir-img { width: 100%; display: block; border-radius: 8px; margin-bottom: 8px; background: #eef2f6; }
.dir p { font-size: 14px; margin: 6px 0; }
@media (max-width: 860px) { .dirs { grid-template-columns: 1fr; } }

/* rules */
.rules { max-width: 720px; margin: 0 auto; padding: 24px 20px 60px; }
.rules h1, .rules h2 { font-family: var(--display); color: var(--navy); }
.rules li { margin-bottom: 8px; }
.rules dt { font-weight: 700; margin-top: 10px; }
.rules dd { margin: 2px 0 0 0; color: var(--muted); }

/* play */
.play { max-width: 1240px; margin: 0 auto; padding: 16px 20px 40px; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr); gap: 28px; }
.title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.title-row h1 { font-family: var(--display); color: var(--navy); margin: 4px 0; font-size: 28px; }
.diffs { display: flex; gap: 6px; }
.chip { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--muted); font-size: 13px; font-weight: 600; }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
/* Progress marks: a teal dot while in progress, a check once solved. */
.chip.is-started:not(.on) { border-color: var(--teal); color: var(--teal-d); }
.chip .mark { margin-left: 6px; }
.chip .mark.live { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--teal); vertical-align: 2px; }
.chip.on .mark.live { background: #fff; }
.intro { margin: 6px 0 12px; color: var(--muted); }
.board svg { display: block; max-width: 640px; user-select: none; }
.board.placing svg { outline: 3px solid var(--mustard); outline-offset: 4px; border-radius: 4px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tchip { padding: 2px; border-radius: 50%; border: 3px solid transparent; background: none; cursor: pointer; }
.tchip.sel { border-color: var(--mustard); }
.tchip.placed { opacity: 0.45; }
.seats { font-size: 13px; color: var(--muted); margin-top: 8px; }
.question { font-family: var(--display); font-size: 20px; font-weight: 700; color: var(--coral); margin: 8px 0 10px; }
.tray { display: flex; flex-direction: column; gap: 8px; }
.who { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; text-align: left; padding: 8px 10px; border: 2px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; font: inherit; color: inherit; }
.who:hover { border-color: #b8c4d1; }
.who.sel { border-color: var(--mustard); box-shadow: 0 0 0 3px rgba(224, 162, 27, 0.25); }
.who.target { background: var(--soft); }
.who.placed .av { opacity: 0.55; }
.who-body { min-width: 0; overflow-wrap: anywhere; }
.who-name { display: block; font-weight: 700; }
.who-role { font-weight: 500; color: var(--muted); font-size: 12px; }
.who-at { font-weight: 800; color: var(--teal-d); font-size: 15px; min-width: 28px; text-align: right; }
[data-token], #board { user-select: none; -webkit-user-select: none; }
/* The small chips are drag handles. The board scrolls the page unless a touch starts on a piece (app.ts). */
.tchip { touch-action: none; }
#board { touch-action: manipulation; }
#board .drop-target { fill: var(--teal); fill-opacity: 0.22; stroke: var(--teal-d); stroke-width: 4px; }
#board .drop-blocked { fill: var(--coral); fill-opacity: 0.3; stroke: var(--coral); stroke-width: 4px; }
.drag-preview { position: fixed; z-index: 10; pointer-events: none; transform: translateY(calc(-100% - 12px)); display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; max-width: 240px; background: #fff; color: var(--ink); border: 2px solid var(--teal); border-radius: 12px; box-shadow: 0 6px 18px rgba(30, 41, 59, 0.22); font-weight: 700; }
.drag-preview .av { flex-shrink: 0; }
.clue { display: block; font-size: 14.5px; }
.clue.muted { color: var(--muted); font-style: italic; }
.verse { display: block; margin: 6px 0; padding-left: 10px; border-left: 2px solid var(--line); line-height: 1.5; }
.verse-text { display: block; }
.verse-ref { display: block; margin-top: 2px; font-weight: 600; color: var(--teal-d); }
.verse-note { font-size: 14.5px; margin: 0 0 12px; }
.av { border-radius: 50%; border: 3px solid var(--c); object-fit: cover; display: block; background: #fff; }
.av-txt { display: inline-flex; align-items: center; justify-content: center; background: var(--c); color: #fff; font-weight: 800; border-color: transparent; font-size: 15px; }
.globals { margin-top: 12px; padding: 10px 12px; border: 1px dashed #b8c4d1; border-radius: 12px; }
.g-head { font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.controls { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.msg { margin-top: 10px; min-height: 44px; padding: 10px 12px; border-radius: 10px; background: var(--soft); font-size: 14.5px; }
.msg.hint { background: #e7f5f3; border-left: 4px solid var(--teal); }
.solved { margin-top: 14px; display: grid; grid-template-columns: 72px 1fr; gap: 14px; padding: 16px; border-radius: 14px; background: #eaf6f5; border: 2px solid var(--teal); }
.solved-head { font-family: var(--display); font-size: 22px; font-weight: 800; color: var(--navy); }
.solved p { margin: 4px 0; }
.ref { font-weight: 700; color: var(--teal-d); }
.stats { font-size: 13px; color: var(--muted); margin: 4px 0 8px; }
.solved-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.accuse { margin-top: 14px; padding: 16px; border-radius: 14px; background: #eaf6f5; border: 2px solid var(--teal); }
.accuse p { margin: 4px 0 10px; }
.accuse p.nope { color: #b91c1c; font-weight: 600; }
.suspects { display: flex; gap: 8px; flex-wrap: wrap; }
.suspect { padding: 6px 14px 6px 6px; }
.suspect .av { flex-shrink: 0; }
.suspect.wrong { border-color: #ef4444; opacity: 0.6; }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .hero-text { padding: 28px 20px; }
  .hero .logo { font-size: 42px; }
  .play { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 10px 12px 30px; }
  .play > section { min-width: 0; }
  .shelf-head { grid-template-columns: 90px 1fr; }
  .cover { width: 90px; }
}

/* ---------- phone play layout (picked by Brad from three options, 2026-10-28) ----------
   Board and chips pinned at the top while the clues scroll underneath; buttons in a
   bottom bar with messages just above it. Sections flatten so CSS order can regroup them. */
@media (max-width: 600px) {
  .play { display: flex; flex-direction: column; gap: 8px; padding-top: 6px; padding-bottom: 68px; }
  .play > section { display: contents; }
  .title-row { order: 1; row-gap: 4px; } .question { order: 3; } .stage { order: 4; } .solved, .accuse { order: 5; }
  .verse-note { order: 6; } .tray { order: 7; } .globals { order: 8; } .intro { order: 9; } .seats { order: 10; }
  .title-row h1 { font-size: 19px; margin: 0; }
  .diffs .chip { padding: 2px 8px; font-size: 12px; }
  .question { font-size: 15px; margin: 0; }
  /* The story moves below the clues, two lines until tapped. */
  .intro { margin: 0; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
  .intro.open { display: block; }
  .seats, .solved, .accuse, .globals { margin-top: 0; }
  .stage { position: sticky; top: 0; z-index: 4; background: #fff; padding: 4px 0 6px; box-shadow: 0 6px 8px -8px rgba(30, 41, 59, 0.35); }
  .is-solved .stage { position: static; box-shadow: none; } /* Locked board: let Solved! show. */
  .board svg { margin: 0 auto; max-width: min(100%, 40vh); }
  .chips { justify-content: center; margin-top: 6px; }
  .chips .av { width: 34px; height: 34px; }
  .tray { gap: 6px; }
  .who { padding: 6px 10px; }
  .who-role { display: none; }
  .controls { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; margin: 0; justify-content: center; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); }
  .controls .btn { padding: 8.5px 13.5px; font-size: 12.75px; } /* 15% under the desktop size, per Brad. */
  .msg { position: fixed; left: 8px; right: 8px; bottom: calc(58px + env(safe-area-inset-bottom)); z-index: 6; margin: 0; min-height: 0; max-height: 30vh; overflow: auto; box-shadow: 0 4px 14px rgba(30, 41, 59, 0.2); }
  .msg.idle { display: none; }
}
