/* ============================================
   CSS VARIABLES — Abacus Simulator Design System
   ============================================ */
:root {
  --color-primary:    #ff7c00;
  --color-primary-dark: #e06600;
  --color-background: #fdf8f3;
  --color-surface:    #f8f6f0;
  --color-text:       #333333;
  --color-muted:      #7d733a;
  --radius-large:     24px;
  --radius-medium:    16px;
  --radius-small:     10px;
  --shadow-soft:      0 12px 30px rgba(255, 124, 0, 0.15);
  --shadow-inset:     inset 0 -8px 15px rgba(0, 0, 0, 0.15);
  --transition:       0.25s ease;
  /* backwards-compat aliases used in JS-generated HTML */
  --card-cream:       #f8f6f0;
  --card-border:      rgba(255, 124, 0, 0.2);
  --card-shadow-strong: 0 12px 30px rgba(255, 124, 0, 0.15);
  --card:             #fff;
  --ink:              #333333;
  --shadow:           0 12px 30px rgba(255, 124, 0, 0.12);
  --round:            24px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  height: 100%;
  margin: 0;
  font-family: "Montserrat", system-ui, -apple-system, sans-serif;
  color: var(--color-text);
  background: var(--color-background);
}

.container { width: min(2400px, 96vw); margin: 0 auto; padding: 0 8px; }

/* ============================================
   HERO / HEADER
   ============================================ */
/* ============================================
   HERO / HEADER
   ============================================ */
.hero {
  position: relative;
  background: linear-gradient(135deg, var(--color-primary) 0%, #ff9a2b 100%);
  color: #fff8ec;
  padding: 2px 48px; /* Ровно 2px сверху и снизу */
  box-shadow: var(--shadow-inset);
  min-height: 46px; /* 42px (логотип) + 2px (верх) + 2px (низ) */
}

.hero-inner {
  position: relative;
  max-width: 2400px;
  width: 100%;
  margin: 0 auto;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px; /* Высота подгоняется под размер логотипа */
}

.hero-brand {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  display: flex; /* Убирает скрытые отступы под картинкой */
}

.hero-brand img {
  width: 42px; 
  height: 42px; 
  object-fit: contain;
  border-radius: 10px; /* Чуть уменьшил скругление для компактности */
  background: rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  padding: 2px;
  display: block;
}

.hero-title {
  font-family: "Baloo 2", cursive;
  font-size: clamp(20px, 2.5vw, 32px);
  font-weight: 800;
  color: #fff8ec;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  white-space: nowrap;
  /* САМОЕ ВАЖНОЕ ДЛЯ СУЖЕНИЯ: */
  margin: 0; /* Убиваем стандартные отступы h1 */
  line-height: 1; /* Убираем высоту строки */
}

/* --- Капсула с языками --- */
.lang-capsule.lang--on-hero {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 248, 236, 0.8); /* Сделал рамку тоньше (1px) */
  border-radius: 999px;
  padding: 2px; /* Минимальный отступ внутри капсулы */
  backdrop-filter: blur(8px);
}

.lang--on-hero button {
  border: 0;
  background: transparent;
  color: #fff8ec;
  padding: 4px 10px; /* Сделал кнопки ниже */
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.8rem;
  line-height: 1; /* Убрал высоту строки внутри кнопок */
  cursor: pointer;
  transition: var(--transition);
}

.lang--on-hero button.active {
  background: #fff8ec;
  color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(255, 255, 255, 0.35);
}

/* ============================================
   STEP INDICATOR NAV
   ============================================ */
.steps-nav {
  background: var(--color-surface);
  border-bottom: 1px solid rgba(255, 124, 0, 0.15);
  padding: 10px 24px;
}

.step-indicator {
  display: flex;
  align-items: center;
  list-style: none;
  padding: 0;
  margin: 0;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}

.step-indicator__item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
  color: rgba(51, 51, 51, 0.4);
  transition: var(--transition);
  cursor: default;
}

.step-indicator__item.active {
  color: var(--color-primary);
}

.step-indicator__item.complete {
  color: rgba(51, 51, 51, 0.35);
}

.step-indicator__badge {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 124, 0, 0.1);
  color: var(--color-muted);
  font-size: 13px;
  font-weight: 700;
  transition: var(--transition);
  flex-shrink: 0;
}

