/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: #F7F3EE;
  color: #1A1A2E;
  max-width: 375px;
  margin: 0 auto;
}

/* ── Экраны ── */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 48px 28px 40px;
}

.screen.active {
  display: flex;
}

/* ══════════════════════════════
   Стартовый экран
══════════════════════════════ */
#screen-start {
  align-items: center;
  background: #F7F3EE;
}

/* Логотип — автоматически центрируется в свободном пространстве */
.start-logo {
  margin-top: auto;
  margin-bottom: auto;
  text-align: center;
}

.start-logo h1 {
  font-size: 72px;
  font-weight: 900;
  letter-spacing: -3px;
  line-height: 1;
  color: #1A1A2E;
}

.start-logo .tagline {
  font-size: 15px;
  color: #7A7A8C;
  margin-top: 8px;
  letter-spacing: 0.2px;
  font-weight: 400;
}

/* Кнопки стартового экрана — всегда внизу */
.start-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  flex-shrink: 0;
}

/* ══════════════════════════════
   Экран выбора набора
══════════════════════════════ */
.screen-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 24px;
  flex-shrink: 0;
}

#screen-sets {
  overflow-y: auto;
}

.sets-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.set-card {
  background: #fff;
  border-radius: 20px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.set-card-title {
  font-size: 20px;
  font-weight: 800;
  color: #1A1A2E;
}

.set-card-desc {
  font-size: 14px;
  color: #7A7A8C;
  margin-top: 4px;
}

.set-card-count {
  font-size: 13px;
  font-weight: 600;
  color: #B0A99F;
  margin-top: 2px;
}

.set-card-btn {
  margin-top: 4px;
}

/* ══════════════════════════════
   Экран перед раундом
══════════════════════════════ */
#screen-ready {
  justify-content: space-between;
}

.ready-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  text-align: center;
}

.ready-set-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #B0A99F;
  margin-bottom: 6px;
}

.ready-set-name {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: -1px;
  color: #1A1A2E;
  line-height: 1.1;
}

.ready-text {
  font-size: 16px;
  color: #7A7A8C;
  line-height: 1.4;
}

.ready-rules {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.ready-rule {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border-radius: 14px;
  padding: 13px 16px;
  font-size: 15px;
  color: #1A1A2E;
  text-align: left;
}

/* ══════════════════════════════
   Игровой экран
══════════════════════════════ */
#screen-game {
  justify-content: space-between;
  padding-top: 36px;
}

.game-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  flex-shrink: 0;
}

/* кнопка ← — левая колонка (переопределяем absolute из .btn-back) */
#btn-game-exit {
  position: static;
  justify-self: start;
}

/* счёт — правая колонка */
.game-score {
  justify-self: end;
}

.game-timer-wrap {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.game-timer {
  font-size: 32px;
  font-weight: 800;
  color: #1A1A2E;
  letter-spacing: -1px;
}

.game-timer-unit {
  font-size: 16px;
  font-weight: 600;
  color: #7A7A8C;
}

.game-timer.timer-urgent,
.game-timer.timer-urgent + .game-timer-unit {
  color: #E05555;
}

.game-score {
  font-size: 32px;
  font-weight: 800;
  color: #1A1A2E;
  letter-spacing: -1px;
}

.game-word-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 0;
}

.game-word {
  font-weight: 900;
  color: #1A1A2E;
  text-align: center;
  white-space: nowrap;
  line-height: 1.1;
  /* font-size выставляется динамически через JS */
}

.game-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

/* ══════════════════════════════
   Экран результата
══════════════════════════════ */
#screen-result {
  justify-content: space-between;
}

.result-header {
  flex-shrink: 0;
}

.result-title {
  font-size: 15px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #B0A99F;
  margin-bottom: 8px;
}

.result-score {
  font-size: 48px;
  font-weight: 900;
  letter-spacing: -2px;
  line-height: 1;
  color: #1A1A2E;
}

.result-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  margin: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 500;
}

.result-guessed {
  background: #EAF5EA;
  color: #1A1A2E;
}

.result-skipped {
  background: transparent;
  color: #9A9A9A;
}

.result-mark {
  font-size: 15px;
  font-weight: 700;
  width: 18px;
  flex-shrink: 0;
}

.result-guessed .result-mark {
  color: #3DAA5C;
}

.result-skipped .result-mark {
  color: #C0BDB9;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

.btn-home {
  background: transparent;
  border: none;
  color: #B0A99F;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  padding: 8px;
  cursor: pointer;
  text-align: center;
  -webkit-user-select: none;
  user-select: none;
}

.btn-home:active {
  color: #1A1A2E;
}

/* ══════════════════════════════
   Экран правил
══════════════════════════════ */
#screen-rules {
  justify-content: space-between;
}

.rules-header {
  flex-shrink: 0;
}

.rules-list {
  list-style: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 24px 0;
}

.rules-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  font-size: 16px;
  line-height: 1.4;
  color: #1A1A2E;
}

.rules-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

/* ── Диалог ── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 46, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  z-index: 100;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.dialog-overlay.hidden {
  display: none;
}

.dialog {
  background: #F7F3EE;
  border-radius: 24px;
  padding: 32px 24px 24px;
  width: 100%;
  max-width: 319px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.dialog-text {
  font-size: 20px;
  font-weight: 700;
  color: #1A1A2E;
  text-align: center;
  line-height: 1.4;
}

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

/* ── Кнопка Назад ── */
.btn-back {
  position: absolute;
  top: 20px;
  left: 24px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #7A7A8C;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 50%;
  transition: background 80ms ease, color 80ms ease;
  -webkit-user-select: none;
  user-select: none;
}

.btn-back:active {
  background: #EDE8E1;
  color: #1A1A2E;
}

/* экраны с кнопкой назад — position: relative + отступ под стрелку */
#screen-sets,
#screen-ready {
  position: relative;
  padding-top: 72px;
}

/* ── Кнопки (общие) ── */
.btn {
  width: 100%;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.2px;
  transition: transform 80ms ease, opacity 80ms ease;
  -webkit-user-select: none;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
  opacity: 0.9;
}

.btn-primary {
  padding: 20px;
  background: #1A1A2E;
  color: #F7F3EE;
}

.btn-secondary {
  padding: 18px;
  background: transparent;
  color: #1A1A2E;
  border: 2px solid #C8C2BA;
  font-weight: 600;
}

.btn-secondary:active {
  background: #EDE8E1;
}
