:root {
  --bg: #0b1020;
  --card: rgba(255, 255, 255, 0.06);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.68);
  --border: rgba(255, 255, 255, 0.12);
  --accent: #60a5fa;
  --good: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --tap: 52px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7fb;
    --card: rgba(17, 24, 39, 0.06);
    --text: rgba(17, 24, 39, 0.92);
    --muted: rgba(17, 24, 39, 0.65);
    --border: rgba(17, 24, 39, 0.12);
    --shadow: 0 8px 22px rgba(17, 24, 39, 0.12);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;
  font-size: 18px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: radial-gradient(1200px 800px at 10% 0%, rgba(96, 165, 250, 0.22), transparent 55%),
    radial-gradient(900px 700px at 90% 10%, rgba(34, 197, 94, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

/* Prevent scroll when game screen is active */
html.is-game,
body.is-game {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body.is-game {
  position: fixed;
  inset: 0;
  width: 100%;
}

#bg {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  pointer-events: none;
  z-index: 0;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 780px;
  margin: 0 auto;
  padding: 16px 14px calc(28px + env(safe-area-inset-bottom));
}

.screen {
  display: block;
}

.screen[hidden] {
  display: none !important;
}

/* Extra safety: ensure native hidden always wins */
[hidden] {
  display: none !important;
}

.h1 {
  font-size: 30px;
  margin: 10px 0 6px;
}

.h2 {
  font-size: 20px;
  margin: 0;
}

.h3 {
  font-size: 18px;
  margin: 0;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 14px;
}

.right {
  text-align: right;
}

.footnote {
  font-size: 14px;
  margin-top: 14px;
}

#summaryLine {
  font-size: 20px;
  line-height: 1.35;
}

#summaryLine .summaryTeam {
  display: block;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: var(--text);
  margin-bottom: 6px;
}

#summaryLine .summaryStats {
  display: block;
  color: var(--muted);
  font-size: 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin: 14px 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.row--split {
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.row--split .btn {
  width: auto;
}

.card .row--split {
  margin-bottom: 8px;
}

.row--buttons {
  justify-content: stretch;
  gap: 10px;
}

.row--buttons .btn {
  width: 100%;
  flex: 1 1 200px;
}

.formGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

@media (max-width: 420px) {
  .formGrid {
    grid-template-columns: 1fr;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field__label {
  font-size: 14px;
  color: var(--muted);
}

.input,
.textarea {
  width: 100%;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  color: var(--text);
  outline: none;
  font-size: 18px;
}

.input {
  min-height: 44px;
}

.input--withAction {
  padding-right: 92px;
}

.textarea {
  resize: vertical;
  min-height: 92px;
}

.inputWrap {
  position: relative;
  width: 100%;
  flex: 1 1 240px;
}

.inputActions {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  gap: 4px;
}

.inputActions .btn--icon {
  color: var(--muted);
  background: transparent;
}

.inputActions .btn--icon:disabled {
  opacity: 0.35;
}

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 10px;
  user-select: none;
}

.check input {
  transform: translateY(3px);
}

.btn {
  min-height: var(--tap);
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #081022;
  font-weight: 700;
  letter-spacing: 0.2px;
  width: 100%;
  touch-action: manipulation;
  cursor: pointer;
  font-size: 18px;
}

.btn:active {
  transform: translateY(1px);
}

.btn--secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn--icon {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  font-size: 20px;
  line-height: 1;
}

.btn--icon:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 80%, white);
  outline-offset: 2px;
}

.btn--good {
  background: color-mix(in srgb, var(--good) 92%, white);
  color: #04140b;
}

.btn--warn {
  background: color-mix(in srgb, var(--warn) 92%, white);
  color: #1b1203;
}

.btn--danger {
  background: color-mix(in srgb, var(--danger) 92%, white);
  color: #1b0707;
}

.btn[disabled] {
  opacity: 0.55;
}

.btn--sm {
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
  width: auto;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
}

.levelGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

@media (max-width: 420px) {
  .levelGrid {
    grid-template-columns: 1fr;
  }
}

.levelOption {
  position: relative;
  display: block;
  user-select: none;
}

.levelOption__input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.levelOption__surface {
  display: block;
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 66%, transparent);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
  transition: transform 120ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.levelOption__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.levelOption__num {
  font-size: 22px;
  font-weight: 950;
  letter-spacing: 0.3px;
}

.levelOption__tag {
  font-size: 13px;
  color: var(--muted);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  padding: 4px 8px;
  border-radius: 999px;
}

.levelOption__desc {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  color: var(--muted);
}

.levelOption__input:checked+.levelOption__surface {
  border-color: color-mix(in srgb, var(--accent) 85%, white);
  background: radial-gradient(140px 90px at 18% 10%, rgba(96, 165, 250, 0.22), transparent 60%),
    color-mix(in srgb, var(--bg) 62%, transparent);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}

.levelOption__input:active+.levelOption__surface {
  transform: translateY(1px);
}

.levelOption__input:focus-visible+.levelOption__surface {
  outline: 2px solid color-mix(in srgb, var(--accent) 80%, white);
  outline-offset: 2px;
}

.levelHint {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
}

.levelHint__line {
  color: var(--muted);
  font-size: 14px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  font-size: 14px;
  color: var(--text);
}

.posGrid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.posPresets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.posOption {
  position: relative;
  display: inline-flex;
  user-select: none;
}