.step-indicator__item.active .step-indicator__badge {
  background: var(--color-primary);
  color: #fff8ec;
  box-shadow: 0 4px 10px rgba(255, 124, 0, 0.3);
}

.step-indicator__item.complete .step-indicator__badge {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.step-indicator__sep {
  list-style: none;
  color: rgba(125, 115, 58, 0.3);
  font-size: 16px;
  line-height: 1;
}

@media (max-width: 480px) {
  .step-indicator__label { display: none; }
  .step-indicator { gap: 4px; }
}

/* ============================================
   SCREENS (generic)
   ============================================ */
.screen {
  padding: 40px 0;
  position: relative;
  z-index: 1;
}

/* ============================================
   SETTINGS SCREEN
   ============================================ */
.settings-screen {
  background-color: var(--color-background);
  min-height: 100vh;
  padding-top: 40px;
  padding-bottom: 70px;
  z-index: 1;
}

.panel {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  background: var(--color-surface);
  border: 1px solid rgba(255, 124, 0, 0.15);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow-soft);
  padding: 32px 40px 28px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 20px;
  position: relative;
}

/* BATTLE BUTTON */
.battle-corner-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  padding: 10px 20px;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(135deg, #ff6b35 0%, var(--color-primary) 100%);
  color: #fff8ec;
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
  transition: var(--transition);
  z-index: 10;
}

.battle-corner-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 107, 53, 0.4);
}

.field { flex: 1 1 240px; }
.field.wide { flex: 1 1 100%; }
.inline-check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--color-text); }
.digits { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* CHIPS (digit selector) */
.chip {
  background: rgba(255, 124, 0, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 124, 0, 0.2);
  border: none;
  color: var(--color-muted);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: var(--transition);
}

.chip.active {
  background: var(--color-primary);
  color: #fff8ec;
  box-shadow: 0 6px 14px rgba(255, 124, 0, 0.3);
}

.panel select {
  padding: 10px 14px;
  border: 1px solid rgba(125, 115, 58, 0.25);
  border-radius: var(--radius-medium);
  background: #fff;
  font-weight: 600;
  font-size: 1rem;
  font-family: "Montserrat", sans-serif;
  transition: var(--transition);
}

.panel select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(255, 124, 0, 0.12);
}

.panel-btn {
  flex: 1 1 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  padding: 10px 20px;
  border-radius: 999px;
  border: 0;
  background: rgba(125, 115, 58, 0.1);
  cursor: pointer;
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--color-muted);
  transition: transform var(--transition), box-shadow var(--transition);
}

.btn.start {
  background: var(--color-primary);
  color: #fff8ec;
  box-shadow: 0 12px 20px rgba(255, 124, 0, 0.25);
}

.btn.start:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 26px rgba(255, 124, 0, 0.3);
}

.btn.green {
  background: #10b981;
  color: #fff;
  box-shadow: 0 8px 16px rgba(16, 185, 129, 0.25);
}

.btn.green:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 22px rgba(16, 185, 129, 0.3);
}

.btn.danger {
  background: #e23d3d;
  color: #fff;
  box-shadow: 0 8px 16px rgba(226, 61, 61, 0.2);
}

.btn.danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 22px rgba(226, 61, 61, 0.3);
}

.btn.ghost {
  background: rgba(125, 115, 58, 0.12);
  color: var(--color-muted);
}

.btn.ghost:hover {
  background: rgba(125, 115, 58, 0.2);
}

/* CONFIRM screen */
.confirm-screen {
  background-color: var(--color-background);
  min-height: 100vh;
  padding-top: 40px;
  padding-bottom: 70px;
}

.confirm-card {
  width: min(760px, 96vw);
  margin: 0 auto;
  background: var(--color-surface);
  border: 1px solid rgba(255, 124, 0, 0.15);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow-soft);
  padding: 32px 40px 28px;
  color: var(--color-text);
  font-family: "Montserrat", sans-serif;
}

.confirm-card h2 {
  margin: 0 0 10px;
  color: var(--color-muted);
  font-family: "Baloo 2", cursive;
}

.confirm-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
  color: var(--color-text);
}

.confirm-list li b { color: var(--color-primary); }

.confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 18px;
}

/* ============================================
   PLAY SCREEN — SOLO
   ============================================ */
