/* ============ Birthday Quiz — стили (TV-адаптивные) ============ */
/* Все размеры в vw/vh/clamp — масштабируются под любой экран. */
/* Safe-zone для overscan: ~3vw по бокам, 3vh сверху/снизу. */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: 'Segoe UI', 'Roboto', Arial, sans-serif;
  background: radial-gradient(ellipse at center, #1a1340 0%, #0a0820 70%, #000 100%);
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  /* базовый шрифт привязан к высоте экрана — главный масштабирующий якорь */
  font-size: clamp(14px, 1.6vh, 28px);
}

:root {
  --gold: #ffd24a;
  --gold-deep: #d4a017;
  --gold-glow: #ffe88a;
  --bg-dark: #0a0820;
  --bg-card: rgba(20, 15, 50, 0.85);
  --green: #2ecc71;
  --red:   #e74c3c;
  --focus: #ffd24a;
  /* Safe-zone: TV-overscan и просто отступ от краёв */
  --safe-x: 4vw;
  --safe-y: 4vh;
}

/* ============ Универсальные классы ============ */

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--safe-y) var(--safe-x);
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  text-align: center;
}
.screen.active { display: flex; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 8vh;
  padding: 1.5vh 3vw;
  font-size: clamp(20px, 2.6vh, 40px);
  font-weight: 700;
  color: #000;
  background: linear-gradient(180deg, var(--gold-glow), var(--gold) 50%, var(--gold-deep));
  border: 0.3vh solid transparent;
  border-radius: 1.2vh;
  cursor: pointer;
  outline: none;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  box-shadow: 0 0.8vh 2.4vh rgba(0,0,0,0.5);
  max-width: 90vw;
  white-space: nowrap;
}
.btn:hover { transform: scale(1.03); box-shadow: 0 0 2.5vh var(--gold-glow); }
.btn:focus, .btn.focused {
  border-color: #fff;
  transform: scale(1.05);
  box-shadow: 0 0 3vh var(--gold-glow), 0 0 6vh var(--gold);
}

.title {
  font-size: clamp(28px, 6vh, 88px);
  font-weight: 900;
  text-align: center;
  color: var(--gold);
  text-shadow: 0 0 2.4vh rgba(255, 210, 74, 0.6);
  margin-bottom: 2vh;
  letter-spacing: 0.05em;
  max-width: 92vw;
  line-height: 1.1;
}

.subtitle {
  font-size: clamp(18px, 3vh, 44px);
  color: #fff;
  text-align: center;
  margin-bottom: 3vh;
  opacity: 0.92;
  max-width: 90vw;
  line-height: 1.25;
}

/* ============ Welcome screen ============ */

#screen-welcome {
  background: radial-gradient(ellipse at center, #2a1d70 0%, #0a0820 80%);
}
#screen-welcome .title {
  font-size: clamp(32px, 8vh, 120px);
  animation: pulse 2s ease-in-out infinite;
}
#screen-welcome .name {
  font-size: clamp(48px, 12vh, 180px);
  background: linear-gradient(180deg, #fff 0%, var(--gold) 50%, var(--gold-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 1vh 0 3vh;
  animation: glow 3s ease-in-out infinite;
  text-align: center;
  line-height: 1;
  max-width: 92vw;
  word-break: break-word;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}
@keyframes glow {
  0%, 100% { filter: drop-shadow(0 0 2.4vh var(--gold)); }
  50% { filter: drop-shadow(0 0 4.8vh var(--gold-glow)); }
}

/* ============ Topic select ============ */

.topic-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2.5vh 2.5vw;
  width: min(78vw, 1400px);
  margin-top: 1vh;
}

.topic-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3vh 2vw;
  min-height: 22vh;
  background: var(--bg-card);
  border: 0.4vh solid transparent;
  border-radius: 2vh;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.topic-card .icon { font-size: clamp(40px, 8vh, 120px); margin-bottom: 1vh; line-height: 1; }
.topic-card .name { font-size: clamp(22px, 3.6vh, 56px); font-weight: 700; color: var(--gold); }