.posOption__input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.posOption__surface {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  color: var(--muted);
  font-size: 14px;
  transition: transform 120ms ease, border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.posOption__input:checked+.posOption__surface {
  border-color: color-mix(in srgb, var(--accent) 65%, white);
  background: color-mix(in srgb, var(--accent) 16%, var(--bg));
  color: var(--text);
}

.posOption__input:focus-visible+.posOption__surface {
  outline: 2px solid color-mix(in srgb, var(--accent) 80%, white);
  outline-offset: 2px;
}

.posOption__input:active+.posOption__surface {
  transform: translateY(1px);
}

.scorebar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-top: 6px;
}

.team {
  font-size: 18px;
  font-weight: 800;
}

.score {
  font-size: 22px;
  font-weight: 900;
}

.timer {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
}

.timer__time {
  font-size: 44px;
  font-weight: 900;
  letter-spacing: 1px;
  text-align: center;
}

.timer__sub {
  text-align: center;
  margin-top: 6px;
}

.wordCard {
  margin: 14px 0;
  border-radius: calc(var(--radius) + 6px);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  box-shadow: var(--shadow);
}

.word {
  padding: 26px 16px;
  text-align: center;
  font-size: 34px;
  font-weight: 900;
  line-height: 1.1;
  word-break: break-word;
}

@media (max-width: 420px) {
  .word {
    font-size: 30px;
    padding: 22px 14px;
  }
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.listItem {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
}

.wordLink {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 65%, transparent);
  text-underline-offset: 3px;
  font-weight: 800;
}

.wordLink:active {
  opacity: 0.85;
}

.listItem__right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn--report {
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 12px;
  font-size: 18px;
}

.badge {
  font-size: 12px;
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.badge--good {
  color: color-mix(in srgb, var(--good) 80%, var(--text));
}

.badge--warn {
  color: color-mix(in srgb, var(--warn) 80%, var(--text));
}

.table {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.tableRow {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
}

.details summary {
  cursor: pointer;
  color: var(--muted);
  margin: 10px 0;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.modal {
  border: none;
  padding: 0;
  background: transparent;
  margin: auto;
  max-width: calc(100vw - 16px - env(safe-area-inset-left) - env(safe-area-inset-right));
  max-height: calc(100vh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}

.modal__card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 16px;
  width: min(520px, calc(100vw - 28px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow);
}

.modal__card p {
  margin: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.modal__card .row--buttons {
  margin-top: 6px;
}

/* Fullscreen minimal game */
.screen--game {
  position: fixed;
  inset: 0;
  z-index: 5;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom));
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

.countdown {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(18px + env(safe-area-inset-top)) 14px calc(18px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(10px);
}

.countdown__value {
  font-weight: 1000;
  letter-spacing: 2px;
  font-size: min(120px, 22vw);
  line-height: 1;
  text-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* На паузе слово не должно просвечивать: фон почти непрозрачный. */
.pauseOverlay {
  background: color-mix(in srgb, var(--bg) 97%, transparent);
  backdrop-filter: blur(22px);
}

.pauseOverlay__panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(360px, 100%);
}

.pauseOverlay__title {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 1px;
}

.pauseOverlay__time {
  font-size: min(96px, 20vw);
  font-weight: 1000;
  line-height: 1;
}

.pauseOverlay__panel .btn {
  width: 100%;
}

/*
 * Кнопку паузы держим в потоке, а не позиционируем через transform:
 * .btn:active задаёт свой transform и специфичнее, поэтому центрирование
 * трансформом слетало прямо в момент нажатия и кнопка уезжала из-под пальца.
 * Пустой спейсер слева уравновешивает кнопку справа, чтобы время осталось по центру.
 */
.timer {
  display: flex;
  align-items: center;
  gap: 8px;
}

.timer::before {
  content: '';
  flex: 0 0 44px;
}

.timer__time {
  flex: 1 1 auto;
}

.timer__pause {
  flex: 0 0 auto;
}

.screen--game .timer {
  margin: 0;
}

.screen--game .wordCard {
  margin: 0;
}

.screen--game .word {
  font-size: 40px;
  padding: 30px 16px;
}

@media (max-width: 420px) {
  .screen--game .word {
    font-size: 34px;
    padding: 26px 14px;
  }
}

/* Mobile typography bump (readability-first) */
@media (max-width: 520px) {
  body {
    font-size: 22px;
  }

  .container {
    padding: 14px 12px calc(22px + env(safe-area-inset-bottom));
  }

  .card {
    padding: 12px;
    margin: 12px 0;
  }

  .h1 {
    margin-top: 6px;
  }

  .row--buttons {
    flex-direction: column;
  }

  .row--buttons .btn {
    flex-basis: auto;
  }

  .h1 {
    font-size: 38px;
  }

  .h2 {
    font-size: 24px;
  }

  .h3 {
    font-size: 22px;
  }

  .small {
    font-size: 16px;
  }

  .footnote {
    font-size: 16px;
  }

  .field__label {
    font-size: 16px;
  }

  .input,
  .textarea {
    font-size: 20px;
  }

  .btn {
    font-size: 20px;
  }

  .pill {
    font-size: 17px;
  }

  .badge {
    font-size: 15px;
  }

  .listItem {
    font-size: 18px;
  }

  .timer__time {
    font-size: 58px;
  }
}

@media (max-width: 380px) {
  body {
    font-size: 21px;
  }

  .h1 {
    font-size: 36px;
  }
}

@media (min-width: 640px) {
  .btn {
    width: auto;
  }

  .actions .btn {
    width: 100%;
  }
}