@font-face { font-family: "KMini"; src: url("assets/fonts/kenney-mini-square.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "KFuture"; src: url("assets/fonts/kenney-future.ttf") format("truetype"); font-display: swap; }

:root {
  --ink: #1f1a24;
  --muted: #5d5566;
  --paper: #fbf8f3;
  --card: #ffffff;
  --line: #e4ddd2;
  --flat: #8a8494;
  --with: #d9622b;
  --accent: #2f6f6a;
  --box: #241c2e;
  --boxline: #f3e3c3;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
#app { max-width: 720px; margin: 0 auto; padding: 20px 14px 40px; }

.intro h1 { font-family: KFuture, system-ui, sans-serif; font-weight: normal; font-size: 30px; line-height: 1.1; margin: 0 0 10px; letter-spacing: .5px; }
.intro h1 em { color: var(--with); font-style: normal; }
.intro p { margin: 0 0 18px; color: var(--muted); font-size: 15px; }

/* ---------- trick card ---------- */
.trick {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 14px 12px;
  margin: 0 0 22px;
  box-shadow: 0 1px 0 rgba(0,0,0,.03);
}
.trick-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 2px; }
.trick-num { font-family: KFuture, system-ui, sans-serif; color: var(--with); font-size: 15px; }
.trick-title { font-family: KFuture, system-ui, sans-serif; font-weight: normal; font-size: 19px; margin: 0; letter-spacing: .3px; }
.trick-rule { margin: 2px 0 12px; color: var(--muted); font-size: 14.5px; }
.trick-rule b { color: var(--ink); font-weight: 600; }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.side { min-width: 0; display: flex; flex-direction: column; }
.side-label { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin: 0 0 5px; display: flex; align-items: center; gap: 6px; }
.side-label::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.side.flat .side-label { color: var(--flat); }
.side.with .side-label { color: var(--with); }

/* ---------- stage ---------- */
.stage {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  overflow: hidden;
  background: #3a5a3a;
  container-type: inline-size;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  outline: none;
  border: 2px solid transparent;
}
.side.flat .stage { border-color: #d9d5de; }
.side.with .stage { border-color: #f1c2a7; }
.stage:focus-visible { border-color: var(--accent); }
.stage.playable { cursor: pointer; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; display: block; }

/* dialogue box: narrow, centred low */
.dbox {
  position: absolute;
  left: 50%;
  bottom: 4.5%;
  transform: translateX(-50%);
  width: 76%;
  min-height: 21%;
  background: var(--box);
  border: 2px solid var(--boxline);
  border-radius: 4px;
  box-shadow: 0 0 0 2px var(--box), 0 3px 0 2px rgba(0,0,0,.25);
  color: #fff;
  font-family: KMini, ui-monospace, monospace;
  font-size: clamp(10px, 4.1cqw, 17px);
  line-height: 1.3;
  padding: 2.2cqw 3cqw 2.4cqw;
  opacity: 0;
  transition: opacity .15s;
  pointer-events: none;
}
.dbox.on { opacity: 1; }
.dbox .who { display: block; font-size: .8em; color: #ffcf6e; margin-bottom: 1px; letter-spacing: .04em; }
.dbox .who.wren { color: #8fd3ff; }
.dbox .who.tobin { color: #a8e07a; }
.dbox .who.narr { color: #c8bfd6; }
.dbox .who.smith { color: #ff9e7a; }
.dbox .more { position: absolute; right: 2.4cqw; bottom: 1.4cqw; font-size: .8em; color: #ffcf6e; opacity: 0; }
.dbox.wait .more { opacity: 1; animation: bob .6s ease-in-out infinite alternate; }
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(-2px); } }

.hint {
  position: absolute; left: 50%; top: 4%; transform: translateX(-50%);
  background: rgba(255,255,255,.94); color: var(--ink);
  font: 600 clamp(10px, 3.6cqw, 14px)/1.2 system-ui, sans-serif;
  padding: .45em .8em; border-radius: 999px; white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.hint.on { opacity: 1; }
.hint .bar { display: block; height: 4px; margin-top: 4px; background: #eee; border-radius: 2px; overflow: hidden; }
.hint .bar i { display: block; height: 100%; width: 0; background: var(--with); }

/* name cards (the bad version of name-budget) */
.cards { position: absolute; left: 0; right: 0; top: 4%; display: flex; flex-wrap: wrap; justify-content: center; gap: 1.4cqw; padding: 0 3cqw; pointer-events: none; }
.namecard {
  background: #fff6d8; color: #3b2a12; border: 2px solid #3b2a12; border-radius: 3px;
  font-family: KMini, monospace; font-size: clamp(8px, 3.3cqw, 13px); line-height: 1.1;
  padding: .3em .5em; animation: pop .25s ease-out both; box-shadow: 0 2px 0 rgba(0,0,0,.3);
}
.namecard small { display: block; font-size: .78em; opacity: .75; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* plant/payoff track */
.track { position: absolute; left: 16%; right: 6%; top: 4%; height: 5.5cqw; display: none; align-items: center; pointer-events: none; }
.track.on { display: flex; }
.track::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px; background: rgba(255,255,255,.55); transform: translateY(-50%); }
.track .dot { position: absolute; top: 50%; width: 3.2cqw; height: 3.2cqw; margin: -1.6cqw 0 0 -1.6cqw; border-radius: 50%; background: rgba(0,0,0,.35); border: 2px solid rgba(255,255,255,.7); transition: background .2s, transform .2s; }
.track .dot.lit { background: #ffcf6e; transform: scale(1.25); }
.track .dot.pay.lit { background: var(--with); }
.track .dot.miss.lit { background: #b9b2c4; }

/* chip, caption, question */
.chip {
  align-self: flex-start;
  margin-top: 7px; font: 600 12.5px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 4px 8px; border-radius: 6px; background: #f1eef5; color: #4b4458;
  transition: background .3s;
}
.side.with .chip { background: #fdebe1; color: #7a3412; }
.chip.flash { background: #fff1b8 !important; }
.caption { margin: 6px 0 0; font-size: 14px; line-height: 1.4; min-height: 3.9em; color: var(--ink); }
.caption .what { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; display: block; }
.caption.pending { color: #a39cab; }

.q { margin-top: 8px; padding: 8px 9px 9px; border-radius: 8px; background: #f6f3ee; border: 1px dashed #d9d0c2; font-size: 14px; display: none; }
.q.on { display: block; animation: fadein .3s ease-out; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.q p { margin: 0 0 6px; font-weight: 600; }
.q .opts { display: flex; flex-wrap: wrap; gap: 6px; }
.q button {
  font: 600 13.5px/1 system-ui, sans-serif; padding: 7px 11px; border-radius: 999px;
  border: 1px solid #cfc6b8; background: #fff; color: var(--ink); cursor: pointer;
}
.q button:hover { border-color: var(--ink); }
.q button.picked { background: var(--ink); color: #fff; border-color: var(--ink); }
.q button:disabled:not(.picked) { opacity: .45; cursor: default; }
.q .note { margin: 7px 0 0; font-size: 13.5px; color: var(--muted); display: none; }
.q.answered .note { display: block; }

.compare { margin: 10px 0 0; font-size: 14px; padding: 8px 10px; border-radius: 8px; background: #eef6f4; color: #1d4a46; display: none; }
.compare.on { display: block; animation: fadein .3s ease-out; }

.controls { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.controls button {
  font: 600 14px/1 system-ui, sans-serif; padding: 9px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--ink); background: var(--ink); color: #fff; display: inline-flex; align-items: center; gap: 6px;
}
.controls button.alt { background: #fff; color: var(--ink); }
.controls button[aria-pressed="true"] { background: var(--with); border-color: var(--with); color: #fff; }
.controls .solo-link { margin-left: auto; align-self: center; font-size: 12.5px; color: var(--muted); }

.credits { font-size: 13px; color: var(--muted); text-align: center; margin-top: 8px; }
.credits a, .solo-link { color: inherit; }

/* ---------- phone: stack the two sides ---------- */
@media (max-width: 560px) {
  #app { padding: 14px 10px 30px; }
  .intro h1 { font-size: 25px; }
  .trick { padding: 12px 10px 10px; }
  .pair { grid-template-columns: 1fr; gap: 16px; }
  .caption { min-height: 0; }
  .controls .solo-link { margin-left: 0; width: 100%; }
}

/* ---------- solo embed mode ---------- */
body.solo { background: transparent; }
body.solo #app { padding: 0; max-width: 720px; }
body.solo .intro, body.solo .credits { display: none; }
body.solo .trick { margin: 0; }
body.solo .solo-link { display: none; }

@media (prefers-reduced-motion: reduce) {
  .dbox.wait .more, .namecard, .q.on, .compare.on { animation: none; }
}
