:root {
  --bg: #fff8ef;
  --surface: #ffffff;
  --text: #2b1d12;
  --muted: #8a7563;
  --line: #ecdcc9;
  --accent: #e8590c;
  --accent-text: #ffffff;
  --danger: #d6336c;
  --ok: #2f9e44;
  --heat: 0;
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1510;
    --surface: #2a1f18;
    --text: #f6ebe0;
    --muted: #b39d89;
    --line: #42332a;
    --accent: #ff7a2f;
    --accent-text: #1d1510;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: color-mix(in srgb, var(--bg), #ff3b00 calc(var(--heat) * 4%));
  color: var(--text);
  transition: background 1s;
  -webkit-tap-highlight-color: transparent;
}

.screen {
  max-width: 460px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

h1, h2 { margin: 0; text-align: center; }
h1 { font-size: 2rem; }
h2 { font-size: 1.25rem; }
.lead { text-align: center; color: var(--muted); margin: 0; line-height: 1.45; }
.muted { color: var(--muted); }
.center { text-align: center; }
.logo { font-size: 72px; text-align: center; margin-top: 24px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: var(--muted); }

input {
  font: inherit;
  font-size: 1.1rem;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--text);
  outline: none;
}
input:focus { border-color: var(--accent); }
#code { text-transform: uppercase; letter-spacing: 0.3em; text-align: center; font-weight: 700; }

button {
  font: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 12px 18px;
  border-radius: 12px;
  border: 2px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
}
button:disabled { opacity: 0.45; cursor: default; }
button.secondary { background: transparent; color: var(--accent); }
button.small { padding: 6px 12px; font-size: 0.95rem; }
button.link { background: none; border: none; color: var(--muted); font-weight: 500; text-decoration: underline; }

.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 0.9rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.error { color: var(--danger); text-align: center; min-height: 1.2em; margin: 0; }

#banner {
  position: fixed; inset: 0 0 auto 0; z-index: 10;
  background: var(--text); color: var(--bg);
  text-align: center; padding: 8px 16px; font-size: 0.9rem;
}

/* Lobby */
.code-box { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.code { font-size: 3rem; letter-spacing: 0.25em; padding-left: 0.25em; }
.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.players li {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.players li .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.players li.off { opacity: 0.45; }
.players .kick { padding: 2px 10px; font-size: 0.9rem; }
.tag { font-size: 0.8rem; color: var(--muted); }

.settings { display: flex; flex-direction: column; gap: 12px; padding: 8px 0; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper strong { min-width: 1.5em; text-align: center; font-size: 1.2rem; }
.segmented { display: flex; border: 2px solid var(--accent); border-radius: 12px; overflow: hidden; }
.segmented button { border: none; border-radius: 0; background: transparent; color: var(--accent); padding: 6px 12px; font-size: 0.95rem; }
.segmented button.on { background: var(--accent); color: var(--accent-text); }
.settings.readonly button { pointer-events: none; }
.settings.readonly .stepper button { visibility: hidden; }

/* Game */
.round { text-align: center; font-size: 0.9rem; }
.category { font-size: 1.8rem; }
.potato-wrap { display: grid; place-items: center; height: 170px; }
.potato {
  font-size: 110px;
  line-height: 1;
  transform: scale(calc(1 + var(--heat) * 0.09));
  filter: drop-shadow(0 0 calc(var(--heat) * 10px) rgb(255 80 0 / calc(var(--heat) * 22%)));
  transition: transform 0.6s, filter 0.6s;
}
.potato.wiggle { animation: wiggle calc(1.2s - var(--heat) * 0.24s) ease-in-out infinite; }
.potato.boom { animation: boom 0.5s ease-out forwards; }
@keyframes wiggle {
  0%, 100% { rotate: 0deg; }
  25% { rotate: calc(-4deg - var(--heat) * 2deg); }
  75% { rotate: calc(4deg + var(--heat) * 2deg); }
}
@keyframes boom {
  0% { scale: 1; opacity: 1; }
  60% { scale: 1.8; opacity: 0.6; }
  100% { scale: 0.2; opacity: 0; }
}

.status { text-align: center; font-size: 1.15rem; font-weight: 700; margin: 0; }
.status.you { color: var(--accent); }
.typing { text-align: center; min-height: 1.4em; margin: 0; color: var(--muted); font-style: italic; }
.feedback { text-align: center; min-height: 1.3em; margin: 0; font-weight: 600; }
.feedback.bad { color: var(--danger); }
.feedback.good { color: var(--ok); }
.shake { animation: shake 0.35s; }
@keyframes shake {
  20%, 60% { translate: -8px 0; }
  40%, 80% { translate: 8px 0; }
}

.seats { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.seats li {
  padding: 6px 12px; border-radius: 999px; border: 2px solid var(--line);
  display: flex; gap: 6px; align-items: center; font-size: 0.95rem;
}
.seats li.holder { border-color: var(--accent); background: color-mix(in srgb, var(--accent), transparent 85%); }
.seats li.out { opacity: 0.4; text-decoration: line-through; }
.seats li.off { opacity: 0.5; }
.seats li.me { font-weight: 700; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chips span { padding: 4px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 0.9rem; }

.overlay {
  position: fixed; inset: 0; z-index: 5;
  display: grid; place-items: center; padding: 16px;
  background: rgb(0 0 0 / 45%);
}
.overlay-card {
  width: min(400px, 100%);
  background: var(--surface); border-radius: 20px; padding: 24px 20px;
  display: flex; flex-direction: column; gap: 10px; text-align: center;
}
.overlay-card p { margin: 0; }
.overlay-icon { font-size: 64px; }
.missed { font-size: 0.95rem; }