.play-screen {
  background-color: var(--color-background);
  min-height: 100vh;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

.play-screen .container {
  display: flex;
  gap: 0;
  align-items: stretch;
  flex-wrap: nowrap;
  max-width: 1920px;
  width: 100%;
}

.play-layout-solo {
  display: grid;
  grid-template-columns: 75% 25%;
  gap: 0;
  width: 100%;
  max-width: 1920px;
  margin: 0 auto;
  align-items: stretch;
}

/* SCENE */
.scene {
  width: 100%;
  position: relative;
  aspect-ratio: 16/9;
  background: var(--color-surface);
  border-radius: 24px 0 0 24px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: flex-start; /* Было center - теперь прижимаем к верху */
  padding-top: 10px; /* Задаем те самые 10px от верхнего края */
}

.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 0;
}

.scene.is-correct::after {
  background: rgba(16, 185, 129, 0.14);
  opacity: 1;
}

.scene.is-wrong::after {
  background: rgba(226, 61, 61, 0.12);
  opacity: 1;
}

/* QUESTION */
.question {
  position: relative;
  z-index: 2;
  font-family: "Baloo 2", cursive;
  font-weight: 700; /* Было 800 - сделали тоньше */
  line-height: 1;
  font-size: min(8.5vh, 6vw, 102px); /* Уменьшили на ~15% (было 10vh, 7vw, 120px) */
  max-width: 90%;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-muted);
  padding: 0 16px; /* Убрали вертикальный padding, чтобы работал padding-top из .scene */
}

.scene-battle .question {
  font-size: min(12vh, 8vw, 100px);
}

/* CONTROLS CARD */
.card {
  background: var(--color-surface);
  border-radius: var(--round);
  box-shadow: var(--shadow-soft);
  padding: 16px 14px;
  margin: 0;
}

.controls-bottom {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 16px;
  justify-content: space-between;
  border-radius: 0 24px 24px 0;
  background: var(--color-surface);
  box-shadow: var(--shadow-soft);
}

/* ANSWER INPUT */
.answer-line {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.answer-line input {
  font-family: "Baloo 2", cursive;
  font-size: 24px;
  padding: 14px 16px;
  border: 1px solid rgba(125, 115, 58, 0.25);
  border-radius: var(--radius-medium);
  width: 100%;
  text-align: center;
  font-weight: 700;
  margin-bottom: 10px;
  background: #fff;
  color: var(--color-text);
  transition: var(--transition);
}

.answer-line input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(255, 124, 0, 0.12);
}

/* BUTTON ROWS */
.btn-row-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* SCORE */
.score {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 11px;
  color: var(--color-muted);
  margin: 6px 0;
}

.score span {
  background: rgba(255, 124, 0, 0.06);
  border: 1px solid rgba(255, 124, 0, 0.12);
  padding: 5px 8px;
  border-radius: 10px;
  text-align: center;
}

.score b {
  color: var(--color-primary);
  font-weight: 700;
}

/* PROGRESS BARS */
.progress {
  position: relative;
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(125, 115, 58, 0.1);
  overflow: hidden;
  margin: 8px 0;
}

.progress.big {
  height: 20px;
  margin: 14px 0;
}

.progress.mini {
  height: 8px;
}

.progress__green,
.progress__red,
.progress__rest {
  position: absolute;
  top: 0;
  bottom: 0;
}

.progress__green {
  background: linear-gradient(135deg, var(--color-primary), #ffc366);
  left: 0;
}

.progress__red {
  background: #e23d3d;
}

.progress__rest {
  background: rgba(0, 0, 0, 0.05);
  right: 0;
}

.btn-row-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

/* ============================================
   BATTLE MODE
   ============================================ */
.play-layout-battle {
  position: relative;
  width: 100%;
  max-width: 2400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 20px;
}

.player-zone {
  position: relative;
  width: 100%;
  max-width: 700px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.player-1 { justify-self: end; }
.player-2 { justify-self: start; }

.player-header {
  text-align: center;
  background: var(--color-surface);
  border: 1px solid rgba(255, 124, 0, 0.15);
  padding: 10px 16px;
  border-radius: var(--radius-medium);
  box-shadow: var(--shadow-soft);
}

.player-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  font-family: "Baloo 2", cursive;
  color: var(--color-muted);
}

.scene-battle {
  aspect-ratio: 16/9;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-size: cover;
  background-position: center center;
  border-radius: var(--radius-large);
  overflow: hidden;
}

.controls-battle {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--color-surface);
  border-radius: var(--radius-medium);
  box-shadow: var(--shadow-soft);
}

