:root {
  --bg: #0b0507;
  --panel: #1b0d11;
  --panel-2: #2a141a;
  --line: #4a2029;
  --text: #f6ece6;
  --muted: #b39a94;
  --red: #d7263d;
  --red-bright: #ff4d5e;
  --green: #2fb56a;
  --gold: #f2b134;
}

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

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(ellipse at top, #3a0d17 0%, var(--bg) 62%) fixed;
  color: var(--text);
  font: 17px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

h1 { margin: 12px 0 0; font-size: 30px; line-height: 1.12; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 22px; line-height: 1.2; }
p { margin: 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
.error { color: var(--red-bright); min-height: 1.35em; font-weight: 600; }
.mask { font-size: 64px; line-height: 1; text-align: center; }

label { display: block; margin-bottom: 8px; font-weight: 600; }

input {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 18px;
}
input:focus { outline: 2px solid var(--red-bright); outline-offset: 1px; }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  touch-action: manipulation;
}

.primary {
  width: 100%;
  padding: 16px;
  border-radius: 12px;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
}
.primary:active { background: var(--red-bright); }
.primary:disabled { opacity: 0.5; }

.characters { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; }
.character {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 4px;
  border-radius: 12px;
  background: var(--panel);
  border: 2px solid var(--line);
  font-size: 14px;
}
.character span:first-child { font-size: 32px; line-height: 1.1; }
.character[aria-pressed="true"] { border-color: var(--red-bright); background: var(--panel-2); }
.character:disabled { opacity: 0.35; }

.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.player.me { border-color: var(--red-bright); }
.player.away { opacity: 0.5; }
.player .avatar { font-size: 24px; }
.player .name { flex: 1; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.player .score { font-variant-numeric: tabular-nums; font-weight: 700; }
.player .gain { color: var(--green); font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.player .gain.zero { color: var(--muted); }
.player .status { color: var(--muted); font-size: 14px; }
.player .status.done { color: var(--green); font-weight: 700; }

.topline { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 15px; font-weight: 600; }
.double { color: var(--gold); font-weight: 800; }

.bar { height: 8px; border-radius: 4px; overflow: hidden; background: var(--panel-2); }
.bar > div { height: 100%; width: 100%; background: var(--red-bright); transform-origin: left; }

.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 12px 14px;
  text-align: left;
  border-radius: 12px;
  background: var(--panel);
  border: 2px solid var(--line);
  font-size: 17px;
  font-weight: 600;
}
.option:disabled { color: var(--text); }
.option.chosen { border-color: var(--gold); background: var(--panel-2); }
.option.dim { opacity: 0.5; }
.option.correct { border-color: var(--green); background: #143524; opacity: 1; }
.option.wrong { border-color: var(--red-bright); background: #3d1219; opacity: 1; }
.option .who { white-space: nowrap; font-size: 20px; }

.verdict { font-size: 22px; font-weight: 800; text-align: center; }
.verdict.good { color: var(--green); }
.verdict.bad { color: var(--red-bright); }

.phone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 34px 18px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  text-align: center;
}
.phone .mask.ringing { animation: ring 0.6s ease-in-out infinite; }
.phone-actions { display: flex; gap: 12px; width: 100%; }
.phone-actions button { flex: 1; padding: 16px; border-radius: 12px; font-weight: 700; color: #fff; }
.accept { background: var(--green); }
.decline { background: var(--red); }

@keyframes ring {
  0%, 100% { transform: rotate(-7deg); }
  50% { transform: rotate(7deg); }
}

@media (prefers-reduced-motion: reduce) {
  .phone .mask.ringing { animation: none; }
}

.winner { text-align: center; display: flex; flex-direction: column; gap: 6px; }
.winner .mask { font-size: 76px; }
.epitaph { color: var(--muted); font-size: 14px; font-weight: 400; display: block; }

#offline {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  padding: 6px;
  text-align: center;
  background: var(--gold);
  color: #201000;
  font-weight: 700;
  font-size: 14px;
}
#offline[hidden] { display: none; }
