/* Sketchel styles. Built from the agreed draw-guess concept design system. */
@font-face {
  font-family: Outfit;
  src: url("/Outfit.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --paper: #FFE8B8;
  --paper-2: #FFD789;
  --bg: #FFD36A;
  --ink: #1A2330;
  --text: #1A2330;
  --muted: #4E5540;
  --card: #FFF8E8;
  --field: #FFFDF7;
  --canvas: #FFFDF7;
  --coral: #FF3D2E;
  --gold: #FFC107;
  --teal: #12B3A8;
  --violet: #7B5CFF;
  --good: #1F9A5A;
  --shadow: #1A2330;
  --blob-opacity: 1;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1B2230;
    --paper-2: #252E3F;
    --bg: #151B26;
    --text: #FFF3DA;
    --muted: #D6CDB8;
    --card: #263043;
    --field: #FFFDF7;      /* inputs stay light for legibility */
    --canvas: #FFFDF7;     /* the drawing canvas always stays light */
    --shadow: #05070B;
    --blob-opacity: .45;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font-family: Outfit, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
body { position: fixed; inset: 0; }

#bg {
  position: fixed; inset: 0;
  background-color: var(--bg);
  pointer-events: none;
}
#bg::before {
  content: ""; position: absolute; inset: 0;
  background-image: url("/party-bg.svg");
  background-size: cover;
  background-position: center top;
  opacity: var(--blob-opacity);
}

#app {
  position: absolute; inset: 0;
  display: flex; justify-content: center;
}