.score-mini {
  display: flex;
  justify-content: space-around;
  gap: 8px;
  font-size: 12px;
  margin-top: 8px;
}

.score-mini span {
  background: rgba(255, 124, 0, 0.08);
  border: 1px solid rgba(255, 124, 0, 0.12);
  padding: 6px 10px;
  border-radius: 10px;
  font-weight: 600;
}

.battle-divider { display: none; }

.battle-finish {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  margin-top: 15px;
  z-index: 10;
}

.battle-finish button {
  padding: 12px 32px;
  font-size: 16px;
  font-weight: 700;
  font-family: "Montserrat", sans-serif;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(135deg, #e23d3d 0%, #c62828 100%);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(226, 61, 61, 0.35);
  transition: var(--transition);
}

.battle-finish button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(226, 61, 61, 0.45);
}

/* ============================================
   RESULTS SCREEN
   ============================================ */
.results-screen {
  background: var(--color-background);
  min-height: 100vh;
  padding: 40px 0 80px;
  position: relative;
  z-index: 100;
}

.result-card {
  width: 100%;
  margin: 0 auto;
  background: var(--color-surface);
  border: 1px solid rgba(255, 124, 0, 0.15);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow-soft);
  padding: 32px 40px 28px;
  color: var(--color-text);
  text-align: center;
}

.result-card h2 {
  margin: 0 0 14px;
  color: var(--color-muted);
  font-family: "Baloo 2", cursive;
  font-weight: 800;
  font-size: 26px;
}

.result-stats {
  margin: 12px 0 8px;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px 16px;
}

.result-stats li {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 124, 0, 0.06);
  border: 1px solid rgba(255, 124, 0, 0.15);
  border-radius: var(--radius-medium);
  padding: 12px 8px;
  box-shadow: 0 4px 10px rgba(255, 124, 0, 0.08);
}

.result-stats span {
  font-size: 13px;
  color: var(--color-muted);
}

.result-stats b {
  font-family: "Baloo 2", cursive;
  font-size: 20px;
  color: var(--color-primary);
}

.result-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 14px;
  position: relative;
  z-index: 2;
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  display: none;
}

/* ============================================
   RESPONSIVE
   ============================================ */

/* Tablets — solo */
@media (max-width: 900px) {
  .play-layout-solo {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    gap: 20px;
  }

  .scene {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 24px;
  }

  .controls-bottom {
    width: 100%;
    height: auto;
    max-width: 600px;
    margin: 0 auto;
    border-radius: 24px;
  }

  .play-layout-battle {
    position: static;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 16px;
    padding: 10px;
  }

  .player-zone {
    position: static;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    justify-self: center;
  }

  .player-1, .player-2 { justify-self: center; }
  .player-1 { grid-row: 1; }
  .player-2 { grid-row: 2; }

  .battle-finish {
    grid-row: 3;
    grid-column: 1;
    margin-top: 10px;
  }

  .scene-battle {
    aspect-ratio: 16/9;
    width: 100%;
    background-size: cover;
    background-position: center center;
  }

  .controls-bottom { height: auto; max-height: none; }
}

@media (max-width: 768px) {
  .hero-brand img { width: 52px; height: 52px; }
  .hero-title { font-size: clamp(18px, 5.6vw, 26px); }
  .field { flex: 1 1 100%; }
  .confirm-list { grid-template-columns: 1fr; }

  .result-stats { grid-template-columns: repeat(2, 1fr); }
  .scene { aspect-ratio: 16/9; }
  .question { font-size: min(8vh, 6vw, 64px); }
  .controls-bottom { height: auto; max-height: none; }
}

