/* quiznight — shared styles for player (bright) + host (dark stage).
   Answer colors + A/B/C/D letters are IDENTICAL across both UIs. */
:root {
  --a-color: #e8402c; /* A - red    */
  --b-color: #1f7ae0; /* B - blue   */
  --c-color: #f2b705; /* C - amber  */
  --d-color: #17b26a; /* D - green  */
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
body { overflow-x: hidden; }
.screen { display: none; }
.screen.active { display: flex; }
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* Answer-option shared look: colored, LABELLED (A/B/C/D + text). */
.opt {
  display: flex; align-items: center; gap: 0.75rem;
  border: none; border-radius: var(--radius);
  color: #fff; text-align: left; width: 100%;
  font-weight: 700; line-height: 1.2;
  transition: transform .08s ease, filter .12s ease, opacity .12s ease;
}
.opt:active { transform: scale(0.98); }
.opt .letter {
  flex: 0 0 auto;
  display: grid; place-items: center;
  background: rgba(0,0,0,0.22);
  border-radius: 10px;
  font-weight: 800;
}
.opt[data-i="0"] { background: var(--a-color); }
.opt[data-i="1"] { background: var(--b-color); }
.opt[data-i="2"] { background: var(--c-color); }
.opt[data-i="3"] { background: var(--d-color); }
.opt.dim { opacity: 0.35; }
.opt.correct { outline: 5px solid #fff; box-shadow: 0 0 0 4px rgba(23,178,106,0.6); }
.opt.chosen { outline: 5px solid #fff; }

/* Countdown bar */
.timer-wrap {
  width: 100%; height: 18px; border-radius: 999px;
  background: rgba(128,128,128,0.25); overflow: hidden;
}
.timer-bar { height: 100%; width: 100%; border-radius: 999px; background: var(--d-color); }
.timer-bar.warn { background: var(--c-color); }
.timer-bar.crit { background: var(--a-color); }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(1rem + var(--safe-b));
  transform: translateX(-50%);
  background: #222; color: #fff; padding: .7rem 1.1rem; border-radius: 12px;
  font-weight: 600; z-index: 50; max-width: 90vw; text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
}

/* ============ PLAYER (bright, thumb-friendly) ============ */
body.player {
  background: linear-gradient(160deg, #6a5cff 0%, #8e6bff 45%, #b06bff 100%);
  color: #14121f;
}
body.player #app {
  min-height: 100%; max-width: 560px; margin: 0 auto;
  padding: calc(1rem + var(--safe-t)) 1rem calc(1.25rem + var(--safe-b));
  display: flex; flex-direction: column;
}
body.player .screen.active { flex-direction: column; gap: 1rem; flex: 1; }
body.player .card {
  background: #fff; border-radius: 22px; padding: 1.25rem;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
body.player h1.brand { color: #fff; text-align: center; margin: .25rem 0 1rem; font-size: 1.6rem; }
body.player input {
  width: 100%; padding: 1rem; font-size: 1.25rem; border-radius: 14px;
  border: 2px solid #ddd; margin-top: .35rem; text-align: center; font-weight: 700;
}
body.player input#code { text-transform: uppercase; letter-spacing: .3em; }
body.player label { font-weight: 700; font-size: .95rem; color: #555; }
body.player .btn-primary {
  width: 100%; padding: 1.15rem; font-size: 1.25rem; font-weight: 800;
  color: #fff; background: #14121f; border: none; border-radius: 16px; margin-top: 1rem;
}
body.player .btn-primary:disabled { opacity: .5; }
body.player .q-text { font-size: 1.5rem; font-weight: 800; margin: 0 0 1rem; }
body.player .opts { display: grid; gap: .8rem; }
body.player .opt { padding: 1.15rem 1rem; font-size: 1.25rem; min-height: 68px; }
body.player .opt .letter { width: 38px; height: 38px; font-size: 1.15rem; }
body.player .big-emoji { font-size: 4rem; text-align: center; }
body.player .result-big { text-align: center; }
body.player .result-big .headline { font-size: 2.2rem; font-weight: 900; margin: .5rem 0; }
body.player .result-big .points { font-size: 3.4rem; font-weight: 900; }
body.player .lb-row {
  display: flex; align-items: center; gap: .6rem; padding: .7rem .8rem;
  border-radius: 12px; background: #f2f0ff; margin-bottom: .5rem; font-weight: 700;
}
body.player .lb-row.me { background: #14121f; color: #fff; }
body.player .lb-row .rank { font-size: 1.3rem; width: 2.2rem; }
body.player .lb-row .nm { flex: 1; }
body.player .muted { color: #666; text-align: center; }
body.player .waiting-dots { text-align: center; font-size: 1.2rem; font-weight: 700; }

/* ============ HOST (dark stage, TV / screen-share legible) ============ */
body.host {
  background: radial-gradient(1200px 800px at 50% -10%, #241d4a 0%, #0d0b1a 60%, #060510 100%);
  color: #fff;
}
body.host #stage {
  min-height: 100%; max-width: 1400px; margin: 0 auto;
  padding: 2vh 3vw; display: flex; flex-direction: column;
}
body.host .screen.active { flex-direction: column; flex: 1; }
body.host h1 { font-size: 2.2rem; margin: 0; }
body.host .code-huge {
  font-size: clamp(4rem, 18vw, 12rem); font-weight: 900; letter-spacing: .06em;
  line-height: 1; text-align: center; color: #fff;
  text-shadow: 0 0 40px rgba(140,110,255,.7);
}
body.host .join-url { font-size: clamp(1.2rem, 3vw, 2rem); text-align: center; opacity: .85; }
body.host .players-strip { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; margin-top: 1.5rem; }
body.host .chip {
  background: rgba(255,255,255,.1); border-radius: 999px; padding: .5rem 1.1rem;
  font-size: 1.3rem; font-weight: 700;
}
body.host .chip.off { opacity: .4; }
body.host .q-text { font-size: clamp(1.8rem, 4.5vw, 4rem); font-weight: 900; margin: 0 0 2vh; text-align: center; }
body.host .opts { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
body.host .opts.single { grid-template-columns: 1fr; }
body.host .opt { padding: 1.6rem; font-size: clamp(1.3rem, 3vw, 2.4rem); min-height: 12vh; }
body.host .opt .letter { width: 3.4rem; height: 3.4rem; font-size: 1.8rem; }
body.host .media-box {
  max-height: 34vh; display: grid; place-items: center; margin-bottom: 2vh;
}
body.host .media-box img { max-height: 34vh; max-width: 100%; border-radius: 14px; }
body.host .media-placeholder {
  border: 3px dashed rgba(255,255,255,.3); border-radius: 14px; padding: 2rem 3rem;
  font-size: 1.4rem; opacity: .8; text-align: center;
}
body.host .topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2vh; }
body.host .answered-count { font-size: clamp(1.4rem, 3vw, 2.6rem); font-weight: 800; }
body.host .controls { display: flex; gap: 1rem; justify-content: center; margin-top: auto; padding-top: 2vh; }
body.host .btn {
  background: #fff; color: #14121f; border: none; border-radius: 14px;
  padding: 1rem 2.2rem; font-size: 1.4rem; font-weight: 800;
}
body.host .btn.ghost { background: rgba(255,255,255,.14); color: #fff; }
body.host .btn.danger { background: #e8402c; color: #fff; }
body.host .btn:disabled { opacity: .4; }
body.host .dist { margin-top: 1rem; display: grid; gap: .6rem; }
body.host .dist-row { display: flex; align-items: center; gap: 1rem; }
body.host .dist-row .lbl { width: 2.4rem; font-weight: 900; font-size: 1.6rem; text-align: center; border-radius: 8px; color:#fff; }
body.host .dist-bar-wrap { flex: 1; background: rgba(255,255,255,.1); border-radius: 8px; height: 2.4rem; overflow: hidden; }
body.host .dist-bar { height: 100%; border-radius: 8px; transition: width .5s ease; }
body.host .dist-row .n { width: 3rem; text-align: right; font-weight: 800; font-size: 1.4rem; }
body.host .lb { max-width: 900px; margin: 0 auto; width: 100%; }
body.host .lb-row {
  display: flex; align-items: center; gap: 1.2rem; padding: 1.1rem 1.4rem;
  border-radius: 14px; background: rgba(255,255,255,.08); margin-bottom: .8rem;
  font-size: clamp(1.3rem, 3vw, 2rem); font-weight: 800;
}
body.host .lb-row .rank { width: 3rem; }
body.host .lb-row .nm { flex: 1; }
body.host .lb-row.top1 { background: linear-gradient(90deg, #f2b705, #f2900d); color: #14121f; }
body.host .winner { text-align: center; }
body.host .winner .crown { font-size: clamp(4rem, 14vw, 9rem); }
body.host .winner .name { font-size: clamp(2.5rem, 8vw, 6rem); font-weight: 900; }
body.host .footer-howto { text-align: center; opacity: .7; margin-top: 1.5rem; font-size: 1.1rem; }
body.host .timer-wrap { height: 26px; }

/* pause / closed overlay (both) */
.overlay {
  position: fixed; inset: 0; background: rgba(6,5,16,.88); color: #fff;
  display: none; place-items: center; text-align: center; z-index: 40; padding: 2rem;
}
.overlay.active { display: grid; }
.overlay h2 { font-size: clamp(1.8rem, 6vw, 3.5rem); margin: 0 0 1rem; }
