/* Monetkey's page (SPEC 7, 8). One centred column: Mo up top, the canvas
   in its gilt frame in the middle and as big as the screen allows, the
   play below it. A gallery at night: a warm dark wall, gilt, vermilion.
   Forked from Logoat's scoreboard; the variable names are Logoat's. */
:root {
  color-scheme: dark;
  --night-950: #110d0b;
  --night-900: #1b1512;
  --night-800: #261e19;
  --night-700: #33281f;
  --line: #45372b;
  --cream: #f3ead8;
  --cream-dim: #b9ab96;
  --amber: #e8c16a;
  --amber-hot: #f3d690;
  --turf: #c8302a;
  --turf-hot: #dd4a3f;
  --yes: #7fa65a;
  --bad: #ff6b6b;
  --gilt-dark: #7a5a22;
  --gilt: #c99a3e;
  --gilt-hi: #f0d38a;
  --font: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --col: 560px;
}
* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(ellipse at 50% -10%, #3a2a1c 0%, var(--night-900) 55%, var(--night-950) 100%) fixed;
  color: var(--cream);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
}
button, input { font: inherit; color: inherit; }
button {
  background: var(--night-800);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 13px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--cream-dim); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--turf); border-color: var(--turf); color: #fff7ea; font-weight: bold; }
