/* TV: a fixed 1920×1080 stage scaled to fit the viewport (see tv.js). */
html, body.tv { width: 100%; height: 100%; overflow: hidden; background: #2a0d0e; }
#viewport { position: fixed; inset: 0; overflow: hidden; }
#stage {
  position: absolute; top: 50%; left: 50%;
  width: 1920px; height: 1080px;
  transform-origin: center center;
  transform: translate(-50%, -50%);
  background:
    radial-gradient(circle at 12% 88%, rgba(255, 89, 0, .10) 0 180px, transparent 181px),
    radial-gradient(circle at 92% 30%, rgba(255, 89, 0, .08) 0 240px, transparent 241px),
    var(--cream);
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* ── Brand header ── */
.brandbar {
  height: 120px; flex: none;
  display: flex; align-items: center; gap: 40px;
  padding: 0 56px;
  background: var(--orange);
  color: var(--white);
  border-radius: 0 0 40px 40px;
  box-shadow: 0 10px 30px rgba(255, 89, 0, .35);
  position: relative; z-index: 3;
}
.brandbar .wordmark { font-size: 76px; }
.brand-title { font-size: 50px; font-weight: 900; flex: 1; }
.room-pill {
  font-size: 34px; font-weight: 700;
  background: rgba(255, 255, 255, .18); border-radius: 999px; padding: 10px 30px;
}
.room-pill b { font-weight: 900; letter-spacing: .12em; margin-inline-start: 10px; }

#views { flex: 1; position: relative; min-height: 0; }
.view {
  position: absolute; inset: 0;
  padding: 36px 56px 24px;
  opacity: 0; pointer-events: none; transform: translateY(30px);
  transition: opacity .45s ease, transform .45s ease;
}
.view.active { opacity: 1; pointer-events: auto; transform: none; }

/* ── Lobby ── */
#view-lobby { display: flex; gap: 48px; }
.qr-card {
  width: 700px; flex: none;
  background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 36px; gap: 22px;
  border: 8px solid var(--orange);
}
.qr-card h2 { margin: 0; font-size: 72px; font-weight: 900; color: var(--orange); line-height: 1.1; }
.qr { background: #fff; padding: 18px; border-radius: 24px; line-height: 0; }
.qr img, .qr canvas { display: block; }
.qr-fallback { font-size: 26px; line-height: 1.5; max-width: 400px; text-align: center; }
.join-url { font-size: 26px; font-weight: 700; color: var(--brown-2); word-break: break-all; text-align: center; font-family: ui-monospace, Menlo, monospace; }

.lobby-side { flex: 1; display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.code-card {
  background: var(--brown); color: var(--white); border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: space-between; padding: 18px 44px;
  box-shadow: var(--shadow-lg);
}
.code-card .label { font-size: 44px; font-weight: 800; }
.code-card .code { font-size: 140px; font-weight: 900; letter-spacing: .14em; line-height: 1; color: var(--orange); font-family: 'Arial Black', system-ui, sans-serif; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; gap: 18px; }
.steps li {
  flex: 1; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  font-size: 30px; font-weight: 700; padding: 18px 22px; display: flex; align-items: center; gap: 14px; line-height: 1.3;
}
.steps .n {
  flex: none; width: 54px; height: 54px; border-radius: 50%; background: var(--orange); color: #fff;
  display: grid; place-items: center; font-weight: 900; font-size: 32px;
}
.players-head { display: flex; align-items: baseline; justify-content: space-between; }
.players-head h3 { margin: 0; font-size: 46px; font-weight: 900; }
.players-head .count { font-size: 36px; font-weight: 700; }
.players-head .count b { color: var(--orange); font-size: 52px; }
.chips { display: flex; flex-wrap: wrap; gap: 14px; align-content: flex-start; flex: 1; overflow: hidden; min-height: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 12px;
  background: var(--white); border-radius: 999px; padding: 10px 26px 10px 14px;
  font-size: 36px; font-weight: 800; box-shadow: var(--shadow);
  border: 3px solid transparent;
}
.chip.new { animation: popIn .5s cubic-bezier(.2, 1.4, .4, 1) both; border-color: var(--orange); }
.chip .av {
  width: 50px; height: 50px; border-radius: 50%; background: var(--orange); color: #fff;
  display: grid; place-items: center; font-size: 26px; font-weight: 900;
}
.chip.off { opacity: .45; }
.chips.many .chip { font-size: 28px; padding: 6px 20px 6px 10px; }
.chips.many .chip .av { width: 40px; height: 40px; font-size: 22px; }
.empty-hint { font-size: 34px; color: var(--brown-2); font-weight: 600; animation: blink 2s infinite; }
.btn-start { font-size: 54px; padding: 22px 60px; align-self: flex-start; }

/* ── Game ── */
#view-game { display: flex; gap: 40px; }
.game-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.turn-label { font-size: 38px; font-weight: 700; color: var(--brown-2); }
.active-name {
  font-size: 128px; font-weight: 900; line-height: 1.2; color: var(--orange);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 6px 0 rgba(65, 21, 23, .08);
}
.active-name.swap { animation: slideUp .5s ease both; }
.game-row { flex: 1; display: flex; align-items: center; gap: 40px; min-height: 0; }
.card-info {
  flex: 1; background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 30px 40px; display: flex; flex-direction: column; gap: 16px; align-items: flex-start; min-width: 0;
  border-top: 14px solid var(--orange);
}
.card-info.swap { animation: cardSwap .5s ease both; }
.card-info .cat-chip { font-size: 54px; padding: 10px 36px 10px 28px; white-space: nowrap; }
.card-num { font-size: 48px; font-weight: 800; }
.card-num b { color: var(--orange); font-size: 68px; }
.status-pill {
  font-size: 40px; font-weight: 800; padding: 8px 32px; border-radius: 999px;
  background: var(--green); color: #fff;
}
.status-pill[data-s="paused"] { background: var(--amber); }
.status-pill[data-s="timeup"] { background: var(--red); }
.guess-hint { font-size: 30px; font-weight: 600; color: var(--brown-2); }
.next-up { font-size: 32px; font-weight: 700; color: var(--brown-2); }
.next-up b { color: var(--brown); }

.timer-wrap { position: relative; width: 480px; height: 480px; flex: none; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: var(--white); stroke: var(--cream-2); stroke-width: 18; }
.ring-fg {
  fill: none; stroke: var(--orange); stroke-width: 18; stroke-linecap: round;
  stroke-dasharray: 552.92; stroke-dashoffset: 0;
  transition: stroke-dashoffset .2s linear, stroke .3s ease;
}
.timer-num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 200px; font-weight: 900; line-height: 1; color: var(--brown);
  font-family: 'Arial Black', system-ui, sans-serif; padding-bottom: 40px;
}
.timer-unit { position: absolute; bottom: 100px; left: 0; right: 0; text-align: center; font-size: 36px; font-weight: 700; color: var(--brown-2); }
body[data-status="paused"] .timer-num { color: var(--amber); animation: blink 1.4s infinite; }

/* danger ≤10s */
#stage.danger .ring-fg { stroke: var(--red); }
#stage.danger .timer-num { color: var(--red); animation: pulse 1s infinite; }
#edge-glow { position: absolute; inset: 0; pointer-events: none; z-index: 5; opacity: 0; transition: opacity .3s; }
#stage.danger #edge-glow {
  opacity: 1;
  animation: edgePulse 1s ease-in-out infinite;
}
@keyframes edgePulse {
  0%, 100% { box-shadow: inset 0 0 60px 20px rgba(255, 89, 0, .55); }
  50% { box-shadow: inset 0 0 140px 50px rgba(214, 43, 31, .85); }
}

.scoreboard {
  width: 460px; flex: none; background: var(--brown); color: var(--white);
  border-radius: var(--radius-lg); padding: 30px 28px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; min-height: 0;
}
.scoreboard h3 { margin: 0 0 18px; font-size: 44px; font-weight: 900; }
.scoreboard ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; overflow: hidden; }
.scoreboard li {
  display: flex; align-items: center; gap: 16px;
  background: rgba(255, 255, 255, .08); border-radius: 20px; padding: 12px 20px;
  font-size: 36px; font-weight: 800; transition: background .3s, transform .3s;
}
.scoreboard li .rk { width: 48px; text-align: center; color: rgba(255, 255, 255, .6); }
.scoreboard li .nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scoreboard li .sc { font-size: 44px; font-weight: 900; color: var(--orange); min-width: 60px; text-align: center; }
.scoreboard li.active { background: var(--orange); transform: scale(1.03); }
.scoreboard li.active .sc, .scoreboard li.active .rk { color: #fff; }
.scoreboard li.off { opacity: .45; }
.scoreboard li .tag { font-size: 20px; font-weight: 600; opacity: .8; }
.scoreboard ol.many li { font-size: 26px; padding: 6px 16px; }
.scoreboard ol.many li .sc { font-size: 30px; }
.scoreboard li.bump .sc { animation: popIn .5s ease; }

/* ── Time up overlay ── */
.timeup-overlay {
  position: absolute; inset: 0; z-index: 6;
  background: rgba(214, 43, 31, .92);
  display: grid; place-items: center; color: #fff;
  animation: slideUp .35s ease both;
  cursor: pointer;
}
.timeup-box { text-align: center; }
.timeup-icon { font-size: 180px; line-height: 1; animation: pulse 1s infinite; }
.timeup-text { font-size: 220px; font-weight: 900; line-height: 1.2; }
.timeup-sub { font-size: 48px; font-weight: 700; opacity: .95; }

/* ── End screen ── */
#view-end { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.end-title { margin: 0; font-size: 84px; font-weight: 900; color: var(--orange); }
.podium { display: flex; align-items: flex-end; gap: 36px; height: 520px; }
.pod { width: 380px; display: flex; flex-direction: column; align-items: center; gap: 12px; animation: slideUp .6s ease both; }
.pod .medal { font-size: 96px; line-height: 1; }
.pod .pname { font-size: 48px; font-weight: 900; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pod .pscore { font-size: 36px; font-weight: 800; color: var(--brown-2); }
.pod .block {
  width: 100%; border-radius: 28px 28px 0 0; background: var(--orange); color: #fff;
  display: grid; place-items: center; font-size: 110px; font-weight: 900; box-shadow: var(--shadow-lg);
}
.pod.p1 .block { height: 300px; }
.pod.p2 .block { height: 210px; background: var(--brown-2); }
.pod.p3 .block { height: 150px; background: var(--brown); }
.pod.p1 { animation-delay: .3s; }
.rest { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; max-width: 1700px; }
.rest li { background: var(--white); border-radius: 999px; padding: 10px 28px; font-size: 32px; font-weight: 800; box-shadow: var(--shadow); }
.rest li b { color: var(--orange); }
.end-thanks { font-size: 40px; font-weight: 800; color: var(--brown-2); margin-top: auto; }

/* ── Control bar ── */
.controlbar {
  height: 132px; flex: none; z-index: 8;
  display: flex; align-items: center; gap: 20px;
  padding: 0 40px;
  background: var(--white);
  border-radius: 40px 40px 0 0;
  box-shadow: 0 -10px 30px rgba(65, 21, 23, .10);
}
.controls { flex: 1; display: flex; gap: 14px; min-width: 0; }
.controls .btn { font-size: 28px; padding: 14px 12px; line-height: 1.2; flex: 1 1 0; min-width: 0; min-height: 92px; }
.controls .btn-success { flex-grow: 1.4; font-size: 38px; }
body[data-status="lobby"] .controls { visibility: hidden; }
body[data-status="finished"] .controls .btn:not([data-action="restart"]) { display: none; }
body[data-status="finished"] .controls { justify-content: center; }
body[data-status="finished"] .controls .btn[data-action="restart"] { flex: 0 0 auto; padding-inline: 60px; font-size: 38px; }
.btn-small { font-size: 22px; padding: 14px 22px; box-shadow: inset 0 0 0 2px var(--cream-2); flex: none; }

/* ── Modals ── */
.modal {
  position: absolute; inset: 0; z-index: 20; background: rgba(42, 13, 14, .7);
  display: grid; place-items: center;
}
.modal-box {
  background: var(--cream); border-radius: var(--radius-lg); padding: 44px 56px; box-shadow: var(--shadow-lg);
  max-width: 1100px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 18px;
  animation: slideUp .3s ease both;
}
.modal-box h2 { margin: 0; font-size: 56px; font-weight: 900; }
.modal-box p { margin: 0; font-size: 32px; font-weight: 600; }
.modal-box .warn { color: var(--red); font-weight: 800; }
.modal-actions { display: flex; gap: 20px; margin-top: 10px; }
.modal-actions .btn { font-size: 34px; padding: 18px 48px; }

.audio-hint {
  position: absolute; left: 40px; bottom: 156px; z-index: 9;
  font-family: inherit; font-size: 26px; font-weight: 800;
  border: 0; border-radius: 999px; padding: 14px 26px;
  background: var(--brown); color: #fff; cursor: pointer; box-shadow: var(--shadow-lg);
  animation: pulse 2s infinite;
}

/* Noto Sans Arabic has tall default line boxes — keep game layout compact */
.turn-label, .card-info > * { line-height: 1.3; }
.card-num, .card-num b { line-height: 1.15; }
.status-pill { line-height: 1.4; }
