:root {
  --bg: #2a211b; --ink: #fbf3e6; --dim: #c9b9a3; --wood: #a8743f; --accent: #f0b53f;
  --g: #46b450; --y: #e7b53a; --n: #8b9096;
  --hud: 92px; --bar: calc(84px + env(safe-area-inset-bottom));
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif, "Noto Color Emoji";
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: radial-gradient(ellipse at 50% 40%, #3d3026, var(--bg) 70%); color: var(--ink); font-family: var(--font); -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }

#c { position: fixed; left: 0; right: 0; top: calc(var(--hud) + env(safe-area-inset-top)); bottom: var(--bar); width: 100%; height: calc(100% - var(--hud) - var(--bar) - env(safe-area-inset-top)); touch-action: none; display: block; }

#hud { position: fixed; top: 0; left: 0; right: 0; padding: calc(8px + env(safe-area-inset-top)) 12px 4px; z-index: 2; }
#hud .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#h-title { font-size: 17px; white-space: nowrap; letter-spacing: 0.2px; }
.btns { display: flex; gap: 6px; }
.btns button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid #5a4636; background: #3a2d23; font-size: 19px; }
#mute.off { opacity: 0.45; text-decoration: line-through; }
#ends { display: flex; justify-content: space-between; align-items: baseline; margin-top: 6px; font-size: 13px; color: var(--dim); }
#ends b { color: var(--ink); }
#ends .q { font-style: italic; color: var(--accent); }

#bar { position: fixed; left: 0; right: 0; bottom: 0; height: var(--bar); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 10px; align-items: stretch; z-index: 2; }
#hist-btn { flex: 0 0 auto; min-width: 104px; border-radius: 14px; border: 1px solid #5a4636; background: #3a2d23; font-size: 14px; }
#check { flex: 1; border-radius: 14px; border: 0; background: #6a5442; color: #fff; font-size: 19px; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; transition: background 0.2s, transform 0.1s; }
#check.ready { background: linear-gradient(#f3c14c, #d89a22); color: #2a1a08; box-shadow: 0 4px 0 #8a5c12; }
#check:active { transform: translateY(2px); }
#pips { display: flex; gap: 5px; }
#pips i { width: 9px; height: 9px; border-radius: 50%; background: currentColor; opacity: 0.9; }
#pips i.used { opacity: 0.25; }

#history { position: fixed; left: 8px; right: 8px; bottom: calc(var(--bar) + 4px); max-height: 50vh; overflow: auto; background: #352920f2; border: 1px solid #5a4636; border-radius: 16px; padding: 10px 12px; z-index: 3; transform: translateY(30px); opacity: 0; pointer-events: none; transition: transform 0.2s, opacity 0.2s; }
body.show-hist #history { transform: none; opacity: 1; pointer-events: auto; }
#history h3 { margin: 0 0 8px; font-size: 14px; color: var(--dim); font-weight: 600; }
.row { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin-bottom: 6px; }
.cell { display: block; aspect-ratio: 1; border-radius: 7px; background: #4a3a2e; padding: 2px; }
.cell img { width: 100%; height: 100%; display: block; }
.cell.f2 { background: var(--g); } .cell.f1 { background: var(--y); } .cell.f0 { background: var(--n); }
.dim { color: var(--dim); font-size: 13px; }

@media (min-width: 1000px) {
  #c { right: 300px; width: calc(100% - 300px); }
  #history { left: auto; right: 12px; top: calc(var(--hud) + 8px); bottom: calc(var(--bar) + 8px); width: 276px; max-height: none; transform: none; opacity: 1; pointer-events: auto; background: #2f241cd0; }
  #hist-btn { display: none; }
  #bar { right: 300px; justify-content: center; }
  #check { flex: 0 1 380px; }
  #ends { margin-right: 300px; }
}
@media (min-width: 700px) { :root { --hud: 96px; } #h-title { font-size: 22px; } #ends { font-size: 15px; } }

#tip { position: fixed; z-index: 5; pointer-events: none; background: #fbf3e6; color: #2a1a08; padding: 8px 11px; border-radius: 10px; max-width: 230px; font-size: 13px; opacity: 0; transition: opacity 0.12s; box-shadow: 0 6px 18px #0007; }
#tip.on { opacity: 1; }
#tip b { display: block; font-size: 15px; }
#tip em { display: block; color: #2f7d36; font-style: normal; font-weight: 600; margin-top: 3px; }

#toast { position: fixed; left: 50%; top: calc(var(--hud) + 14px); transform: translate(-50%, -10px); background: #fbf3e6; color: #2a1a08; padding: 9px 15px; border-radius: 12px; font-size: 15px; opacity: 0; transition: 0.2s; pointer-events: none; z-index: 6; white-space: pre-line; max-width: 90vw; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

#panel { position: fixed; inset: 0; background: #120c08a8; display: flex; align-items: center; justify-content: center; z-index: 4; padding: 12px; }
#panel.hidden { display: none; }
.card { background: #f8efe1; color: #2a1d12; border-radius: 20px; padding: 18px 18px 14px; width: min(440px, 100%); max-height: calc(100% - 8px); overflow: auto; box-shadow: 0 20px 50px #000a; }
.card h2 { margin: 0 0 8px; font-size: 24px; }
.card p { margin: 8px 0; line-height: 1.4; }
.card .lead { font-size: 17px; }
.card .dim { color: #7d6a55; }
.card .big, .card .two button, .card .ghost { width: 100%; min-height: 48px; border-radius: 14px; border: 0; background: #d89a22; color: #2a1a08; font-weight: 700; font-size: 17px; margin-top: 10px; }
.card .two { display: flex; gap: 8px; } .card .two button { background: #e7d8c2; font-weight: 600; font-size: 15px; }
.card .ghost { background: none; color: #7d6a55; font-weight: 500; margin-top: 4px; }
.key { list-style: none; padding: 0; margin: 6px 0; } .key li { display: flex; align-items: center; gap: 10px; margin: 5px 0; } .key .cell { width: 22px; }
.opts { display: grid; gap: 8px; margin-top: 12px; }
.opt { text-align: left; min-height: 52px; border-radius: 14px; border: 2px solid #d8c4a6; background: #fff8ec; padding: 10px 12px; font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.opt:hover { border-color: #d89a22; }
.opt kbd { font: 600 12px var(--font); background: #e7d8c2; border-radius: 6px; padding: 3px 7px; }
body.touch .opt kbd { display: none; }
.verdict { font-weight: 700; font-size: 16px; } .verdict.ok { color: #2f7d36; } .verdict.no { color: #a33b2a; }
.rule { font-size: 26px; line-height: 1.15; }
.joke { font-style: italic; color: #6a5440; }
.score { font-weight: 600; }
.before { display: flex; align-items: center; gap: 8px; opacity: 0.8; } .before .lbl { font-size: 12px; color: #7d6a55; width: 34px; } .before .row { flex: 1; margin: 0; }
.row.mini .cell { background: #e2d2bb; }
.tidy { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0; }
.tidy .item { background: #fff8ec; border-radius: 10px; padding: 4px; text-align: center; border: 2px solid var(--g); }
.tidy img { width: 100%; max-width: 64px; aspect-ratio: 1; display: block; margin: 0 auto; }
.tidy b { display: block; font-size: 11px; line-height: 1.15; } .tidy span { display: block; font-size: 11px; color: #6a5440; }
.foot { text-align: center; font-size: 13px; color: #7d6a55; } .foot a { color: #9a5e10; }
.shelf { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 10px 0; background: linear-gradient(#0000 calc(100% - 6px), #a8743f 0); }
.drawer { background: #ead9bf; border-radius: 10px; padding: 6px; border: 2px solid #c79f6c; font-size: 12px; }
.drawer .dh { display: flex; justify-content: space-between; margin-bottom: 4px; }
.drawer .slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; background: #35505e; border-radius: 6px; padding: 3px; min-height: 64px; }
.drawer .slots img { width: 100%; aspect-ratio: 1; }
.drawer p { margin: 4px 0 0; font-size: 11px; line-height: 1.2; min-height: 2.4em; }
.drawer.missed { background: none; border: 2px dashed #c9b9a3; color: #9a8a75; } .drawer.missed .slots { background: none; }
.drawer.open .slots { background: #35505e88; }

/* the end-of-drawer vote and fake door */
.card .ask { border-top: 1px solid #e3d3bc; margin-top: 12px; padding-top: 4px; }
.card .ask .q { font-size: 13px; color: #7d6a55; margin: 6px 0; text-align: center; }
.card .ask .q a { color: #a06a1c; }
.card .ask .chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }
.card .ask .chips button { min-height: 44px; padding: 0 12px; border-radius: 22px; border: 1px solid #d8c4a6; background: #fff8ec; font-size: 13px; font-weight: 600; color: #2a1d12; }
.card #door button { min-height: 44px; width: 100%; margin: 6px 0 2px; padding: 6px 12px; border-radius: 14px; border: 1px dashed #d89a22; background: #fbeed3; color: #8a5a12; font-size: 13px; font-weight: 600; }
