/* Culper — one stylesheet. Phone first: the board sits beside a video call. */
:root {
  --bg: #f6f1e7;
  --bg-2: #efe7d6;
  --ink: #1d1a16;
  --ink-2: #5d564b;
  --line: #d8cfbc;
  --red: #b3282d;
  --red-2: #f3d9da;
  --blue: #1f4e8c;
  --blue-2: #d8e3f3;
  --bystander: #cdbb92;
  --bystander-2: #efe6cf;
  --mole: #1a1a1a;
  --tile: #fffdf8;
  --ok: #2e7d4f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.05);
  --serif: Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 16px; -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; }
#app { max-width: 720px; margin: 0 auto; padding: 10px 10px calc(16px + env(safe-area-inset-bottom)); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; letter-spacing: .01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
p { margin: .4em 0; line-height: 1.4; }
small, .muted { color: var(--ink-2); }
a { color: var(--blue); }
button, input, select { font: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--tile); color: var(--ink); border-radius: var(--radius); padding: 10px 14px; box-shadow: var(--shadow); }
button:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
button.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
button.red { background: var(--red); color: #fff; border-color: var(--red); }
button.blue { background: var(--blue); color: #fff; border-color: var(--blue); }
button.ghost { background: transparent; box-shadow: none; }
button.small { padding: 6px 10px; font-size: .9rem; }
input[type=text], select { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: var(--tile); color: var(--ink); width: 100%; }
input[type=text]:focus, select:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--tile); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.err { color: var(--red); font-weight: 600; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--bg-2); }
.badge.red { background: var(--red-2); color: var(--red); }
.badge.blue { background: var(--blue-2); color: var(--blue); }
.badge.handler { background: var(--ink); color: var(--bg); }

/* ---------------------------------------------------------------- home */
.hero { text-align: center; padding: 28px 0 16px; }
.hero h1 { font-size: 2.4rem; }
.hero .sub { color: var(--ink-2); font-family: var(--serif); font-style: italic; }
.code-input { text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }

/* --------------------------------------------------------------- lobby */
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.team { border-radius: var(--radius); padding: 10px; border: 2px solid var(--line); background: var(--tile); }
.team.red { border-color: var(--red); }
.team.blue { border-color: var(--blue); }
.team h3 { font-family: var(--sans); font-size: .95rem; text-transform: uppercase; letter-spacing: .06em; }
.team.red h3 { color: var(--red); }
.team.blue h3 { color: var(--blue); }
.team ul { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.team li { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: .95rem; }
.team li.me { font-weight: 700; }
.unassigned { color: var(--ink-2); font-size: .9rem; }

/* ---------------------------------------------------------------- game */
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 6px 2px; }
.score { font-family: var(--serif); font-size: 1.7rem; font-weight: 700; line-height: 1; }
.score.red { color: var(--red); text-align: left; }
.score.blue { color: var(--blue); text-align: right; }
.turn { text-align: center; font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.turn.red { color: var(--red); }
.turn.blue { color: var(--blue); }
.timer { font-variant-numeric: tabular-nums; font-size: .85rem; color: var(--ink-2); text-align: center; }
.timer.low { color: var(--red); font-weight: 700; }

.cluebar { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 48px; padding: 6px 10px; margin: 4px 0 8px; border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--line); }
.cluebar .clue { font-family: var(--serif); font-size: 1.5rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.cluebar .num { font-size: 1.4rem; font-weight: 700; padding: 0 10px; border-left: 2px solid var(--line); }
.cluebar .left { font-size: .8rem; color: var(--ink-2); }
.cluebar.waiting { font-style: italic; color: var(--ink-2); font-family: var(--serif); }

.board { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.tile { position: relative; min-width: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; text-align: center; aspect-ratio: 5 / 3.6; padding: 4px; border-radius: 8px; background: var(--tile); border: 2px solid var(--line); box-shadow: var(--shadow); font-weight: 700; font-size: clamp(.62rem, 2.9vw, 1.05rem); line-height: 1.1; text-transform: uppercase; letter-spacing: .01em; word-break: normal; overflow-wrap: normal; hyphens: manual; user-select: none; transition: transform .08s ease; }
/* long single words shrink instead of splitting; classes set by app.js from the longest unbroken run */
.tile.long { font-size: clamp(.5rem, 2.25vw, .95rem); letter-spacing: 0; padding: 3px 2px; }
.tile.xlong { font-size: clamp(.4rem, 1.8vw, .85rem); letter-spacing: -.01em; padding: 3px 1px; }
.tile.tappable { cursor: pointer; }
.tile.tappable:active { transform: scale(.96); }
.tile.revealed { color: #fff; border-color: transparent; box-shadow: none; }
.tile.revealed.red { background: var(--red); }
.tile.revealed.blue { background: var(--blue); }
.tile.revealed.bystander { background: var(--bystander); color: var(--ink); }
.tile.revealed.mole { background: var(--mole); color: #fff; }
.tile.revealed .word { opacity: .92; }
/* key view: what the handler sees on unrevealed tiles */
.tile.key-red { border-color: var(--red); background: var(--red-2); }
.tile.key-blue { border-color: var(--blue); background: var(--blue-2); }
.tile.key-bystander { border-color: var(--bystander); background: var(--bystander-2); }
.tile.key-mole { border-color: var(--mole); background: #2a2a2a; color: #fff; }
.tile.key-mole::after { content: '✕'; position: absolute; top: 2px; right: 6px; font-size: .75rem; opacity: .8; }
.keybanner { text-align: center; font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; color: var(--bg); background: var(--ink); border-radius: 6px; padding: 4px; margin-bottom: 6px; }

.controls { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.clueform { display: grid; grid-template-columns: 1fr 88px auto; gap: 8px; }
.clueform select { padding: 10px 8px; }
.status { text-align: center; color: var(--ink-2); font-size: .95rem; }
.status b { color: var(--ink); }

.over { text-align: center; padding: 14px; border-radius: var(--radius); margin-bottom: 8px; color: #fff; }
.over.red { background: var(--red); }
.over.blue { background: var(--blue); }
.over.none { background: var(--ink-2); }
.over h2 { color: #fff; font-size: 1.5rem; }
.over .next { margin-top: 10px; font-size: .95rem; opacity: .95; }
.over .next button { margin-left: 6px; color: #fff; border-color: rgba(255,255,255,.5); }
.timer { font-size: 1.1rem; font-weight: 700; }
.timer.low { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* --------------------------------------------------------------- panels */
.tabs { display: flex; gap: 6px; margin: 14px 0 6px; flex-wrap: wrap; }
.tabs button { padding: 6px 10px; font-size: .88rem; }
.tabs button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.log { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.log li { padding: 8px 10px; border-radius: 8px; background: var(--tile); border: 1px solid var(--line); font-size: .92rem; }
.log li .who { font-weight: 700; }
.log .taps { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.chip { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: .78rem; font-weight: 700; color: #fff; text-transform: uppercase; }
.chip.red { background: var(--red); } .chip.blue { background: var(--blue); } .chip.bystander { background: var(--bystander); color: var(--ink); } .chip.mole { background: var(--mole); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--tile); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.stat .k { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.stat .v { font-family: var(--serif); font-size: 1.15rem; font-weight: 700; }
.words { display: flex; flex-wrap: wrap; gap: 6px; }
.words .w { padding: 3px 9px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line); font-size: .85rem; }
.help ol { padding-left: 20px; line-height: 1.45; }
footer { margin-top: 20px; text-align: center; font-size: .78rem; color: var(--ink-2); }
@media (min-width: 560px) { .tile { font-size: 1rem; } }
