:root {
  --bg: #0b0a12;
  --bg-2: #14121f;
  --panel: rgba(255, 255, 255, 0.045);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f2eefb;
  --muted: #9b93b5;
  --accent: #ff4d8d;
  --accent-2: #6ee7ff;
  --good: #4ade80;
  --bad: #ff6b6b;
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(60vw 60vw at 15% -10%, rgba(255, 77, 141, 0.25), transparent 60%),
    radial-gradient(50vw 50vw at 95% 0%, rgba(110, 231, 255, 0.18), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 55%);
  z-index: -1;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 18px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── top bar ── */
.topbar { text-align: center; margin-bottom: 22px; }

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0.22em;
  font-size: 26px;
}
.brand-mark { color: var(--accent); font-size: 22px; }
.brand-name {
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sub {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
  margin-top: 4px;
}

main { flex: 1; }

/* ── screens ── */
.screen { display: none; animation: rise 0.28s ease both; }
.screen.active { display: block; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  backdrop-filter: blur(6px);
}
.center-panel { text-align: center; padding: 44px 22px; }

h2 { margin: 0 0 14px; font-size: 22px; }
h3.list-head {
  margin: 20px 0 8px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.lede { margin: 0 0 20px; color: var(--muted); line-height: 1.55; }

/* ── mode cards ── */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 26px;
}
.mode-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.mode-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: rgba(255, 77, 141, 0.08);
}
.mode-icon { font-size: 20px; }
.mode-title { font-size: 17px; font-weight: 700; }
.mode-desc { font-size: 13px; color: var(--muted); line-height: 1.4; }

