:root{
  --card-cream:#FFF7E9;
  --card-border:#F0D9B3;
  --card-shadow-strong:0 18px 40px rgba(0,0,0,.18);
  --bg1:#ff9723;
  --bg2:#ff7c00;
  --card:#fff;
  --ink:#1f2937;
  --shadow:0 12px 30px rgba(0,0,0,.15);
  --round:22px;
}

*{box-sizing:border-box}

[hidden] {
  display: none !important;
}

body{
  height: 100%;
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial;
  color:var(--ink);
  background:#EC8D00;
}

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

/* HERO */
.hero{
  position:relative;
  background:linear-gradient(180deg,#EC8D00 0%,#E8654B 100%);
  color:#fff;
  padding:0px 0;
}
.hero-inner{
  position:relative; max-width:2400px; margin:0 auto; padding:0 12px;
  display:flex; align-items:center; justify-content:center;
}
.hero-brand{ position:absolute; left:20px; top:50%; transform:translateY(-50%); }
.hero-brand img{ width:76px; height:auto; object-fit:contain; }
.hero-title{ font-size:clamp(20px,2.5vw,32px); font-weight:800; text-shadow:0 2px 6px rgba(0,0,0,.18); white-space:nowrap; }
.lang-capsule.lang--on-hero{
  position:absolute; right:20px; top:50%; transform:translateY(-50%);
  display:flex; gap:6px; background:transparent; border:1px solid rgba(255,255,255,.9);
  border-radius:999px; padding:4px;
}
.lang--on-hero button{ border:0; background:transparent; color:#fff; padding:8px 12px; border-radius:999px; font-weight:800; cursor:pointer; }
.lang--on-hero button.active{ background:#fff; color:#EC8D00; box-shadow:0 2px 8px rgba(0,0,0,.15); }

/* СКРІНИ */
.screen{ 
  padding:40px 0;
  position: relative;
  z-index: 1;
}

.settings-screen {
  background-color: #EC8D00;
  min-height: 100vh;
  padding-top: 40px; 
  padding-bottom: 70px;
  z-index: 1;
}

.panel{
  width:100%;
  max-width:960px;
  margin:0 auto;
  background:var(--card-cream);
  border:1px solid var(--card-border);
  border-radius:22px;
  box-shadow:var(--card-shadow-strong);
  padding:26px 28px 22px;
  display:flex;
  flex-wrap:wrap;
  justify-content:space-between;
  gap:20px;
  position: relative;
}

/* КНОПКА BATTLE В ПРАВОМ ВЕРХНЕМ УГЛУ */
.battle-corner-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 0;
  background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
  transition: all 0.3s;
  z-index: 10;
}

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

.field{ flex:1 1 240px; }
.field.wide{ flex:1 1 100%; }
.inline-check{ display:flex; align-items:center; gap:8px; font-size:14px; color:#333; }
.digits{ display:flex; flex-wrap:wrap; gap:8px; margin-top:8px; }
.chip{ border:1px solid #E0D8CA; background:#fff; color:#222; padding:8px 12px; border-radius:999px; cursor:pointer; font-weight:700; transition:.2s; }
.chip.active{ background:#EC8D00; color:#fff; border-color:#EC8D00; box-shadow:0 3px 10px rgba(236,141,0,.25); }

.panel select{
  padding:10px 14px; border:1px solid #ddd; border-radius:14px; background:#fff; font-weight:600;
}

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

.btn{ padding:8px 12px; border-radius:12px; border:0; background:#f1f1f1; cursor:pointer; font-weight:700; font-size:14px; }
.btn.start{ background:#ff9a27; color:#fff; }
.btn.green{ background:#2f8f46; color:#fff; }
.btn.danger{ background:#e23d3d; color:#fff; }
.btn.ghost{ background:#e6e7ea; color:#2b2b2b; }

.confirm-screen {
  display: none !important;
}

/* ПОДТВЕРЖДЕНИЕ */
.confirm-card{
  width:min(760px,96vw);
  margin:0 auto;
  background:var(--card-cream);
  border:1px solid var(--card-border);
  border-radius:22px;
  box-shadow:var(--card-shadow-strong);
  padding:26px 28px 22px;
  color:#333;
  font-family:system-ui,-apple-system,"Segoe UI",Roboto,Arial;
}
.confirm-card h2{ margin:0 0 10px; color:#8a3b00; }
.confirm-list{
  list-style:none; padding:0; margin:0;
  display:grid; grid-template-columns:1fr 1fr; gap:10px 16px; color:#333;
}
.confirm-list li b{ color:#111; }
.confirm-actions{ display:flex; gap:12px; justify-content:flex-end; margin-top:18px; }

/* ========================================
   ЭКРАН ИГРЫ - СОЛО РЕЖИМ
   ======================================== */
.play-screen {
  background-color: #EC8D00;
  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 {
  width: 100%;
  position: relative;
  aspect-ratio: 16/9;
  background-image: url('assets/images/lion-bg.png');
  background-position: center center;
  background-size: contain;
  background-repeat: no-repeat;
  border-radius: 26px 0 0 26px;
  box-shadow: var(--shadow);
  overflow: visible;
}

/* ДОСКА */
.board {
  position: absolute;
  right: 8%;
  top: 8%;
  width: 50%;
  height: 40%;
  background: #fff;
  border-radius: 28px;
  border: 5px solid #8A3B00;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2%;
  overflow: hidden;
}

/* ДОСКА В БАТЛ-РЕЖИМІ - В ПРАВОМУ ВЕРХНЬОМУ КУТІ */
.scene-battle .board {
  width: 45%;
  height: 40%;
  right: 8%;
  top: 8%;
  transform: none;
}

.board::before {
  content: "";
  position: absolute;
  inset: 0px;
  border-radius: 22px;
  border: 4px solid #C9A86A;
  pointer-events: none;
  z-index: 1;
}

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

.board.is-correct::after {
  background: rgba(26, 127, 55, 0.18);
  opacity: 1;
}

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

/* ТЕКСТ ВОПРОСА */
.question{
  position: relative;
  z-index: 2;
  font-weight: 800;
  line-height: 1;
  font-size: min(14vh, 10vw, 100px);
  max-width: 100%;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ТЕКСТ ВОПРОСА В БАТЛ-РЕЖИМІ - 30% ВІД ВИСОТИ ДОШКИ */
.scene-battle .question {
  font-size: min(20vh, 14vw, 100px);
}

/* БЛОК УПРАВЛЕНИЯ - УЗКИЙ */
.card {
  background: #fff;
  border-radius: var(--round);
  box-shadow: var(--shadow);
  padding: 16px 14px;
  margin: 0;
}

.controls-bottom {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 14px;
  justify-content: space-between;
  border-radius: 0 26px 26px 0;
}

/* ПОЛЕ ВВОДА */
.answer-line {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.answer-line input {
  font-size: 24px;
  padding: 14px 16px;
  border: 2px solid #ccc;
  border-radius: 12px;
  width: 100%;
  text-align: center;
  font-weight: 600;
  margin-bottom: 10px;
}

/* КНОПКИ ВЕРХНИЕ (Відповісти + Далі) */
.btn-row-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* СТАТИСТИКА */
.score {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 11px;
  color: #555;
  margin: 6px 0;
}

.score span {
  background: #f8f8f8;
  padding: 5px 8px;
  border-radius: 8px;
  text-align: center;
}

.score b {
  color: #111;
  font-weight: 700;
}

/* ПРОГРЕСС */
.progress {
  position: relative;
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #eee;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .08);
  overflow: hidden;
  margin: 8px 0;
}

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

.progress.mini {
  height: 10px;
}

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

.progress__green {
  background: #2F8F46;
  left: 0;
}

.progress__red {
  background: #E23D3D;
}

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

/* КНОПКИ НИЖНИЕ (Завершити + Скинути) */
.btn-row-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

/* ========================================
   БАТЛ РЕЖИМ - ДОШКИ В ПРАВОМУ ВЕРХНЬОМУ КУТІ
   ======================================== */
.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;
}

/* ГРАВЕЦЬ 1 */
.player-1 {
  justify-self: end;
}

/* ГРАВЕЦЬ 2 */
.player-2 {
  justify-self: start;
}

.player-header {
  text-align: center;
  background: rgba(255, 255, 255, 0.95);
  padding: 10px 16px;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.player-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: #8A3B00;
}

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

.controls-battle {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.score-mini span {
  background: #f8f8f8;
  padding: 6px 10px;
  border-radius: 8px;
  font-weight: 600;
}

/* РАЗДЕЛИТЕЛЬ VS - СКРЫТ */
.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: 800;
  border-radius: 14px;
  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: all 0.3s;
}

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

/* ЭКРАН РЕЗУЛЬТАТОВ */
.results-screen {
  background: #EC8D00;
  min-height: 100vh;
  padding: 40px 0 80px;
  position: relative;
  z-index: 100;
}

.result-card {
  width: 100%;
  margin: 0 auto;
  background: var(--card-cream);
  border: 1px solid var(--card-border);
  border-radius: 22px;
  box-shadow: var(--card-shadow-strong);
  padding: 26px 28px 22px;
  color: #333;
  text-align: center;
}

.result-card h2 {
  margin: 0 0 14px;
  color: #8A3B00;
  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: #fff;
  border: 1px solid #efeadf;
  border-radius: 14px;
  padding: 10px 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .06);
}

.result-stats span {
  font-size: 13px;
  color: #666;
}

.result-stats b {
  font-size: 18px;
  color: #111;
}

.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;
}

/* ========================================
   АДАПТИВ
   ======================================== */

/* Планшеты - Соло */
@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;
    background-size: contain;
    border-radius: 26px;
  }
  
  .controls-bottom {
    width: 100%;
    height: auto;
    max-width: 600px;
    margin: 0 auto;
    border-radius: 26px;
  }
  
  .board {
    width: 50%;
    height: 32%;
    right: 5%;
    top: 5%;
  }
  
  /* Батл на планшетах - повертаємо до grid */
  .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: 56px;
  }
  
  .hero-title {
    font-size: clamp(20px, 5.6vw, 28px);
  }
  
  .field {
    flex: 1 1 100%;
  }
  
  .confirm-list {
    grid-template-columns: 1fr;
  }
  
  .board {
    width: 60%;
    height: 38%;
    right: 5%;
    top: 5%;
  }
  
  .result-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .scene {
    aspect-ratio: 16/9;
    background-size: contain;
  }
  
  .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: 52px;
    height: 52px;
  }
  
  .hero .hero-title {
    font-size: clamp(18px, 5.2vw, 22px);
    line-height: 1.2;
    text-align: center;
    margin: 0;
    max-width: 100%;
    white-space: normal;
    text-wrap: balance;
  }
  
  .hero .lang-capsule {
    align-self: center;
    margin-top: 2px;
    gap: 6px;
    border-width: 1px;
    padding: 3px 4px;
    z-index: 0;
  }
  
  .hero .lang-capsule button {
    padding: 6px 10px;
    line-height: 1;
  }
  
  .board {
    top: 5%;
    right: 5%;
    width: 65%;
    height: 40%;
    padding: 2%;
  }
  
  .scene {
    aspect-ratio: 16/9;
    background-size: contain;
  }
  
  .question {
    font-size: min(7vh, 5vw, 48px);
  }
  
  .controls-bottom {
    min-width: 100%;
    height: auto;
    max-height: none;
  }
  
  .scene-battle {
    aspect-ratio: 16/9;
  }
}

@media (max-width: 400px) {
  .board {
    padding: 1.5%;
    top: 5%;
    right: 5%;
    width: 70%;
    height: 42%;
  }
  
  .question {
    font-size: min(6vh, 4.5vw, 40px);
  }
  
  .answer-line input {
    font-size: 16px;
  }
  
  .btn-row-top,
  .btn-row-bottom {
    grid-template-columns: 1fr;
  }
}

/* ── HERO: компактная шапка ─────────────────────────── */
.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:auto; }

  .hero-title{
    margin:0;
    text-align:center;
    font-size:clamp(18px,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:6px 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; }
  .hero-title{ font-size:clamp(16px,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,.9);
    background:transparent;
    color:#fff; font-weight:800;
  }
}

/* ── MacBook та середні екрани (900px - 1600px) ────────── */
@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;
  }
}

/* ── Великі екрани (1600px+) ────────────────────────────── */
@media (min-width: 1601px) {
  .container {
    width: 100%;
    max-width: 1920px;
  }
  
  .play-layout-solo {
    max-width: 1920px;
  }
  
  /* Оптимізація розміру фону для великих екранів */
  .scene {
    background-size: contain;
    aspect-ratio: 16/9;
  }
}

/* ── Full HD і вище (1920px+) - зберігаємо пропорції ─────── */
@media (min-width: 1920px) {
  .play-screen .container {
    max-width: 1920px;
    margin: 0 auto;
  }
  
  .play-layout-solo {
    max-width: 1920px;
  }
  
  .scene {
    background-size: contain;
    aspect-ratio: 16/9;
  }
  
  .controls-bottom {
    width: 100%;
  }
}

/* ── Дуже великі екрани 2K+ (2000px+) ────────────────────── */
@media (min-width: 2000px) {
  .scene {
    background-size: contain;
    aspect-ratio: 16/9;
  }
  
  .play-screen .container {
    max-width: 1920px;
  }
  
  .play-layout-solo {
    max-width: 1920px;
  }
}