.screen {
  width: 100%;
  max-width: 480px;
  height: 100%;
  padding: calc(var(--safe-t) + 14px) calc(var(--safe-r) + 20px) calc(var(--safe-b) + 18px) calc(var(--safe-l) + 20px);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.screen.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.screen.scroll > * { flex-shrink: 0; }
.spacer { flex: 1 1 auto; min-height: 12px; }
.grow { flex: 1 1 auto; min-height: 0; }

/* ---------- type ---------- */
.logo {
  width: 96px; height: 96px;
  border-radius: 28px;
  background: var(--ink);
  display: grid; place-items: center;
  margin: 18px auto 16px;
  border: 3px solid var(--ink);
  box-shadow: 6px 6px 0 var(--coral);
  transform: rotate(-4deg);
  flex: 0 0 auto;
}
.logo svg { width: 70px; height: 70px; }
.logo.small { width: 64px; height: 64px; border-radius: 20px; margin: 4px auto 12px; box-shadow: 4px 4px 0 var(--coral); }
.logo.small svg { width: 46px; height: 46px; }
@media (prefers-color-scheme: dark) { .logo { border-color: #FFF3DA; } }

h1 {
  text-align: center;
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1.05;
}
.tag { text-align: center; margin-top: 10px; font-size: 19px; font-weight: 750; }
.tag .c1 { color: #E8281A; } .tag .c2 { color: #0E8F86; } .tag .c3 { color: #6A48F0; }
@media (prefers-color-scheme: dark) { .tag .c1 { color: #FF7A6E; } .tag .c2 { color: #3FD6CB; } .tag .c3 { color: #A994FF; } }

.kicker {
  text-align: center; font-size: 14px; font-weight: 800;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.title {
  text-align: center; font-size: 30px; font-weight: 800;
  letter-spacing: -0.04em; line-height: 1.1; margin: 6px 0 6px;
}
.sub { text-align: center; font-size: 16px; font-weight: 650; line-height: 1.35; opacity: .85; margin-bottom: 14px; }
.small-note { font-size: 14px; font-weight: 600; line-height: 1.4; opacity: .85; }
.center { text-align: center; }
.label { font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; margin: 14px 2px 8px; }

/* ---------- buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 60px;
  width: 100%;
  border-radius: 18px;
  font: inherit;
  font-size: 19px; font-weight: 800; letter-spacing: -0.02em;
  border: 2.5px solid var(--ink);
  color: var(--ink);
  background: var(--card);
  box-shadow: 0 5px 0 var(--shadow);
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
  transition: transform .06s ease, box-shadow .06s ease;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--shadow); }
.btn + .btn { margin-top: 14px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.coral { background: var(--coral); color: #fff; }
.btn.gold { background: var(--gold); }
.btn.teal { background: var(--teal); color: #fff; }
.btn.violet { background: var(--violet); color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--text); min-height: 48px; text-decoration: underline; text-underline-offset: 3px; }
.btn.ghost:active { transform: none; }
.btn.sm { min-height: 46px; font-size: 16px; border-radius: 14px; box-shadow: 0 4px 0 var(--shadow); width: auto; padding: 0 16px; }
.btn .ico { width: 24px; height: 24px; flex: 0 0 24px; }
.btn-row { display: flex; gap: 12px; }
.btn-row .btn { margin-top: 0; }
@media (prefers-color-scheme: dark) {
  .btn { border-color: #05070B; }
  .btn:not(.coral):not(.gold):not(.teal):not(.violet):not(.ghost) { color: var(--text); }
}

.links { display: flex; justify-content: center; gap: 8px; margin-top: 14px; }
.link {
  min-height: 44px; padding: 0 14px; display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-size: 16px; font-weight: 800; color: var(--text);
  background: none; border: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.iconbtn {
  min-width: 44px; height: 44px; border-radius: 14px;
  border: 2px solid var(--ink); background: var(--card); color: var(--text);
  display: inline-grid; place-items: center; font: inherit; font-weight: 800; font-size: 15px;
  cursor: pointer; padding: 0 10px;
  box-shadow: 0 3px 0 var(--shadow);
}
.iconbtn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--shadow); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 46px; margin-bottom: 8px; }
.topbar .ttl { font-size: 18px; font-weight: 800; }

/* ---------- forms ---------- */
.field {
  width: 100%; min-height: 56px;
  border-radius: 16px; border: 2.5px solid var(--ink);
  background: var(--field); color: #1A2330;
  font: inherit; font-size: 18px; font-weight: 700;
  padding: 0 16px;
  outline: none;
  -webkit-appearance: none; appearance: none;
}
.field::placeholder { color: #8A8370; }
.field:focus { box-shadow: 0 0 0 3px var(--gold); }
.field.code-input { text-align: center; font-size: 34px; letter-spacing: .3em; text-transform: uppercase; padding-left: calc(16px + .3em); min-height: 70px; }

.seg { display: flex; gap: 6px; background: var(--card); border: 2px solid var(--ink); border-radius: 16px; padding: 4px; }
.seg button {
  flex: 1; min-height: 44px; border-radius: 12px; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 16px; font-weight: 800; cursor: pointer;
}
.seg button.on { background: var(--ink); color: #fff; }
@media (prefers-color-scheme: dark) { .seg button.on { background: var(--gold); color: #1A2330; } .seg { border-color: #05070B; } }

.player-edit { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.player-edit .field { flex: 1; }

.card {
  background: var(--card); border: 2.5px solid var(--ink); border-radius: 22px;
  padding: 16px; box-shadow: 0 5px 0 var(--shadow);
}
.card + .card { margin-top: 14px; }
@media (prefers-color-scheme: dark) { .card { border-color: #05070B; } }

/* ---------- players / scores ---------- */
.avatar {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 800; font-size: 16px; color: #fff;
  border: 2px solid var(--ink);
}
.players { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 14px; margin: 4px 0 12px; }
.player { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 14px; font-weight: 800; width: 64px; text-align: center; }
.player span { max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player.off { opacity: .45; }
.player.empty .avatar { background: var(--card); color: var(--text); border-style: dashed; }
.board { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 2px solid var(--ink); border-radius: 16px;
  padding: 10px 14px; font-size: 18px; font-weight: 800; min-height: 58px;
}
.row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.win { background: var(--gold); color: #1A2330; box-shadow: 0 4px 0 var(--shadow); }
.pts { margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pts small { font-size: 14px; margin-left: 6px; color: #0E7F57; }
.row.win .pts small { color: #1A2330; }
@media (prefers-color-scheme: dark) { .pts small { color: #5BE3A6; } .row { border-color: #05070B; } }

/* ---------- play screens ---------- */
.hud { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 46px; margin-bottom: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: #B8F3EC; color: #1A2330;
  border: 2px solid var(--ink); border-radius: 999px;
  padding: 6px 12px; font-weight: 800; font-size: 15px; white-space: nowrap;
}
.pill.gold { background: var(--gold); }
.pill.warn { background: #FFD1CC; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--good); }
.timer {
  background: var(--card); color: var(--text); border: 2px solid var(--ink); border-radius: 999px;
  padding: 6px 12px; font-variant-numeric: tabular-nums; font-weight: 800; font-size: 16px; min-width: 64px; text-align: center;
}
.timer.low { background: var(--coral); color: #fff; }
.word-label { font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--violet); }
@media (prefers-color-scheme: dark) { .word-label { color: #B9A8FF; } }
.word { font-size: 26px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; line-height: 1.1; }
.mask { text-align: center; font-size: 22px; font-weight: 800; letter-spacing: .25em; margin: 0 0 8px; font-variant-numeric: tabular-nums; }

.pad-wrap { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
.pad {
  position: relative;
  background: var(--canvas);
  border: 2.5px solid var(--ink);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 6px 0 var(--teal);
  touch-action: none;
}
.pad canvas { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.pad .overlay {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px;
  font-size: 20px; font-weight: 800; color: #1A2330; pointer-events: none;
}
.pad.violet { box-shadow: 0 6px 0 var(--violet); }

.tools { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.tool-row { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.swatch {
  width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%;
  border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; padding: 0;
}
.swatch i { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--ink); display: block; }
.swatch.on i { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5.5px var(--text); }
.swatch.eraser i { background: repeating-linear-gradient(45deg, #fff 0 5px, #FFD1CC 5px 10px); }
.sizes { display: flex; background: var(--card); border: 2px solid var(--ink); border-radius: 999px; padding: 2px; gap: 2px; }
.size { width: 44px; height: 40px; border-radius: 999px; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; }
.size b { display: block; border-radius: 50%; background: var(--text); }
.size.on { background: var(--ink); }
.size.on b { background: #fff; }
@media (prefers-color-scheme: dark) { .size.on { background: var(--gold); } .size.on b { background: #1A2330; } }

.guess-row { display: flex; gap: 10px; margin-top: 12px; }
.guess-row .field { flex: 1; }
.send {
  width: 60px; min-height: 56px; flex: 0 0 60px; border-radius: 16px;
  background: var(--coral); border: 2.5px solid var(--ink); display: grid; place-items: center;
  box-shadow: 0 4px 0 var(--shadow); cursor: pointer; color: #fff;
}
.send:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--shadow); }
.hint { text-align: center; font-size: 16px; font-weight: 700; margin: 10px 0 0; min-height: 22px; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.options .btn { margin: 0; min-height: 54px; font-size: 17px; text-transform: capitalize; }
.shake { animation: shake .35s; }
@keyframes shake { 0%,100% { transform: none } 25% { transform: translateX(-8px) } 75% { transform: translateX(8px) } }

.choice-list { display: flex; flex-direction: column; gap: 14px; margin: 12px 0; }
.choice-list .btn { min-height: 72px; font-size: 24px; text-transform: capitalize; margin: 0; }

.cover-name { font-size: 46px; font-weight: 800; letter-spacing: -0.04em; text-align: center; line-height: 1.05; margin: 8px 0 10px; word-break: break-word; }
.cover-art { width: 150px; height: 150px; margin: 10px auto 18px; }

.thumb {
  background: var(--canvas); border: 2.5px solid var(--ink); border-radius: 22px;
  overflow: hidden; margin: 4px auto 14px; box-shadow: 0 5px 0 var(--violet);
}
.thumb canvas { display: block; width: 100%; height: 100%; }
.reveal { text-align: center; font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.reveal strong { font-weight: 800; }
.guesses { font-size: 14px; font-weight: 700; text-align: center; opacity: .85; margin: -4px 0 12px; line-height: 1.5; }

/* ---------- lobby / qr ---------- */
.qr-wrap {
  background: #FFFDF7; color: #1A2330;
  border: 2.5px solid var(--ink); border-radius: 28px;
  padding: 16px 16px 10px; display: flex; flex-direction: column; align-items: center;
  box-shadow: 0 6px 0 var(--coral); margin: 4px auto 16px; width: 100%; max-width: 300px;
}
.qr-wrap .qr { width: 196px; height: 196px; }
.qr-wrap .qr svg { width: 100%; height: 100%; display: block; }
.code-label { margin-top: 8px; font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.code { font-size: 40px; font-weight: 800; letter-spacing: .18em; margin: 0 0 2px .18em; }

/* ---------- scan ---------- */
.finder {
  flex: 1 1 auto; min-height: 220px; margin: 6px 0 14px; border-radius: 28px;
  background: linear-gradient(180deg, #3A4450 0%, #232A33 100%);
  border: 2.5px solid var(--ink); position: relative; overflow: hidden; box-shadow: 0 6px 0 var(--violet);
  display: grid; place-items: center; color: #FFF3DA; text-align: center;
}
.finder video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.finder .frame { position: absolute; left: 50%; top: 50%; width: 200px; height: 200px; transform: translate(-50%, -50%); pointer-events: none; }
.finder .corner { position: absolute; width: 36px; height: 36px; border: 5px solid var(--coral); }
.finder .tl { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; }
.finder .tr { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 10px 0 0; }
.finder .bl { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 10px; }
.finder .br { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 10px 0; }
.finder .msg { position: relative; padding: 24px; font-size: 17px; font-weight: 700; line-height: 1.4; max-width: 300px; }

/* ---------- install ---------- */
.install-card {
  background: var(--paper); border: 2.5px solid var(--ink); border-radius: 28px;
  padding: 20px 18px 18px; box-shadow: 0 7px 0 var(--shadow); display: flex; flex-direction: column;
}
.steps { margin: 6px 0 14px; display: flex; flex-direction: column; gap: 10px; }
.step {
  display: flex; gap: 12px; align-items: center; background: var(--card); border: 2px solid var(--ink);
  border-radius: 16px; padding: 11px 14px; font-size: 16px; font-weight: 700; line-height: 1.3;
}
.step svg { flex: 0 0 auto; vertical-align: -4px; }
.num {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%; background: var(--gold); color: #1A2330;
  border: 2px solid var(--ink); display: grid; place-items: center; font-weight: 800; font-size: 14px;
}
.roomchip {
  align-self: center; margin: 4px 0 12px; background: var(--teal); color: #fff;
  border: 2px solid var(--ink); border-radius: 999px; padding: 8px 18px; font-weight: 800; letter-spacing: .14em; font-size: 20px;
}
.free { text-align: center; font-size: 16px; font-weight: 800; margin: 2px 0 4px; }

/* ---------- banners, toasts, modal ---------- */
.banner {
  display: flex; align-items: center; gap: 12px; background: #B8F3EC; color: #1A2330;
  border: 2.5px solid var(--ink); border-radius: 18px; padding: 10px 12px 10px 16px; font-weight: 800; margin-bottom: 10px;
}
.banner .btn { width: auto; margin-left: auto; }
#conn {
  position: fixed; left: 50%; top: calc(var(--safe-t) + 8px); transform: translateX(-50%);
  z-index: 30; max-width: 92%; text-align: center;
  background: #1A2330; color: #FFF3DA; border-radius: 999px; padding: 8px 16px; font-weight: 800; font-size: 15px;
  border: 2px solid #FFF3DA; display: none;
}
#conn.show { display: block; }
#conn.ok { background: var(--good); }
#toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 96px); transform: translateX(-50%) translateY(20px);
  z-index: 40; max-width: 88%; text-align: center; opacity: 0; pointer-events: none;
  background: #1A2330; color: #FFF3DA; border-radius: 16px; padding: 12px 18px; font-weight: 800; font-size: 16px;
  transition: opacity .2s, transform .2s; border: 2px solid #FFF3DA;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.modal-back {
  position: fixed; inset: 0; z-index: 50; background: rgba(26, 35, 48, .55);
  display: grid; place-items: center; padding: 24px;
}
.modal { width: 100%; max-width: 360px; }
.modal .title { font-size: 24px; }

.history { font-size: 15px; font-weight: 700; line-height: 1.45; }
.history li { list-style: none; padding: 8px 0; border-top: 1.5px dashed rgba(26, 35, 48, .35); }
.history li:first-child { border-top: 0; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; font-size: 17px; font-weight: 800; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
