:root {
  --paper: #fff4d6; --ink: #2b2118; --dim: #7a6a58; --line: #e6d6b0;
  --pop: #ff5a3c; --pop2: #2f7df6; --good: #22a35a; --card: #fffaf0;
  --font: "Comic Sans MS", "Chalkboard SE", "Segoe Print", ui-rounded, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--paper); background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 22px 22px; }
.app { max-width: 1100px; margin: 0 auto; padding: 18px 14px 30px; }
.top { text-align: center; margin-bottom: 14px; }
h1 { margin: 0; font-size: clamp(2.2rem, 8vw, 3.4rem); line-height: 1; transform: rotate(-2deg); color: var(--pop); text-shadow: 3px 3px 0 var(--ink); }
.tag { color: var(--dim); margin: 8px 0 0; }
.card { background: var(--card); border: 3px solid var(--ink); border-radius: 18px; padding: 20px 18px; box-shadow: 6px 6px 0 var(--ink); }
.card.narrow { max-width: 460px; margin: 0 auto; }
[hidden] { display: none !important; }
label, .label { display: block; color: var(--dim); font-size: .95rem; margin: 0 0 6px; }
input { width: 100%; font: inherit; font-size: 1.1rem; padding: 11px 12px; border-radius: 12px; border: 3px solid var(--ink); background: #fff; color: var(--ink); outline: none; }
input:focus { border-color: var(--pop2); }
#code { text-transform: uppercase; letter-spacing: .3em; text-align: center; font-weight: 800; }
button { font: inherit; font-weight: 800; font-size: 1rem; padding: 11px 16px; border: 3px solid var(--ink); border-radius: 12px; cursor: pointer; color: var(--ink); background: #ffd23c; box-shadow: 3px 3px 0 var(--ink); }
button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
button:disabled { opacity: .55; cursor: default; }
button.big { width: 100%; margin-top: 14px; font-size: 1.2rem; padding: 14px; background: var(--pop); color: #fff; }
button.ghost { width: 100%; margin-top: 10px; background: transparent; box-shadow: none; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }
.or { text-align: center; margin: 16px 0 10px; color: var(--dim); font-size: .85rem; }
.status, .hint { color: var(--dim); text-align: center; min-height: 1.2em; }
.code { font-size: 2.6rem; font-weight: 900; letter-spacing: .25em; text-align: center; margin: 4px 0; }
.players { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.players li { border: 2px solid var(--ink); border-radius: 999px; padding: 4px 12px; background: #fff; }
.players li.host::after { content: " ★"; color: var(--pop); }
.players li.away { opacity: .5; }

.bar-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.pill { border: 3px solid var(--ink); border-radius: 999px; padding: 4px 12px; background: #fff; font-weight: 800; white-space: nowrap; }
.timer { min-width: 3.2em; text-align: center; }
.timer.low { background: var(--pop); color: #fff; }
.word { flex: 1; text-align: center; font-size: clamp(1.1rem, 4vw, 1.8rem); font-weight: 900; letter-spacing: .12em; }
.stage { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 12px; }
.canvas-wrap { position: relative; aspect-ratio: 4 / 3; background: #fff; border: 3px solid var(--ink); border-radius: 14px; box-shadow: 5px 5px 0 var(--ink); overflow: hidden; touch-action: none; }
canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: rgba(255, 244, 214, .94); text-align: center; padding: 16px; }
.overlay h2 { margin: 0; font-size: 1.6rem; }
.overlay .choices { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.overlay .reveal-word { font-size: 2.2rem; font-weight: 900; color: var(--pop); }
.side { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.scores { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.scores li { display: flex; justify-content: space-between; gap: 8px; border: 2px solid var(--ink); border-radius: 10px; padding: 5px 10px; background: #fff; }
.scores li.drawing { background: #ffe9a8; }
.scores li.got { background: #d6f5e1; }
.scores .gain { color: var(--good); font-weight: 800; margin-left: auto; margin-right: 8px; }
.chat { list-style: none; margin: 0; padding: 8px; flex: 1; min-height: 140px; max-height: 300px; overflow-y: auto; border: 2px solid var(--ink); border-radius: 10px; background: #fff; font-size: .95rem; }
.chat li { padding: 2px 0; overflow-wrap: anywhere; }
.chat li.got { color: var(--good); font-weight: 800; }
.chat li.close { color: var(--pop2); font-weight: 800; }
.chat li.sys { color: var(--dim); font-style: italic; }
.draw-col { min-width: 0; }
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.colors { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 34px; height: 34px; padding: 0; border-radius: 50%; box-shadow: 2px 2px 0 var(--ink); }
.swatch.on, .size.on { outline: 3px solid var(--pop2); outline-offset: 2px; }
.size { width: 42px; padding: 6px 0; background: #fff; }
.tool { background: #fff; }
.foot { text-align: center; color: var(--dim); font-size: .85rem; margin-top: 18px; }
@media (max-width: 760px) {
  .stage { grid-template-columns: 1fr; }
  .chat { max-height: 160px; }
}
