:root {
  --bg: #f7f6f2;
  --card: #ffffff;
  --lane: #ebe9e2;
  --rail: #d2cfc4; --rail-gold: #edd5a6; --cell-bd: #8f8c82;
  --text: #1f1e1c;
  --text2: #5f5e5a;
  --muted: #8a8983;
  --border: #d3d1c7;
  --border-strong: #b4b2a9;
  --accent: #185fa5;
  --ok-bg: #dcefc6; --ok-bd: #639922; --ok-tx: #27500a;
  --bad-bg: #f7c1c1; --bad-bd: #e24b4a; --bad-tx: #791f1f;
  --hint-bg: #e6f1fb; --hint-bd: #85b7eb; --hint-tx: #6f8db0;
  --sel: #fac775;
  --gold-bg: #faeeda; --gold-bd: #ba7517; --gold-tx: #633806; --gold-lane: #f5e6c8;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a19; --card: #262624; --lane: #2f2f2c;
    --rail: #3f3f3b; --rail-gold: #4d3c1f; --cell-bd: #77766f;
    --text: #f1efe8; --text2: #b4b2a9; --muted: #888780;
    --border: #444441; --border-strong: #5f5e5a; --accent: #85b7eb;
    --ok-bg: #27500a; --ok-bd: #97c459; --ok-tx: #eaf3de;
    --bad-bg: #791f1f; --bad-bd: #f09595; --bad-tx: #fcebeb;
    --hint-bg: #0c447c; --hint-bd: #378add; --hint-tx: #85b7eb;
    --sel: #854f0b;
    --gold-bg: #633806; --gold-bd: #ef9f27; --gold-tx: #faeeda; --gold-lane: #3a2e1c;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
}
header {
  max-width: 560px; margin: 0 auto; padding: 12px 0;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.brand { text-align: center; }
h1 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: 0.5px; }
.meta { font-size: 13px; color: var(--text2); margin-top: 2px; }
button {
  font: inherit; color: var(--text); background: transparent;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 6px 12px; cursor: pointer;
}
button:active { transform: scale(0.98); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--card); }
.icon { width: 36px; height: 36px; padding: 0; font-size: 17px; border-radius: 50%; }
main { max-width: 560px; margin: 0 auto; padding: 16px 0 40px; }
#boardWrap { display: flex; justify-content: center; }
#board { position: relative; touch-action: none; user-select: none; -webkit-user-select: none; }
.lane { position: absolute; background: var(--rail); border-radius: 6px; }
.lane.sel { outline: 2px solid var(--sel); outline-offset: -1px; }
.cell {
  position: absolute; display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 1.5px solid var(--cell-bd); border-radius: 6px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
  font-weight: 600; text-transform: uppercase; cursor: grab;
}
.cell.ok { background: var(--ok-bg); border-color: var(--ok-bd); color: var(--ok-tx); }
.cell.bad { background: var(--bad-bg); border-color: var(--bad-bd); color: var(--bad-tx); }
.cell.hint { background: var(--hint-bg); border-color: var(--hint-bd); color: var(--hint-tx); }
.cell.sel { box-shadow: inset 0 0 0 2px var(--sel); }
.cell .sub { position: absolute; right: 3px; bottom: 1px; font-size: 10px; font-weight: 500; }
.done .cell { cursor: default; }
.status { text-align: center; font-size: 14px; color: var(--text2); margin: 14px 0 6px; min-height: 20px; }
.status.win { color: var(--ok-bd); font-weight: 600; }
.clues { list-style: none; padding: 0; margin: 0; }
.clue {
  display: flex; align-items: center; gap: 10px; padding: 8px 6px;
  border-bottom: 1px solid var(--border); border-radius: 0;
}
.clue.sel { background: var(--lane); }
.clue .tag { font-size: 13px; font-weight: 700; min-width: 26px; color: var(--text); }
.clue .txt { flex: 1; font-size: 15px; line-height: 1.35; }
.clue .txt small { color: var(--text2); font-weight: 600; }
.clue.solved .txt { color: var(--ok-bd); }
.clue input {
  width: 110px; height: 34px; font: inherit; font-size: 15px; text-transform: uppercase;
  letter-spacing: 1px; padding: 0 8px; border-radius: var(--radius);
  border: 1.5px solid var(--cell-bd); background: var(--card); color: var(--text); font-weight: 600;
}
.clue input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.clue input.shake { animation: shake 0.3s; border-color: var(--bad-bd); }
.clue .ans { width: 110px; font-weight: 600; letter-spacing: 1px; }
.clue .reveal { font-size: 12px; padding: 4px 8px; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10;
}
.overlay[hidden] { display: none; }
.sheet {
  position: relative; background: var(--card); border-radius: 14px; padding: 20px 22px;
  max-width: 420px; width: 100%; max-height: 90vh; overflow: auto;
}
.sheet h2 { margin: 0 0 10px; font-size: 20px; }
.sheet p, .sheet li { font-size: 15px; line-height: 1.5; color: var(--text2); }
.sheet ol { padding-left: 20px; }
.close { position: absolute; top: 10px; right: 10px; border: none; font-size: 24px; padding: 2px 8px; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px !important; }
.sw { display: inline-block; width: 16px; height: 16px; border-radius: 4px; border: 1px solid; }
.sw.ok { background: var(--ok-bg); border-color: var(--ok-bd); }
.sw.bad { background: var(--bad-bg); border-color: var(--bad-bd); margin-left: 8px; }
.sw.hint { background: var(--hint-bg); border-color: var(--hint-bd); margin-left: 8px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; margin: 12px 0 16px; }
.stats b { display: block; font-size: 26px; }
.stats span { font-size: 12px; color: var(--muted); }
.sharebox {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap;
  background: var(--lane); border-radius: var(--radius); padding: 10px 12px; font-size: 14px; margin: 10px 0;
}
.row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.countdown { font-size: 13px; color: var(--muted); }
h1 { display: flex; align-items: center; justify-content: center; gap: 8px; }
.logo { width: 30px; height: 30px; }
.cell.given { color: var(--accent); }
.clue .hintbtn, .clue .reveal { font-size: 13px; font-weight: 600; padding: 5px 9px; border: 1.5px solid var(--cell-bd); }
.lane.ulane { background: var(--rail-gold); }
.cell.slot { border: 2px dashed var(--gold-bd); }
.cell.slot.ghost { color: var(--gold-bd); background: transparent; }
.cell.uber { background: var(--gold-bg); border: 1px solid var(--gold-bd); color: var(--gold-tx); }
.cell.slot.uber { border-style: solid; }
.clue.uber { padding-left: 22px; }
.clue.uber .tag { color: var(--gold-bd); }
.ulabel { font-size: 11px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; color: var(--gold-tx); background: var(--gold-bg); border: 1px solid var(--gold-bd); border-radius: 4px; padding: 1px 5px; vertical-align: 1px; }
.sw.gold { background: var(--gold-bg); border: 2px dashed var(--gold-bd); margin-left: 8px; }
.clue input {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600;
  letter-spacing: 3px; width: 124px;
}
.clue input::placeholder { color: var(--text); opacity: 0.7; letter-spacing: 3px; }
.status.next { color: var(--accent); font-weight: 600; }
.hbtns { display: flex; gap: 8px; }
header > .icon { margin-right: 44px; }  /* balance the two buttons on the right */
#soundBtn { display: flex; align-items: center; justify-content: center; }
#soundBtn .mute { display: none; }
#soundBtn.off .wave { display: none; }
#soundBtn.off .mute { display: inline; }
#soundBtn.off { color: var(--muted); }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 20; }
.cell.dance { animation: dance 0.6s ease-out both; }
@keyframes dance {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-14px) scale(1.12); }
  65% { transform: translateY(2px) scale(0.98); }
  100% { transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) { .cell.dance { animation: none; } }