@media (max-width: 640px) {
  .hero { padding: 10px 0 12px; }

  .hero-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
  }

  .hero .hero-brand,
  .hero .hero-title,
  .hero .lang-capsule {
    position: static !important;
    transform: none !important;
  }

  .hero .hero-brand img { width: 48px; height: 48px; }

  .hero .hero-title {
    font-size: clamp(16px, 5.2vw, 22px);
    line-height: 1.2;
    text-align: center;
    margin: 0;
    max-width: 100%;
    white-space: normal;
  }

  .hero .lang-capsule {
    align-self: center;
    margin-top: 2px;
    gap: 4px;
    border-width: 1px;
    padding: 3px 4px;
    z-index: 0;
  }

  .hero .lang-capsule button {
    padding: 5px 10px;
    font-size: 0.8rem;
  }

  .scene { aspect-ratio: 16/9; }
  .question { font-size: min(7vh, 5vw, 48px); }
  .controls-bottom { min-width: 100%; height: auto; max-height: none; }
  .scene-battle { aspect-ratio: 16/9; }

  .panel { padding: 24px 20px 20px; }
}

@media (max-width: 400px) {
  .question { font-size: min(6vh, 4.5vw, 40px); }
  .answer-line input { font-size: 18px; }
  .btn-row-top, .btn-row-bottom { grid-template-columns: 1fr; }
}

/* compact hero on medium screens */
.hero { padding: 10px 0; }

@media (max-width: 980px) {
  .hero { padding: 8px 0; }

  .hero-inner {
    max-width: 2400px;
    margin: 0 auto;
    padding: 0 10px;
    display: grid;
    grid-template-columns: 56px 1fr auto;
    align-items: center;
    gap: 8px;
  }

  .hero-brand { position: static !important; transform: none !important; }
  .hero-brand img { width: 48px; height: 48px; }

  .hero-title {
    margin: 0;
    text-align: center;
    font-size: clamp(16px, 3.6vw, 24px);
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .lang-capsule {
    position: static !important;
    transform: none !important;
    margin-left: auto;
    border-width: 1px;
    padding: 2px 4px;
    gap: 4px;
  }

  .lang-capsule button {
    padding: 5px 8px;
    font-size: 13px;
    border-radius: 999px;
  }
}

.lang-select { display: none; }

@media (max-width: 560px) {
  .hero { padding: 6px 0; }
  .hero-inner { grid-template-columns: 40px 1fr auto; gap: 6px; }
  .hero-brand img { width: 40px; height: 40px; }
  .hero-title { font-size: clamp(14px, 4.2vw, 20px); }

  .lang-capsule { display: none; }
  .lang-select {
    display: block;
    appearance: none;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    background: transparent;
    color: #fff8ec;
    font-weight: 700;
  }
}

/* Medium screens */
@media (min-width: 901px) and (max-width: 1600px) {
  .container { width: 96vw; max-width: 1920px; }
  .play-screen .container, .play-layout-battle { max-width: 1920px; width: 100%; }
  .play-layout-solo { max-width: 1920px; }
}

/* Large screens */
@media (min-width: 1601px) {
  .container { width: 100%; max-width: 1920px; }
  .play-layout-solo { max-width: 1920px; }
  .scene { aspect-ratio: 16/9; }
}

@media (min-width: 1920px) {
  .play-screen .container { max-width: 1920px; margin: 0 auto; }
  .play-layout-solo { max-width: 1920px; }
  .scene { aspect-ratio: 16/9; }
  .controls-bottom { width: 100%; }
}

@media (min-width: 2000px) {
  .scene { aspect-ratio: 16/9; }
  .play-screen .container { max-width: 1920px; }
  .play-layout-solo { max-width: 1920px; }
}

/* ============================================
   SETTINGS CONTROLS
   ============================================ */

/* Series counter */
.series-control {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.series-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 124, 0, 0.2);
  background: var(--color-primary);
  color: #fff8ec;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  transition: var(--transition);
}

.series-btn:hover {
  background: var(--color-primary-dark);
}

#seriesInput {
  width: 70px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  font-family: "Baloo 2", cursive;
  padding: 6px;
  border: 1px solid rgba(125, 115, 58, 0.25);
  border-radius: var(--radius-medium);
  background: #fff;
  transition: var(--transition);
}

#seriesInput:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(255, 124, 0, 0.12);
}

#seriesInput:disabled { opacity: 0.4; }

.series-inf-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  color: var(--color-muted);
}

/* Timer display */
.timer-display {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  font-family: "Baloo 2", cursive;
  color: var(--color-primary);
  background: rgba(255, 124, 0, 0.08);
  border: 1px solid rgba(255, 124, 0, 0.15);
  border-radius: var(--radius-small);
  padding: 6px 10px;
}

.res-timer {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-muted);
  margin-bottom: 10px;
}