.topic-card:hover {
  border-color: var(--focus);
  background: rgba(40, 30, 100, 0.95);
  transform: scale(1.04);
  box-shadow: 0 0 3.5vh var(--gold-glow);
}
.topic-card.focused {
  border-color: var(--focus);
  transform: scale(1.04);
  box-shadow: 0 0 3.5vh var(--gold-glow);
  background: rgba(40, 30, 100, 0.95);
}

/* ============ Question screen ============ */

#screen-question {
  justify-content: flex-start;
  gap: 1.2vh;
  padding-top: 3vh;
}

.ladder {
  display: flex;
  justify-content: center;
  gap: 1vw;
  width: 100%;
  margin-bottom: 0.5vh;
  flex-wrap: nowrap;
}
.ladder .step {
  flex: 0 0 auto;
  padding: 1vh 1.6vw;
  font-size: clamp(16px, 2.2vh, 32px);
  font-weight: 700;
  color: rgba(255,255,255,0.4);
  background: rgba(20,15,50,0.6);
  border: 0.2vh solid rgba(255, 210, 74, 0.2);
  border-radius: 0.8vh;
  white-space: nowrap;
}
.ladder .step.done {
  color: #fff;
  background: rgba(46, 204, 113, 0.25);
  border-color: var(--green);
}
.ladder .step.current {
  color: #000;
  background: linear-gradient(180deg, var(--gold-glow), var(--gold));
  border-color: var(--gold-deep);
  transform: scale(1.08);
  box-shadow: 0 0 2.4vh var(--gold);
}

.timer-bar {
  width: 100%;
  height: 1.4vh;
  background: rgba(255,255,255,0.1);
  border-radius: 0.7vh;
  overflow: hidden;
  margin: 0.5vh 0 1vh;
}
.timer-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--gold), var(--red));
  width: 100%;
  transition: width 0.25s linear;
}

.question-text {
  font-size: clamp(22px, 4vh, 56px);
  font-weight: 600;
  text-align: center;
  margin: 1vh 0 1.5vh;
  max-width: 88vw;
  line-height: 1.25;
  color: #fff;
}

.answer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5vh 2vw;
  width: min(92vw, 1600px);
}

.answer {
  display: flex;
  align-items: center;
  padding: 2vh 2vw;
  font-size: clamp(18px, 2.8vh, 40px);
  font-weight: 600;
  background: var(--bg-card);
  border: 0.4vh solid transparent;
  border-radius: 1.4vh;
  color: #fff;
  cursor: pointer;
  min-height: 9vh;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s, background 0.15s;
  line-height: 1.2;
}
.answer:hover {
  border-color: var(--focus);
  background: rgba(40, 30, 100, 0.95);
  transform: scale(1.03);
  box-shadow: 0 0 2.8vh var(--gold-glow);
}
.answer.focused {
  border-color: var(--focus);
  transform: scale(1.03);
  box-shadow: 0 0 2.8vh var(--gold-glow);
  background: rgba(40, 30, 100, 0.95);
}
.answer.correct {
  background: rgba(46, 204, 113, 0.35);
  border-color: var(--green);
  animation: correctPulse 0.5s ease;
}
.answer.wrong {
  background: rgba(231, 76, 60, 0.35);
  border-color: var(--red);
  animation: wrongShake 0.5s ease;
}

@keyframes correctPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.06); box-shadow: 0 0 4vh var(--green); }
  100% { transform: scale(1.03); }
}
@keyframes wrongShake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-1vw); }
  40% { transform: translateX(1vw); }
  60% { transform: translateX(-0.6vw); }
  80% { transform: translateX(0.6vw); }
}

/* ============ Win/Lose screens ============ */

#screen-win-main .title,
#screen-supergame-win .title { color: var(--gold); }
#screen-lose .title, #screen-supergame-lose .title { color: var(--gold-glow); }

.prize { font-size: clamp(80px, 22vh, 280px); margin: 1vh 0; animation: pulse 1.5s ease-in-out infinite; line-height: 1; }