.testbar { background: #d64541; color: #fff; font-size: 12px; padding: 6px 12px; margin: 0 -16px; }
.testbar .tb-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; margin: 3px 0; }
.testbar button { color: #fff; border-color: rgba(255, 255, 255, 0.6); padding: 2px 8px; font-size: 12px; }
.testbar input { width: 52px; font: inherit; padding: 1px 4px; border-radius: 4px; border: 1px solid rgba(255, 255, 255, 0.6); }
.solghost {
  position: absolute; display: flex; align-items: center; justify-content: center; pointer-events: none;
  border: 2px dashed #d64541; border-radius: 6px; color: #d64541; font-weight: 700; opacity: 0.55;
}
.status.pulse { animation: pulse 0.8s ease-in-out 3; }
@keyframes pulse { 50% { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { .status.pulse { animation: none; } }

/* Large text (Aa button): bigger, bolder clue list; the answer box moves under the clue
   so the clue keeps the full width. */
#textBtn { font-size: 15px; font-weight: 700; }
#textBtn[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
html.big .status { font-size: 18px; font-weight: 600; color: var(--text); }
html.big .clue { flex-wrap: wrap; row-gap: 8px; padding: 14px 6px; }
html.big .clue .tag { font-size: 18px; min-width: 38px; }
html.big .clue .txt { font-size: 21px; font-weight: 500; flex: 1 1 calc(100% - 60px); }
html.big .clue .txt small { font-size: 18px; }
html.big .clue form { flex: 1; margin-left: 48px; }
html.big .clue input { width: 100%; height: 50px; font-size: 24px; letter-spacing: 5px; }
html.big .clue .ans { width: auto; flex: 1; margin-left: 48px; font-size: 24px; letter-spacing: 4px; }
html.big .clue .hintbtn, html.big .clue .reveal { font-size: 17px; padding: 12px 16px; }
html.big .clue.uber { padding-left: 6px; }
html.big .ulabel { font-size: 14px; }
html.big .sheet p, html.big .sheet li { font-size: 18px; }
