:root {
  --paper: #fbf6e9;
  --paper-line: #e8dfc7;
  --ink: #2b2a33;
  --ink-soft: #6b6878;
  --card: #fffdf7;
  --accent: #7b4bd6;
  --accent-ink: #ffffff;
  --good: #2f9e44;
  --bad: #e03131;
  --shadow: 3px 4px 0 rgba(43, 42, 51, 0.85);

  --p0: #e8590c; --p1: #1c7ed6; --p2: #2f9e44; --p3: #c2255c;
  --p4: #f08c00; --p5: #7048e8; --p6: #0c8599; --p7: #862e9c;

  --wobble: 255px 15px 225px 15px / 15px 225px 15px 255px;
  --wobble-2: 15px 225px 15px 255px / 255px 15px 225px 15px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #23212b;
    --paper-line: #2e2b38;
    --ink: #f1ece0;
    --ink-soft: #a9a4b5;
    --card: #2f2c39;
    --accent: #a07cf0;
    --accent-ink: #1b1922;
    --shadow: 3px 4px 0 rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background-color: var(--paper);
  background-image: repeating-linear-gradient(transparent 0 31px, var(--paper-line) 31px 32px);
  color: var(--ink);
  font-family: "Patrick Hand", "Comic Sans MS", cursive;
  font-size: 20px;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

header {
  position: relative;
  text-align: center;
  padding: 18px 16px 4px;
}

.logo {
  margin: 0;
  font-family: "Gochi Hand", cursive;
  font-weight: 400;
  font-size: 44px;
  letter-spacing: 1px;
  transform: rotate(-2deg);
}
.logo span { color: var(--accent); }

.reset {
  position: absolute; top: 8px; left: 12px;
  font: inherit; font-size: 15px;
  background: none; border: none; padding: 4px;
  color: var(--ink-soft); text-decoration: underline; cursor: pointer;
}

.conn {
  position: absolute; top: 8px; right: 12px;
  font-size: 15px; color: var(--bad);
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 16px 40px;
}

.screen { display: flex; flex-direction: column; gap: 16px; }

h2 {
  margin: 0 0 10px;
  font-family: "Gochi Hand", cursive;
  font-weight: 400;
  font-size: 28px;
}

.sheet {
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: var(--wobble);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.sheet:nth-child(even) { border-radius: var(--wobble-2); }

.center { text-align: center; }
.note { color: var(--ink-soft); font-size: 17px; margin: 8px 0 0; min-height: 1em; }
.shout { font-size: 38px; margin: 0; transform: rotate(-1.5deg); }

/* ---------- form controls */

.input {
  width: 100%;
  font: inherit;
  font-size: 22px;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--wobble-2);
  padding: 10px 14px;
  outline: none;
}
.input:focus { border-color: var(--accent); }
.input.small { width: 90px; padding: 4px 8px; text-align: center; }

#join-form { display: flex; flex-direction: column; gap: 12px; }

.btn {
  font: inherit;
  font-size: 22px;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: var(--wobble);
  box-shadow: var(--shadow);
  padding: 10px 18px;
  cursor: pointer;
  transition: transform 0.08s;
}
.btn:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 rgba(43, 42, 51, 0.85); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.big { font-size: 28px; padding: 14px 18px; font-family: "Gochi Hand", cursive; }

.link {
  font: inherit; font-size: 16px;
  background: none; border: none; padding: 0; margin-top: 6px;
  color: var(--ink-soft); text-decoration: underline; cursor: pointer;
}

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row .btn { flex: 1 1 160px; }

/* ---------- players */

.players { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 12px;
  border: 2px solid var(--pc, var(--ink));
  border-radius: var(--wobble);
  color: var(--pc, var(--ink));
  background: var(--card);
}
.chip.me { background: var(--pc); color: #fff; }
.chip.offline { opacity: 0.45; }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--good); }
.chip.offline .dot { background: var(--ink-soft); }