/* ============ Supergame ============ */

.word-display {
  display: flex;
  justify-content: center;
  gap: 1vw;
  margin: 2vh 0;
  flex-wrap: wrap;
  max-width: 92vw;
}
.word-display .letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(38px, 6vw, 96px);
  height: clamp(48px, 8vw, 120px);
  font-size: clamp(28px, 5vw, 72px);
  font-weight: 800;
  color: var(--gold);
  background: var(--bg-card);
  border: 0.3vh solid var(--gold-deep);
  border-bottom: 0.6vh solid var(--gold-deep);
  border-radius: 1vh;
  text-transform: uppercase;
}
.word-display .letter.hidden { color: transparent; }
.word-display .letter.revealed { background: rgba(255, 210, 74, 0.2); }

.big-timer {
  font-size: clamp(80px, 18vh, 220px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  text-shadow: 0 0 3vh var(--gold-glow);
  margin: 1vh 0;
  line-height: 1;
}
.big-timer.warning { color: var(--red); animation: pulse 0.5s infinite; }

.input-row {
  display: flex;
  gap: 1vw;
  align-items: center;
  margin-top: 1vh;
  max-width: 92vw;
}
.word-input {
  font-size: clamp(24px, 4vh, 56px);
  padding: 1.2vh 2vw;
  width: min(70vw, 900px);
  text-align: center;
  background: var(--bg-card);
  border: 0.4vh solid var(--gold-deep);
  border-radius: 1.4vh;
  color: var(--gold);
  outline: none;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.2em;
}
.word-input:focus { border-color: var(--focus); box-shadow: 0 0 3vh var(--gold); }

/* on-screen keyboard */
.keyboard {
  display: flex;
  flex-direction: column;
  gap: 0.6vh;
  margin-top: 1.5vh;
  align-items: center;
  max-width: 96vw;
}
.keyboard .row { display: flex; gap: 0.5vw; flex-wrap: nowrap; }
.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: clamp(36px, 4.8vw, 72px);
  height: clamp(40px, 6vh, 80px);
  padding: 0 0.8vw;
  font-size: clamp(16px, 2.6vh, 36px);
  font-weight: 700;
  color: #fff;
  background: rgba(40, 30, 100, 0.7);
  border: 0.25vh solid transparent;
  border-radius: 0.8vh;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s, background 0.1s, box-shadow 0.1s;
}
.key:hover {
  border-color: var(--focus);
  background: rgba(255, 210, 74, 0.25);
  transform: scale(1.04);
  box-shadow: 0 0 1.4vh var(--gold-glow);
}
.key.wide { min-width: clamp(70px, 10vw, 160px); }
.key.focused {
  border-color: var(--focus);
  background: rgba(255, 210, 74, 0.3);
  transform: scale(1.06);
  box-shadow: 0 0 1.6vh var(--gold-glow);
}

.row-buttons {
  display: flex;
  gap: 2vw;
  margin-top: 2vh;
  flex-wrap: wrap;
  justify-content: center;
}

/* ============ Confetti ============ */

.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 9999;
}
.confetti .piece {
  position: absolute;
  width: clamp(6px, 0.7vw, 14px);
  height: clamp(10px, 1.1vw, 22px);
  top: -3vh;
  opacity: 0.95;
  animation: fall linear forwards;
}
@keyframes fall {
  0%   { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(115vh) rotate(720deg); }
}

/* ============ Misc ============ */

.muted { color: rgba(255,255,255,0.7); font-size: clamp(16px, 2.4vh, 32px); margin-top: 1.5vh; }
.tip   { font-size: clamp(14px, 2.2vh, 30px); color: rgba(255,255,255,0.55); margin-top: 2vh; }

.question-label {
  font-size: clamp(20px, 3.4vh, 48px);
  font-weight: 600;
  color: var(--gold-glow);
  text-align: center;
  margin: 1vh 0 0.5vh;
  max-width: 90vw;
  line-height: 1.25;
}