/* ── settings ── */
.settings { display: grid; gap: 18px; }
.setting.center { text-align: center; margin: 22px 0; }
.setting label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg button:hover { color: var(--text); }
.seg button.on {
  background: linear-gradient(92deg, var(--accent), #ff7ab0);
  color: #fff;
  font-weight: 600;
}
.hint-text { font-size: 12.5px; color: var(--muted); margin: 10px 0 0; line-height: 1.5; }
.best-line { margin: 22px 0 0; font-size: 13px; color: var(--muted); }

/* ── buttons ── */
.btn {
  font-family: inherit;
  font-size: 15px;
  padding: 11px 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s, filter 0.15s, background 0.15s;
}
.btn:hover { transform: translateY(-1px); background: rgba(255, 255, 255, 0.1); }
.btn:active { transform: none; }
.btn.primary {
  background: linear-gradient(92deg, var(--accent), #ff7ab0);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { font-size: 13px; padding: 8px 15px; }
.btn.big { font-size: 17px; padding: 14px 34px; margin-top: 18px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.row.end { justify-content: flex-end; }
.row.center { justify-content: center; }

/* ── account chip ── */
.whoami {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -4px 0 18px;
  flex-wrap: wrap;
}
.whoami-label {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.picker {
  font-family: inherit;
  font-size: 14px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
}
.picker:focus { outline: none; border-color: var(--accent); }

.account-list, .roster, .match-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.account-list li, .match-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 14px;
}
.account-list li.on, .match-list li.mine { border-color: var(--accent); }
.account-list .who, .match-list .who { flex: 1; font-weight: 600; }
.account-list .stat, .match-list .stat { color: var(--muted); font-size: 12px; }

.roster li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  font-size: 15px;
  user-select: none;
}
.roster li.on { border-color: var(--accent); background: rgba(255, 77, 141, 0.1); }
.roster .tick {
  width: 18px; height: 18px;
  border-radius: 5px;
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: transparent;
  flex-shrink: 0;
}
.roster li.on .tick { background: var(--accent); border-color: var(--accent); color: #fff; }
.roster .who { flex: 1; }
.roster .stat { color: var(--muted); font-size: 12px; }

/* ── codes ── */
.code-wrap { display: none; margin-top: 12px; }
.code-wrap.show { display: block; }
.code-box {
  display: block;
  width: 100%;
  word-break: break-all;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px dashed var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--accent-2);
}
#code-input, #match-result-input {
  width: 100%;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  resize: vertical;
}
#code-input:focus, #match-result-input:focus { outline: none; border-color: var(--accent); }
#final-code-wrap, #match-mine-wrap { display: none; }
#final-code-wrap.show, #match-mine-wrap.show { display: block; }
.mode-card.wide { grid-column: 1 / -1; }
#screen-code .setting { margin: 16px 0; }
#screen-code .list-head, #screen-match .list-head { margin-top: 26px; }

/* ── players ── */
.player-list { display: grid; gap: 10px; }
.kill {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
  flex-shrink: 0;
}
.kill:hover { color: var(--bad); }

/* ── pass screen ── */
.pass-kicker {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 6px;
}
.pass-name {
  font-size: 34px;
  margin: 0 0 10px;
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.pass-copy { color: var(--muted); margin: 0; }

/* ── hud ── */
.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.hud-cell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  text-align: center;
}
.hud-label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.hud-val { display: block; font-size: 17px; font-weight: 700; margin-top: 2px; }
.hud-val.warn { color: var(--bad); }

.timer-track {
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-bottom: 26px;
}
.timer-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(92deg, var(--accent-2), var(--accent));
  transition: width 0.12s linear;
}

/* ── word stage ── */
.word-stage { text-align: center; margin-bottom: 22px; }
.word-kicker {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 6px;
}
.word {
  margin: 0;
  font-size: clamp(44px, 13vw, 76px);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: pop 0.4s ease both;
}
@keyframes pop {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: none; }
}
.word-meta { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

/* ── answer bar ── */
.answer-bar { display: flex; gap: 8px; }
.answer-bar input {
  flex: 1;
  font-family: inherit;
  font-size: 16px;
  padding: 13px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
}
.answer-bar input:focus { outline: none; border-color: var(--accent); }
.answer-bar.shake { animation: shake 0.35s ease; }
@keyframes shake {
  25% { transform: translateX(-7px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
}

.feedback { min-height: 22px; margin: 10px 0 4px; font-size: 14px; text-align: center; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }
.feedback.info { color: var(--accent-2); }

/* ── found list ── */
.found-head {
  display: flex;
  justify-content: space-between;
  margin: 22px 0 8px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.found-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.found-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 14px;
  animation: rise 0.22s ease both;
}
.found-list li .by { color: var(--muted); font-size: 12px; text-align: right; flex-shrink: 0; }
.found-list.muted li { opacity: 0.62; }
.found-list li.pending { opacity: 0.7; border-style: dashed; }
.spinner {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 8px;
  vertical-align: -1px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#net-status.off { color: var(--bad); }
#net-status.on { color: var(--good); }
.found-list li .pts { color: var(--good); font-size: 12px; font-weight: 700; }

/* ── results ── */
.score-pop { text-align: center; margin: 8px 0 4px; }
.score-pop span {
  display: block;
  font-size: 54px;
  font-weight: 800;
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.score-pop small { color: var(--muted); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; }
.breakdown {
  display: grid;
  gap: 4px;
  margin: 14px auto 0;
  max-width: 300px;
  font-size: 13px;
  color: var(--muted);
}
.breakdown div { display: flex; justify-content: space-between; }

/* ── scoreboard ── */
.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; counter-reset: rank; }
.board li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 16px;
}
.board li .rank { color: var(--muted); font-size: 13px; width: 22px; }
.board li .who { flex: 1; font-weight: 600; }
.board li .pts { font-weight: 800; }
.board li.win {
  border-color: var(--accent);
  background: rgba(255, 77, 141, 0.12);
}
.board li.win .who::after { content: " 👑"; }

.foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 26px; }

@media (max-width: 520px) {
  .mode-grid { grid-template-columns: 1fr; }
  .hud { grid-template-columns: repeat(2, 1fr); }
  .app { padding: 18px 14px 32px; }
}