/* Hints */
.settings-hint {
  flex: 1 1 100%;
  background: rgba(255, 124, 0, 0.06);
  border: 1px solid rgba(255, 124, 0, 0.2);
  border-radius: var(--radius-small);
  padding: 8px 14px;
  font-size: 13px;
  color: var(--color-muted);
  font-weight: 600;
}

.settings-preview {
  flex: 1 1 100%;
  background: rgba(255, 124, 0, 0.06);
  border: 1px solid rgba(255, 124, 0, 0.15);
  border-radius: var(--radius-small);
  padding: 8px 14px;
  font-size: 14px;
  font-family: "Baloo 2", cursive;
  color: var(--color-primary);
  font-weight: 700;
  min-height: 36px;
}

/* ============================================
   SETTINGS BLOCKS
   ============================================ */
.settings-block {
  flex: 1 1 45%;
  background: rgba(255, 248, 236, 0.7);
  border: 1px solid rgba(255, 124, 0, 0.2);
  border-radius: var(--radius-medium);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-block.wide { flex: 1 1 100%; }

.settings-block-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

/* Checkbox row */
.ops-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Checkbox label pill */
.op-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  background: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 124, 0, 0.2);
  transition: var(--transition);
  user-select: none;
}

.op-check:hover {
  border-color: var(--color-primary);
  background: rgba(255, 124, 0, 0.04);
}

.op-check input[type="checkbox"],
.op-check input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* Range settings */
.range-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 124, 0, 0.12);
  margin-top: 4px;
}

.range-select {
  padding: 8px 12px;
  border: 1px solid rgba(125, 115, 58, 0.25);
  border-radius: var(--radius-medium);
  background: #fff;
  font-weight: 600;
  font-size: 14px;
  font-family: "Montserrat", sans-serif;
  width: 100%;
  transition: var(--transition);
}

.range-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(255, 124, 0, 0.12);
}

.range-multi {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Fractions */
.frac-options {
  display: flex;
  gap: 10px;
  padding-left: 4px;
}

/* Responsive settings blocks */
@media (max-width: 640px) {
  .settings-block { flex: 1 1 100%; }
  .panel { padding: 20px 16px; }
}

/* ============================================
   FLOATING ABACUS
   ============================================ */
.abacus-wrapper {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1000;
  background: var(--color-surface);
  border-radius: var(--radius-medium);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  padding: 16px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: none;
  user-select: none;
  -webkit-user-select: none;
  will-change: opacity, transform;
  transition: box-shadow 0.3s ease;
}

.abacus-wrapper.visible {
  display: block;
  animation: abacusSlideIn 0.4s ease-out;
}

.abacus-wrapper:hover {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

@keyframes abacusSlideIn {
  from { opacity: 0; transform: translateY(80px); }
  to   { opacity: 1; transform: translateY(0); }
}

.abacus-close-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid rgba(192, 166, 127, 0.3);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--color-muted);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition);
  z-index: 1001;
}

.abacus-close-btn:hover {
  background: rgba(192, 166, 127, 0.5);
  transform: scale(1.1);
}

.abacus-reset-btn {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid rgba(192, 166, 127, 0.3);
  font-size: 18px;
  cursor: pointer;
  color: var(--color-muted);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition);
  z-index: 1001;
}

.abacus-reset-btn:hover {
  background: rgba(192, 166, 127, 0.5);
  transform: scale(1.1) rotate(180deg);
}

.abacus-container {
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
}

#abacus-svg {
  display: block;
  margin: 0 auto;
  user-select: none;
  touch-action: none;
}

#abacus-svg .bead { cursor: grab; }
#abacus-svg .bead:active { cursor: grabbing; }

.abacus-wrapper * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Abacus toggle button */
.btn-abacus {
  width: 100%;
  padding: 10px 16px;
  background: rgba(255, 124, 0, 0.08);
  border: 1px solid rgba(255, 124, 0, 0.25);
  border-radius: 999px;
  color: var(--color-primary);
  font-family: "Montserrat", sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.btn-abacus:hover {
  background: var(--color-primary);
  color: #fff8ec;
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(255, 124, 0, 0.25);
}

.btn-abacus.active {
  background: var(--color-primary);
  color: #fff8ec;
  box-shadow: 0 8px 16px rgba(255, 124, 0, 0.25);
}
