@font-face {
  font-family: "KenneyMini";
  src: url("assets/kenney-fonts/kenney-mini.ttf") format("truetype");
  font-display: block;
}

:root {
  --ink: #23212a;
  --muted: #6b6775;
  --line: #e3dfd6;
  --card: #ffffff;
  --page: #f5f3ee;
  --bad: #b8432f;
  --bad-bg: #fbeae6;
  --good: #23824a;
  --good-bg: #e3f3e8;
  --gold: #f2c94c;
  --tri: #e2643c;
  --cir: #3b8fe2;
  --sq: #3fa35a;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
#app { max-width: 720px; margin: 0 auto; padding: 20px 12px 32px; }
h1 { font-size: 1.55rem; line-height: 1.2; margin: 0 0 .6rem; }
.intro p { margin: .4rem 0; }
.small { font-size: .9rem; color: var(--muted); }
.bad { color: var(--bad); }
.good { color: var(--good); }
.sym { font-weight: 700; }
.sym.tri { color: var(--tri); }
.sym.cir { color: var(--cir); }
.sym.sq { color: var(--sq); }
.ffchip { font-size: .85em; }
.foot { margin-top: 1.5rem; text-align: center; }

/* ---------- card ---------- */
.card {
  container-type: inline-size;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 16px 12px;
  margin: 18px 0;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.card.flash { outline: 3px solid var(--gold); outline-offset: 2px; }
.card h2 { font-size: 1.15rem; margin: 0; line-height: 1.3; display: flex; gap: .5rem; align-items: baseline; }
.card h2 .num {
  font-family: KenneyMini, monospace; font-size: .85rem; color: #fff; background: var(--ink);
  border-radius: 6px; padding: 1px 7px 2px; flex: none; position: relative; top: -2px;
}
.card h2 code { font-size: .72rem; color: var(--muted); font-weight: 500; margin-left: auto; white-space: nowrap; }
.card .blurb { margin: .35rem 0 .7rem; font-size: .95rem; color: #3e3a46; }

.controls { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; margin-bottom: 10px; }
.seg { display: inline-flex; border: 1px solid #cfcac0; border-radius: 8px; overflow: hidden; }
.seg button {
  font: inherit; font-size: .82rem; padding: 5px 10px; border: 0; background: #fff; color: var(--ink);
  cursor: pointer; min-height: 32px;
}
.seg button + button { border-left: 1px solid #cfcac0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.seg-label { font-size: .78rem; color: var(--muted); margin-right: -4px; }
.btn-replay {
  font: inherit; font-size: .82rem; padding: 5px 12px; min-height: 32px; border-radius: 8px;
  border: 1px solid #cfcac0; background: #fff; cursor: pointer; margin-left: auto;
}
.seg button:focus-visible, .btn-replay:focus-visible, .stage:focus-visible, .ingame-btn:focus-visible {
  outline: 3px solid var(--cir); outline-offset: 2px;
}

.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@container (max-width: 540px) {
  .panels { grid-template-columns: 1fr; gap: 18px; }
  .btn-replay { margin-left: 0; }
}

.panel-label {
  display: inline-block; font-size: .74rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px; margin-bottom: 6px;
}
.panel.left .panel-label { color: var(--bad); background: var(--bad-bg); }
.panel.right .panel-label { color: var(--good); background: var(--good-bg); }

.stage {
  position: relative; aspect-ratio: 9 / 7; border-radius: 10px; overflow: hidden;
  background: #1d1b22; touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.stage.playing { cursor: pointer; box-shadow: 0 0 0 2px var(--gold); }

.hud { position: absolute; top: 6px; left: 6px; display: flex; gap: 4px; flex-wrap: wrap; pointer-events: none; max-width: 70%; }
.pill {
  font-family: KenneyMini, monospace; font-size: 12px; line-height: 1; color: #fff;
  background: rgba(15,13,20,.78); border-radius: 5px; padding: 4px 6px 5px;
}
.pill.ff { background: var(--gold); color: #2a2100; }
.pill.np { background: rgba(15,13,20,.6); color: #ffd98a; }

.ingame-btn {
  position: absolute; top: 6px; right: 6px; font-family: KenneyMini, monospace; font-size: 13px;
  background: #fff3c9; color: #3a2a00; border: 2px solid #3a2a00; border-radius: 6px; padding: 4px 8px 5px;
  box-shadow: 0 2px 0 #3a2a00; cursor: pointer; min-height: 30px;
}
.ingame-btn[disabled] { cursor: default; }
.ingame-btn.pressed { transform: translateY(2px); box-shadow: 0 0 0 #3a2a00; background: #ffe38a; }

.hintbox {
  position: absolute; left: 6px; right: 6px; bottom: 6px; padding: 6px 9px 7px;
  background: rgba(18,16,26,.93); color: #fff; border: 2px solid var(--gold); border-radius: 7px;
  font-size: 13px; line-height: 1.3; animation: pop .18s ease-out;
}
.hintbox.dump { border-color: #e0614a; }
.hintbox .hb-title { font-family: KenneyMini, monospace; font-size: 11px; color: var(--gold); display: flex; gap: 6px; align-items: center; margin-bottom: 2px; }
.hintbox.dump .hb-title { color: #ff8a73; }
.hintbox .dots { letter-spacing: 2px; }
.hintbox .sym.tri { color: #ff8a62; }
.hintbox .sym.cir { color: #73b6ff; }
.hintbox .sym.sq { color: #6fd38a; }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

.stamp {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%) rotate(-7deg);
  font-family: KenneyMini, monospace; font-size: 22px; padding: 4px 12px 6px; border: 3px solid; border-radius: 8px;
  background: rgba(255,255,255,.92); pointer-events: none; animation: stamp .25s ease-out; white-space: nowrap;
}
.stamp.solved { color: var(--good); }
.stamp.quit { color: var(--bad); }
.stamp.spoiled { color: #b07400; }
@keyframes stamp { from { transform: translate(-50%, -50%) rotate(-7deg) scale(1.6); opacity: 0; } }

.caption { margin: 7px 0 0; font-size: .9rem; line-height: 1.4; min-height: 4.2em; }
.caption .t { font-family: KenneyMini, monospace; font-size: .78rem; color: var(--muted); margin-right: 4px; }
.stat { margin: 2px 0 0; font-size: .78rem; color: var(--muted); min-height: 1.2em; }

@container (max-width: 540px) {
  .caption { min-height: 2.9em; }
}

/* ---------- solo (embed) ---------- */
body.solo { background: transparent; }
body.solo #app { padding: 0; }
body.solo .intro, body.solo .foot { display: none; }
body.solo .card { margin: 0; }

@media (max-width: 420px) {
  #app { padding: 14px 8px 24px; }
  .card { padding: 12px 10px 10px; }
  .card h2 code { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .hintbox, .stamp { animation: none; }
}
