:root {
  --bg: #15161a;
  --raise: #1f2127;
  --line: #2c2f37;
  --ink: #ece8df;
  --muted: #8f8b83;
  --accent: #f2c94c;
  --accent-ink: #1c1708;
  --paper: #f3eee2;
  --paper-ink: #22201b;
  --bad: #ff8a80;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.screen {
  max-width: 560px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 18px max(28px, env(safe-area-inset-bottom));
}

h1 { font-size: 34px; line-height: 1.1; margin: 8px 0 8px; letter-spacing: -0.02em; }
h2 { font-size: 22px; margin: 0 0 6px; }
.lead { color: var(--muted); margin: 0; }
.top { margin-bottom: 26px; }

.field { margin-bottom: 22px; }
.label { font-weight: 600; margin-bottom: 8px; }
.hint { color: var(--muted); font-size: 14px; margin-top: 8px; min-height: 20px; }

.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1;
  min-height: 48px;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.seg button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.actions { display: flex; flex-direction: column; gap: 10px; margin: 26px 0 8px; }
.actions.row { flex-direction: row; }
.actions.row > * { flex: 1; }

.primary, .secondary, .text {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 18px;
  border-radius: 14px; border: 0;
  font-weight: 650; text-decoration: none; cursor: pointer;
  transition: transform .12s, background-color .15s, opacity .15s;
}
.primary { background: var(--accent); color: var(--accent-ink); font-size: 17px; }
.secondary { background: var(--raise); color: var(--ink); border: 1px solid var(--line); }
.text { background: transparent; color: var(--muted); min-height: 44px; font-weight: 500; }
.primary:active, .secondary:active { transform: scale(.98); }
button:disabled { opacity: .45; cursor: default; }

@media (hover: hover) and (pointer: fine) {
  .primary:hover { background: #f6d36a; }
  .secondary:hover { background: #262931; }
  .text:hover { color: var(--ink); }
  .seg button:not(.on):hover { border-color: #3d414b; background: #1b1d22; }
  .tile:hover { border-color: #3d414b; }
}

.rules { margin-top: 30px; border-top: 1px solid var(--line); padding-top: 16px; }
.rules summary { cursor: pointer; font-weight: 600; }
.rules ol { padding-left: 20px; color: #cfcac0; margin: 12px 0 0; }
.rules li { margin-bottom: 8px; }

.err { color: var(--bad); margin: 14px 0 0; }

/* диктовка */
#play { min-height: 100svh; display: flex; flex-direction: column; }
.play-top { display: flex; justify-content: space-between; color: var(--muted); font-size: 15px; }
.cell-now { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 260px; }
.cell-num {
  font-size: min(42vw, 220px); line-height: 1; font-weight: 800;
  font-variant-numeric: tabular-nums; letter-spacing: -0.04em;
}
.cell-sub { color: var(--muted); margin-top: 10px; font-size: 18px; }
.bar { height: 6px; background: var(--raise); border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transform-origin: left; }

/* ответы */
.last {
  position: sticky; top: 8px; z-index: 2;
  display: flex; align-items: baseline; gap: 12px;
  background: var(--paper); color: var(--paper-ink);
  border-radius: 14px; padding: 12px 16px; margin-bottom: 10px;
}
.last-n { font-weight: 800; color: #8a8478; font-variant-numeric: tabular-nums; }
.last-w { font-size: 24px; font-weight: 800; }
.grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.tile {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  background: var(--raise);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 20px; font-variant-numeric: tabular-nums;
  cursor: pointer; padding: 4px; text-align: center;
  transition: background-color .15s, color .15s, border-color .15s;
}
.tile.open {
  background: var(--paper); color: var(--paper-ink); border-color: var(--paper);
  flex-direction: column; font-size: 12px; font-weight: 650; line-height: 1.15;
}
.tile.open .word { white-space: nowrap; }
.tile.open b { font-size: 11px; color: #8a8478; font-weight: 600; margin-bottom: 2px; }
.grid.n50 .tile { aspect-ratio: 1 / .8; }
.grid.n50 .tile:not(.open) { font-size: 17px; }

.score { margin-top: 34px; border-top: 1px solid var(--line); padding-top: 18px; }
.score-head { display: flex; align-items: center; justify-content: space-between; }
#players { list-style: none; padding: 0; margin: 8px 0 12px; }
#players li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
#players .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#players .pts { min-width: 34px; text-align: center; font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }
#players button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--raise); font-size: 20px; font-weight: 700; cursor: pointer; }
#players .del { border: 0; background: transparent; color: var(--muted); width: 36px; font-size: 18px; }
.add { display: flex; gap: 8px; }
.add input { flex: 1; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); padding: 0 14px; }
.add input:focus { outline: none; border-color: var(--accent); }
