/* Werwolf – mobile first. Dark night theme, light mode follows the system. */

:root {
  --bg: #14121d;
  --bg-soft: #1d1930;
  --card: #221d38;
  --text: #f2efff;
  --muted: #a49dc4;
  --line: #342d52;
  --accent: #8f73ff;
  --accent-soft: #2c2350;
  --accent-text: #ffffff;
  --good: #3ecf8e;
  --warn: #ffc857;
  --bad: #ff6b6b;
  --radius: 18px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
  color-scheme: dark light;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f1ff;
    --bg-soft: #ece5ff;
    --card: #ffffff;
    --text: #1d1a2e;
    --muted: #6e6889;
    --line: #e2dbf5;
    --accent: #6d4aff;
    --accent-soft: #ece6ff;
    --shadow: 0 6px 18px rgba(40, 25, 90, .12);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }

body {
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(120% 60% at 50% 0%, var(--bg-soft), var(--bg) 60%);
  color: var(--text);
  min-height: 100dvh;
  padding: 0 0 calc(24px + env(safe-area-inset-bottom));
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 54px;
  padding: env(safe-area-inset-top) 14px 6px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.logo { font-weight: 800; font-size: 20px; letter-spacing: -.02em; color: var(--accent); }

.lang-switch { display: inline-flex; gap: 2px; padding: 2px; border-radius: 999px; background: var(--line); }
.lang-switch .chip {
  border: none; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700;
  padding: 5px 10px; border-radius: 999px;
}
.lang-switch .chip.active { background: var(--card); color: var(--accent); }

main { max-width: 560px; margin: 0 auto; padding: 4px 14px 24px; display: grid; gap: 12px; }

h1 { font-size: 30px; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 22px; margin: 6px 0 2px; }
p { margin: 6px 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 8px;
}
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.error { color: var(--bad); font-size: 15px; }
.good { color: var(--good); }
.bad { color: var(--bad); }

.chip {
  display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.chip.plain { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.chip.done { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good); }
.chip.bad-chip { background: color-mix(in srgb, var(--bad) 20%, transparent); color: var(--bad); }
.chip.good-chip { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good); }

.btn {
  border: none; border-radius: 14px; background: var(--accent); color: var(--accent-text);
  padding: 14px 16px; font-weight: 700; min-height: 50px; width: 100%;
}
.btn.small { min-height: 38px; padding: 8px 12px; font-size: 14px; width: auto; }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--line); }
.btn:disabled { opacity: .45; }
.icon-btn {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 10px; width: 34px; height: 34px;
}

.row { display: flex; gap: 8px; align-items: stretch; }
.row .btn { width: auto; }
.field { display: grid; gap: 4px; }
.field > span { font-size: 14px; color: var(--muted); }
input[type="text"], select {
  width: 100%; padding: 13px 14px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--bg-soft); min-height: 50px;
}
input.code-input { text-transform: uppercase; letter-spacing: .18em; font-weight: 800; text-align: center; }
.switch { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }
details.settings summary, details.log-card summary { cursor: pointer; font-weight: 700; }

.hero { text-align: center; display: grid; gap: 2px; padding: 10px 0 0; }
.hero-emoji { font-size: 44px; }

.code-card { text-align: center; }
.code { font-size: 46px; font-weight: 800; letter-spacing: .22em; color: var(--accent); }
.host-note { color: var(--muted); font-size: 14px; text-align: center; margin: 0; }

.players { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.players li { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.players li.out .name { text-decoration: line-through; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); flex: none; }
.dot.on { background: var(--good); }
.dot.off { background: var(--bad); }

.role-card.hidden-role { text-align: center; background: linear-gradient(160deg, var(--accent-soft), var(--card)); }
.big-emoji { font-size: 54px; }
.inspections { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 15px; }

.action-card { border-color: var(--accent); }
.targets { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.target {
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--text);
  border-radius: 14px; padding: 14px 10px; min-height: 54px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.target.skip { grid-column: 1 / -1; background: transparent; color: var(--muted); }

.phase-card { border-left: 6px solid var(--accent); }
.phase-card.phase-night { border-left-color: var(--accent); }
.phase-card.phase-day { border-left-color: var(--warn); }
.phase-card.phase-vote { border-left-color: var(--bad); }
.phase-card.phase-ended { border-left-color: var(--good); }
.phase-text { font-size: 18px; margin: 0; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--warn); }
.timer.over { color: var(--bad); }
.winner { font-size: 20px; font-weight: 800; }

.announcement p { margin: 2px 0; }
.announcement p:last-child { font-weight: 700; }

.messages { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 220px; overflow-y: auto; }
.messages li { font-size: 15px; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; }
.chat-form .btn { width: auto; min-width: 84px; }

.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.log li.secret { color: var(--warn); }

.host-bar { display: grid; gap: 8px; position: sticky; bottom: 8px; }
.host-bar .btn { box-shadow: var(--shadow); }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 12px 16px; border-radius: 14px; font-size: 15px; max-width: calc(100% - 28px);
  z-index: 20;
}

@media (min-width: 620px) {
  .targets { grid-template-columns: repeat(3, 1fr); }
}