button.primary:hover:not(:disabled) { background: var(--turf-hot); border-color: var(--turf-hot); }
button.big { font-size: 1.2em; padding: 11px 18px; width: 100%; }
[hidden] { display: none !important; }
.dim { color: var(--cream-dim); }
.small { font-size: 12px; }
.warn { color: var(--amber); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* ---- the shell ---- */
.app { min-height: 100dvh; display: flex; flex-direction: column; padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.testing { margin: 0; padding: 7px 16px; text-align: center; font-size: 13px; background: repeating-linear-gradient(135deg, #3a2a12 0 12px, #33250f 12px 24px); color: var(--amber-hot); border-bottom: 1px solid var(--gilt-dark); }
.testing b { color: var(--amber); }
.topbar { display: flex; align-items: center; gap: 6px; padding: 8px 16px; border-bottom: 1px solid var(--line); max-width: var(--col); width: 100%; margin: 0 auto; }
.wordmark { margin: 0; line-height: 0; }
#wordmark { image-rendering: pixelated; height: 21px; }
button.icon { width: 36px; height: 32px; padding: 0; font-weight: bold; }
.bars { display: inline-flex; gap: 2px; align-items: flex-end; height: 14px; }
.bars i { display: block; width: 4px; background: var(--cream); }
.bars i:nth-child(1) { height: 7px; }
.bars i:nth-child(2) { height: 14px; }
.bars i:nth-child(3) { height: 10px; }
.gear { font-size: 17px; line-height: 1; }

.col { width: 100%; max-width: var(--col); margin: 0 auto; padding: 8px 16px 24px; display: flex; flex-direction: column; gap: 10px; flex: 1; }

/* ---- Mo, up top ---- */
.mo-strip { display: flex; align-items: center; gap: 10px; min-height: 64px; }
#mo { image-rendering: pixelated; flex: none; width: 88px; height: 80px; }
.bubble {
  position: relative; margin: 0; padding: 8px 12px; flex: 1;
  background: var(--cream); color: var(--night-900); border-radius: 8px; font-weight: bold; font-size: 14px; line-height: 1.3;
  min-height: 2.6em; display: flex; align-items: center;
}
.bubble::before { content: ""; position: absolute; left: -8px; top: 50%; margin-top: -6px; border: 6px solid transparent; border-right: 8px solid var(--cream); border-left: 0; }
.bubble.pop { animation: pop 0.28s ease-out; }
@keyframes pop { 0% { transform: scale(0.92); } 60% { transform: scale(1.03); } 100% { transform: scale(1); } }

/* ---- the canvas in its frame: the centre of everything ---- */
.board-wrap {
  align-self: center; width: min(100%, 520px, calc(100dvh - 330px)); min-width: min(100%, 280px);
  aspect-ratio: 1; padding: 14px; border-radius: 3px;
  /* A gilt frame: a bevel of three golds, with a dark inner lip. */
  background:
    linear-gradient(135deg, var(--gilt-hi) 0%, var(--gilt) 22%, var(--gilt-dark) 50%, var(--gilt) 78%, var(--gilt-hi) 100%);
  box-shadow: inset 0 0 0 2px var(--gilt-dark), inset 0 0 0 5px var(--gilt-hi), inset 0 0 0 7px var(--gilt-dark), 0 14px 34px rgba(0, 0, 0, 0.55);
}
#board { display: block; width: 100%; height: 100%; image-rendering: pixelated; background: #e9e0cc; box-shadow: 0 0 0 2px #2a1d10; }
.board-wrap.win { box-shadow: inset 0 0 0 2px var(--gilt-dark), inset 0 0 0 5px var(--gilt-hi), inset 0 0 0 7px var(--gilt-dark), 0 14px 34px rgba(0, 0, 0, 0.55), 0 0 60px rgba(240, 211, 138, 0.45); }
.board-wrap.shake { animation: shake 0.22s linear; }
@keyframes shake { 25% { transform: translate(-3px, 1px); } 50% { transform: translate(3px, -1px); } 75% { transform: translate(-2px, 0); } }
.caption { margin: -2px 0 0; text-align: center; color: var(--amber); font-weight: bold; min-height: 1.45em; letter-spacing: 0.04em; }

/* ---- the panel under the board ---- */
.panel { display: flex; flex-direction: column; gap: 10px; }
.view { display: flex; flex-direction: column; gap: 10px; }
.view h2 { margin: 0; font-size: 16px; }
.note { margin: 0; }
.howto { margin: 0; padding-left: 1.4em; }
.howto li { margin: 3px 0; }
.countdown { margin: 0; color: var(--cream-dim); }

.play-head { display: flex; align-items: center; gap: 10px; }
.pips { display: inline-flex; gap: 4px; }
.pips i { width: 14px; height: 14px; border-radius: 3px; background: var(--night-700); border: 1px solid var(--line); display: block; }
.pips i.used { background: var(--amber); border-color: var(--amber); }
.pips i.won { background: var(--turf); border-color: var(--turf); }
.guess-count { font-weight: bold; }
.guess-count.last { color: var(--amber); }
.guess { position: relative; display: flex; gap: 8px; }
.guess input { flex: 1; min-width: 0; background: var(--night-950); border: 1px solid var(--line); border-radius: 6px; padding: 9px 11px; font-size: 16px; }
.dropdown { position: absolute; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--night-800); border: 1px solid var(--line); border-radius: 6px; z-index: 5; max-height: 300px; overflow-y: auto; overscroll-behavior: contain; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); }
.dropdown li { padding: 6px 8px; border-radius: 4px; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.dropdown li[aria-selected="true"], .dropdown li:hover { background: var(--line); }
.dropdown .lg { margin-left: auto; font-size: 11px; color: var(--cream-dim); }
.message { margin: 0; min-height: 1.45em; color: var(--amber); }

.guesses { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.guesses li { display: grid; grid-template-columns: 40px 1fr auto auto; gap: 10px; align-items: center; background: var(--night-800); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px 6px 6px; cursor: pointer; }
.guesses li.fresh { animation: flash 1s ease-out; }
.guesses li.peek { border-color: var(--amber); }
.guesses li.right { border-color: var(--yes); background: #23301a; }
@keyframes flash { from { background: var(--night-700); border-color: var(--amber); } }
.guesses .name { overflow: hidden; min-width: 0; line-height: 1.25; }
.guesses .name b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: bold; }
.guesses .name .by { display: block; font-size: 12px; color: var(--cream-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { font-size: 11px; padding: 2px 6px; border-radius: 4px; border: 1px solid var(--line); color: var(--cream-dim); white-space: nowrap; }
.chip.yes { background: var(--yes); border-color: var(--yes); color: var(--night-950); font-weight: bold; }
.chip .arrow { font-weight: bold; color: var(--amber); }
.chip.yes .arrow { color: var(--night-950); }
.pct { font-weight: bold; min-width: 3.6em; text-align: right; }
.pct .bar { display: block; height: 4px; margin-top: 3px; background: var(--night-700); border-radius: 2px; overflow: hidden; }
.pct .bar i { display: block; height: 100%; background: var(--amber); }
.thumb { width: 40px; height: 40px; image-rendering: pixelated; border-radius: 2px; background: #2e2620; display: block; box-shadow: 0 0 0 1px var(--gilt-dark); }
.thumb.big { width: 64px; height: 64px; }

.headline { margin: 0; font-size: 20px; }
.headline:focus { outline: none; }
.answer { display: flex; align-items: center; gap: 12px; font-size: 17px; }
.compare { margin: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.stat-grid b { display: block; font-size: 20px; }
.stat-grid span { font-size: 12px; color: var(--cream-dim); }
.dist { display: grid; grid-template-columns: 1.6em 1fr; gap: 3px 6px; align-items: center; margin-top: 8px; }
.dist .dist-bar { display: block; background: var(--line); color: var(--cream); text-align: right; padding: 0 6px; border-radius: 3px; min-width: 1.6em; }
.dist .dist-bar.you { background: var(--turf); color: #fff7ea; }
.manual-copy { width: 100%; background: var(--night-950); color: var(--cream); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font: inherit; resize: none; }
.back { align-self: flex-start; }
.seg { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; display: flex; gap: 16px; margin: 0; }
.seg legend { padding: 0 4px; color: var(--cream-dim); font-size: 13px; }
.seg label, .check { display: flex; gap: 6px; align-items: center; cursor: pointer; }

/* ---- the footer ---- */
.foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.official-home, .affiliation { margin: 0 0 6px; font-size: 12px; color: var(--cream-dim); }
.footer { font-size: 12px; color: var(--cream-dim); margin: 0; }
.more { color: var(--amber); font-size: 13px; }
.sources { margin: 0; padding-left: 1.4em; font-size: 12px; color: var(--cream-dim); max-height: 50vh; overflow: auto; }
.sources a { color: var(--cream); }
.linkish { background: none; border: none; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; }

/* ---- confetti (fx.js) ---- */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 20; image-rendering: pixelated; width: 100vw; height: 100vh; }

@media (max-width: 520px) {
  .col { padding: 6px 12px 20px; gap: 8px; }
  #mo { width: 66px; height: 60px; }
  .mo-strip { min-height: 54px; }
  .bubble { font-size: 13px; }
  .board-wrap { padding: 7px; width: min(100%, calc(100dvh - 300px)); }
}
@media (prefers-reduced-motion: reduce) {
  .bubble.pop, .guesses li.fresh, .board-wrap.shake { animation: none; }
}
body.reduced .bubble.pop, body.reduced .guesses li.fresh, body.reduced .board-wrap.shake { animation: none; }