.c0 { --pc: var(--p0); } .c1 { --pc: var(--p1); } .c2 { --pc: var(--p2); } .c3 { --pc: var(--p3); }
.c4 { --pc: var(--p4); } .c5 { --pc: var(--p5); } .c6 { --pc: var(--p6); } .c7 { --pc: var(--p7); }

/* ---------- settings */

.presets { display: flex; gap: 8px; flex-wrap: wrap; }
.presets .btn { flex: 1 1 60px; padding: 6px 8px; font-size: 20px; }
.presets .btn.on { background: var(--ink); color: var(--paper); }
.custom { display: block; margin-top: 10px; color: var(--ink-soft); }

/* ---------- drawing */

.timer {
  text-align: center;
  font-family: "Gochi Hand", cursive;
  font-size: 96px;
  line-height: 1;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}
.timer.low { color: var(--bad); animation: wiggle 0.5s infinite; }

@keyframes wiggle {
  0%, 100% { transform: rotate(-2deg); }
  50% { transform: rotate(2deg); }
}

.card {
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: var(--wobble);
  box-shadow: var(--shadow);
}

.card.secret {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 28px 16px 18px;
  cursor: pointer;
  transform: rotate(-1deg);
}
.card-label { color: var(--ink-soft); font-size: 17px; }
.card-word { font-family: "Gochi Hand", cursive; font-size: 54px; line-height: 1.1; text-align: center; }
.card-hint { color: var(--ink-soft); font-size: 15px; }
.card.secret.hidden .card-word { filter: blur(14px); user-select: none; }

/* ---------- voting / reveal */

.banner {
  text-align: center;
  font-family: "Gochi Hand", cursive;
  font-size: 30px;
  padding: 10px;
  border: 2px dashed var(--pc, var(--ink));
  border-radius: var(--wobble-2);
  color: var(--pc, var(--ink));
}
.banner.mine { background: var(--pc); color: #fff; border-style: solid; }

.turns { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; font-size: 17px; }
.turns .chip.done { opacity: 0.5; text-decoration: line-through; }
.turns .chip.now { background: var(--pc); color: #fff; }

.middle { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }

.word {
  position: relative;
  min-height: 84px;
  padding: 14px 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-align: center;
  font-family: "Gochi Hand", cursive;
  font-size: 26px;
  line-height: 1.1;
}
.word:nth-child(3n+1) { transform: rotate(-1.5deg); border-radius: var(--wobble-2); }
.word:nth-child(3n+2) { transform: rotate(1deg); }
.word:nth-child(3n) { transform: rotate(-0.5deg); }

button.word { cursor: pointer; }
button.word:disabled { cursor: default; }
.word.selected { outline: 4px solid var(--accent); outline-offset: 2px; }
.word.removed { opacity: 0.4; box-shadow: none; }
.word.removed .w { text-decoration: line-through 3px; }

.word .who { font-family: "Patrick Hand", cursive; font-size: 16px; color: var(--pc, var(--ink-soft)); }
.word.extra { border-style: dashed; }
.word.extra .who { color: var(--ink-soft); }
.word.removed.revealed { opacity: 1; }
.word.missed { outline: 3px dashed var(--bad); outline-offset: 2px; }

.badge {
  position: absolute; top: -10px; right: -8px;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: #fff;
  font-family: "Patrick Hand", cursive;
  font-size: 22px;
  border: 2px solid var(--ink);
}
.badge.good { background: var(--good); }
.badge.bad { background: var(--bad); }

.confirm {
  position: sticky; bottom: 12px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: var(--wobble);
  box-shadow: var(--shadow);
  padding: 12px 14px;
}
.confirm span { flex: 1 1 100%; text-align: center; }
.confirm .btn { flex: 1; }

.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 18px; }
.log .ok { color: var(--good); }
.log .ko { color: var(--bad); }
