:root {
  --bg: #1b1033;
  --bg2: #34206e;
  --ink: #fff;
  --muted: #b9add9;
  --panel: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.16);
  --yellow: #ffd23f;
  --red: #ff4d6d;
  --green: #2ec27e;
  --pink: #ff5fa2;
  --card-ink: #1b1033;
}

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

html, body { height: 100%; margin: 0; }

body {
  background: radial-gradient(120% 80% at 50% 0%, var(--bg2), var(--bg) 70%) fixed var(--bg);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.35;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app {
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

h1, h2, p { margin: 0; }
.grow { flex: 1; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* Buttons */
button {
  font: inherit;
  color: inherit;
  border: 0;
  border-radius: 18px;
  padding: 16px 18px;
  font-weight: 800;
  cursor: pointer;
  background: var(--panel);
  transition: transform 0.06s ease, filter 0.15s ease;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.35; }
.primary { background: var(--yellow); color: var(--card-ink); font-size: 20px; box-shadow: 0 6px 0 #c99a00; }
.primary:active { box-shadow: 0 2px 0 #c99a00; transform: translateY(4px); }
.ghost { background: transparent; border: 2px solid var(--line); }
.link { background: none; padding: 8px; color: var(--muted); font-weight: 600; text-decoration: underline; }
.block { display: block; width: 100%; }

/* Home */
.logo {
  font-size: 84px;
  font-weight: 900;
  letter-spacing: -3px;
  line-height: 1;
  color: var(--yellow);
  text-shadow: 0 6px 0 var(--pink), 0 12px 0 rgba(0, 0, 0, 0.25);
  transform: rotate(-4deg);
  margin: 6vh 0 18px;
}
.lang { display: flex; gap: 8px; background: var(--panel); padding: 6px; border-radius: 20px; }
.lang button { flex: 1; padding: 12px; border-radius: 14px; background: transparent; }
.lang button.on { background: #fff; color: var(--card-ink); }

/* Setup */
.field { background: var(--panel); border-radius: 20px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.field > label { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 800; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips button { flex: 1; min-width: 60px; padding: 12px 6px; border-radius: 14px; }
.chips button.on { background: #fff; color: var(--card-ink); }
.team-row { display: flex; gap: 8px; align-items: center; }
.team-row .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.team-row input {
  flex: 1; min-width: 0; font: inherit; font-weight: 700; color: var(--ink);
  background: rgba(0, 0, 0, 0.25); border: 2px solid transparent; border-radius: 14px; padding: 12px 14px;
  user-select: text; -webkit-user-select: text;
}
.team-row input:focus { outline: none; border-color: var(--yellow); }
.team-row .x { padding: 10px 14px; border-radius: 14px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.topbar h2 { font-size: 22px; }
.topbar button { padding: 10px 14px; border-radius: 14px; }

/* Scoreboard */
.scores { display: flex; flex-direction: column; gap: 8px; }
.score { display: flex; align-items: center; gap: 10px; background: var(--panel); border-radius: 16px; padding: 12px 14px; font-weight: 800; }
.score.now { outline: 3px solid var(--yellow); }
.score .dot { width: 14px; height: 14px; border-radius: 50%; }
.score .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score .pts { font-size: 22px; font-variant-numeric: tabular-nums; }
.bigname { font-size: 40px; font-weight: 900; line-height: 1.05; word-break: break-word; }

/* Play */
.hud { display: flex; align-items: center; gap: 12px; }
.hud .time { font-size: 40px; font-weight: 900; font-variant-numeric: tabular-nums; min-width: 2.2ch; text-align: center; }
.hud .time.low { color: var(--red); animation: pulse 1s infinite; }
.hud .bar { flex: 1; height: 12px; background: var(--panel); border-radius: 99px; overflow: hidden; }
.hud .bar i { display: block; height: 100%; background: var(--yellow); border-radius: 99px; transform-origin: left; }
.hud .turnpts { font-weight: 900; font-size: 22px; background: var(--panel); border-radius: 12px; padding: 6px 12px; font-variant-numeric: tabular-nums; }
.hud .pause { padding: 8px 12px; border-radius: 12px; }
@keyframes pulse { 50% { transform: scale(1.15); } }

.card {
  flex: 1;
  background: #fff;
  color: var(--card-ink);
  border-radius: 28px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
  animation: pop 0.18s ease-out;
}
@keyframes pop { from { transform: scale(0.94) rotate(-1.5deg); opacity: 0.4; } }
.card .target {
  background: linear-gradient(135deg, #6a3df0, var(--pink));
  color: #fff;
  padding: 26px 16px;
  text-align: center;
  font-weight: 900;
  font-size: 38px;
  line-height: 1.05;
  text-transform: uppercase;
  word-break: break-word;
}
.card .target.long { font-size: 28px; }
.card ul { list-style: none; margin: 0; padding: 6px 0; flex: 1; display: flex; flex-direction: column; justify-content: space-evenly; }
.card li { text-align: center; font-size: 26px; font-weight: 800; padding: 4px 12px; text-transform: uppercase; color: #3a2a63; }
.card li + li { border-top: 2px dashed #e6e0f5; }

.actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.actions button { padding: 20px 4px; font-size: 19px; border-radius: 20px; color: #fff; }
.actions small { display: block; font-size: 13px; font-weight: 700; opacity: 0.85; }
.b-taboo { background: var(--red); box-shadow: 0 6px 0 #b8203f; }
.b-pass { background: #f59f00; box-shadow: 0 6px 0 #b37400; }
.b-ok { background: var(--green); box-shadow: 0 6px 0 #1b8a57; }
.actions button:active { transform: translateY(4px); box-shadow: none; }

.overlay { position: fixed; inset: 0; background: #170d2e; display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 24px; z-index: 5; }
.overlay > * { max-width: 420px; width: 100%; margin: 0 auto; }

/* Summary */
.log { display: flex; flex-direction: column; gap: 6px; }
.log button { display: flex; align-items: center; gap: 10px; text-align: left; padding: 12px 14px; border-radius: 14px; font-weight: 700; }
.log .tag { margin-left: auto; font-size: 13px; padding: 4px 10px; border-radius: 99px; color: #fff; font-weight: 800; white-space: nowrap; }
.tag.c { background: var(--green); } .tag.t { background: var(--red); } .tag.p { background: #f59f00; } .tag.x { background: #6b5f8c; }
.turntotal { font-size: 64px; font-weight: 900; color: var(--yellow); line-height: 1; }

/* Rules */
.rules { background: var(--panel); border-radius: 20px; padding: 6px 16px; }
.rules li { margin: 12px 0; }

.crown { font-size: 72px; line-height: 1; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: #fff; color: var(--card-ink); font-weight: 800; padding: 12px 18px; border-radius: 16px;
  opacity: 0; pointer-events: none; transition: all 0.25s ease; z-index: 9; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-height: 640px) {
  .card .target { padding: 16px; font-size: 30px; }
  .card li { font-size: 21px; }
  .actions button { padding: 14px 4px; }
}
