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

:root {
  --bg1: #0f2557; --bg2: #274b9f;
  --ink: #1b2340; --panel: #ffffff;
  --gold: #ffc53d; --gold-dark: #b97e0e;
  --good: #22c55e; --bad: #ef4444;
  --radius: 18px;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background: linear-gradient(160deg, var(--bg1), #173a7d 55%, var(--bg2));
  min-height: 100vh;
  color: var(--ink);
  padding: 20px 14px 40px;
}

.hidden { display: none !important; }
.screen { max-width: 1100px; margin: 0 auto; }

/* ---------- setup ---------- */
.hero { text-align: center; color: #fff; margin: 10px 0 24px; }
.hero h1 { font-size: clamp(2.4rem, 6vw, 4rem); letter-spacing: 1px; text-shadow: 0 4px 0 rgba(0,0,0,.3); }
.tagline { opacity: .92; font-size: 1.05rem; margin-top: 6px; }

.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 820px) { .setup-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--panel); border-radius: var(--radius);
  padding: 22px; box-shadow: 0 12px 30px rgba(0,0,0,.35);
}
.card h2 { font-size: 1.3rem; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.step {
  background: var(--gold); color: #231900; width: 30px; height: 30px;
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 800; flex: none;
}

.dropzone {
  border: 3px dashed #a8bce8; border-radius: 14px; padding: 22px 14px;
  text-align: center; background: #f2f6ff; transition: .15s;
}
.dropzone.drag { border-color: var(--gold); background: #fff7e0; }
.dz-big { font-weight: 700; font-size: 1.05rem; }
.dz-small { color: #777; margin: 8px 0; }

.gsheet-row { display: flex; gap: 8px; margin-top: 14px; }
.gsheet-row input {
  flex: 1; padding: 11px 12px; border: 2px solid #ddd; border-radius: 10px; font-size: .95rem; min-width: 0;
}
.row-between { display: flex; justify-content: space-between; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.status { margin-top: 12px; font-size: .95rem; min-height: 1.2em; }
.status.ok { color: #15803d; font-weight: 600; }
.status.err { color: #b91c1c; font-weight: 600; }

.help { margin-top: 14px; font-size: .9rem; color: #444; }
.help summary { cursor: pointer; font-weight: 600; color: #173a7d; }
.help p { margin: 8px 0; line-height: 1.45; }
.fmt { border-collapse: collapse; margin: 8px 0; font-size: .82rem; }
.fmt th, .fmt td { border: 1px solid #ccc; padding: 4px 7px; text-align: left; }
.fmt th { background: #eef2ff; }

.lbl { display: block; font-weight: 700; margin: 16px 0 8px; }
.lbl:first-of-type { margin-top: 0; }
.team-name-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.team-dot { width: 16px; height: 16px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px rgba(0,0,0,.12); }
.team-name-row input {
  flex: 1; padding: 11px 12px; border: 2px solid #ddd; border-radius: 10px; font-size: 1rem; min-width: 0;
}
.seg { display: inline-flex; background: #e8edfb; border-radius: 999px; padding: 4px; gap: 4px; }
.seg button {
  border: 0; background: transparent; padding: 8px 18px; border-radius: 999px;
  font-size: 1rem; font-weight: 700; cursor: pointer; color: var(--ink);
}
.seg button.on { background: #173a7d; color: #fff; }
.board-info { margin-top: 10px; color: #555; font-size: .95rem; }
.check-row { display: flex; gap: 10px; align-items: flex-start; margin-top: 18px; cursor: pointer; font-size: .98rem; line-height: 1.4; }
.check-row input { width: 20px; height: 20px; margin-top: 2px; accent-color: #173a7d; flex: none; }
.more-games { margin-top: 16px; font-size: .92rem; color: #555; }
.more-games a { color: #173a7d; font-weight: 700; }

/* ---------- buttons ---------- */
.btn {
  border: 2px solid #c9d4f2; background: #fff; color: var(--ink);
  padding: 10px 18px; border-radius: 999px; font-size: 1rem; font-weight: 700;
  cursor: pointer; transition: .15s;
}
.btn:hover { border-color: var(--gold); transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: #173a7d; border-color: #173a7d; color: #fff; }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,.0); color: #33508f; }
#gameScreen .btn-ghost, #drawScreen .btn-ghost { color: #dbe6ff; border-color: rgba(255,255,255,.35); }
.btn-start { width: 100%; margin-top: 12px; background: var(--gold); border-color: var(--gold-dark); color: #231900; font-size: 1.1rem; padding: 14px; }
.btn-start:hover { border-color: #fff; }

/* ---------- coin toss ---------- */
.draw-wrap { max-width: 640px; margin: 0 auto; text-align: center; color: #fff; }
.coin-scene { perspective: 900px; display: flex; justify-content: center; margin: 26px 0 12px; }
.coin {
  position: relative; width: 190px; height: 190px;
  transform-style: preserve-3d;
  transition: transform 2.4s cubic-bezier(.12,.8,.24,1);
}
.coin-face {
  position: absolute; inset: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  padding: 18px; text-align: center; overflow: hidden; overflow-wrap: anywhere;
  font-weight: 800; font-size: 1.25rem; color: #fff;
  border: 6px solid rgba(255,255,255,.75);
  box-shadow: inset 0 0 0 4px rgba(0,0,0,.18), 0 14px 30px rgba(0,0,0,.35);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.coin-back { transform: rotateY(180deg); }
.draw-vs { font-size: 1.2rem; font-weight: 800; margin-bottom: 16px; text-shadow: 0 2px 0 rgba(0,0,0,.3); }
.draw-vs span { background: rgba(255,255,255,.92); padding: 2px 12px; border-radius: 999px; }
.draw-result { font-size: clamp(1.5rem, 4.5vw, 2.3rem); font-weight: 900; min-height: 1.4em; margin: 20px 0 6px; color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.3); }
.draw-winner-pill { color: #fff; padding: 2px 16px; border-radius: 999px; white-space: nowrap; }
.draw-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.draw-wrap .btn-start { width: auto; padding: 14px 34px; }

/* ---------- game ---------- */
.topbar { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.tbtn { padding: 7px 14px; font-size: .9rem; }

.scoreboard { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: stretch; margin-bottom: 14px; }
.team-card {
  background: #fff; border-radius: 14px; padding: 12px 16px; text-align: center;
  border-top: 6px solid #999; box-shadow: 0 8px 20px rgba(0,0,0,.3); position: relative;
}
.team-card.active { outline: 4px solid var(--gold); }
.team-card .tname { font-weight: 800; font-size: 1.15rem; overflow-wrap: anywhere; }
.team-card .tscore { font-size: 2rem; font-weight: 900; line-height: 1.1; }
.turn-tag {
  position: absolute; top: -11px; left: 50%; transform: translateX(-50%);
  background: var(--gold); color: #231900; font-size: .68rem; font-weight: 900;
  padding: 2px 10px; border-radius: 999px; letter-spacing: .06em; white-space: nowrap;
}
.vs-badge {
  align-self: center; background: rgba(255,255,255,.14); color: #fff; font-weight: 900;
  border: 2px solid rgba(255,255,255,.4); border-radius: 50%; width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center; font-size: .95rem;
}

.round-head { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.round-label { color: #fff; font-weight: 800; font-size: 1.05rem; letter-spacing: .04em; }
.mult-badge { background: var(--bad); color: #fff; font-weight: 900; padding: 3px 12px; border-radius: 999px; font-size: .85rem; }
.pot-box { background: #071633; color: #ffe9a8; border: 2px solid var(--gold); border-radius: 10px; padding: 5px 14px; font-weight: 800; letter-spacing: .05em; }
.pot-box strong { color: var(--gold); font-size: 1.15rem; }

.question-text {
  text-align: center; color: #fff; font-weight: 900;
  font-size: clamp(1.4rem, 3.6vw, 2.2rem); margin: 10px 0 6px; text-shadow: 0 3px 0 rgba(0,0,0,.3);
}
.control-banner { text-align: center; color: #ffe9a8; font-size: 1.1rem; font-weight: 700; min-height: 1.4em; margin-bottom: 12px; }
.control-banner.steal { color: #ffb3b3; }

.board { display: flex; flex-direction: column; gap: 8px; max-width: 760px; margin: 0 auto; }
.answer-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: linear-gradient(180deg, #1d3f83, #122c5e);
  border: 2px solid #3f66b3; border-radius: 12px; padding: 10px 14px;
  color: #fff; font-size: 1.15rem; font-weight: 800; text-align: left; cursor: pointer;
  min-height: 56px;
}
.answer-row .rank {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: #0a1a3d; border: 2px solid var(--gold); color: var(--gold);
  display: flex; align-items: center; justify-content: center; font-size: 1rem; font-weight: 900;
}
.answer-row .atext { flex: 1; letter-spacing: .14em; opacity: .55; }
.answer-row.revealed { background: linear-gradient(180deg, #fdfdfd, #dfe8ff); color: var(--ink); border-color: var(--gold); cursor: default; animation: flipIn .45s ease; }
.answer-row.revealed .atext { letter-spacing: normal; opacity: 1; }
.answer-row.revealed .rank { background: var(--gold); color: #231900; border-color: var(--gold-dark); }
.answer-row .apoints {
  flex: none; background: var(--gold); color: #231900; font-weight: 900;
  border-radius: 8px; padding: 4px 12px; font-size: 1.05rem; min-width: 52px; text-align: center;
}
@keyframes flipIn { from { transform: rotateX(90deg); opacity: 0; } to { transform: rotateX(0); opacity: 1; } }

.strike-box { display: flex; gap: 10px; justify-content: center; margin: 16px 0 6px; }
.strike-slot {
  width: 46px; height: 46px; border-radius: 10px; border: 3px solid rgba(255,255,255,.35);
  color: rgba(255,255,255,.18); font-size: 1.7rem; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
}
.strike-slot.on { background: var(--bad); border-color: #ffb3b3; color: #fff; box-shadow: 0 0 18px rgba(239,68,68,.8); }

.guess-row { display: flex; gap: 8px; max-width: 760px; margin: 10px auto 0; }
.guess-row input {
  flex: 1; padding: 13px 14px; border: 2px solid #3f66b3; border-radius: 10px;
  font-size: 1.1rem; min-width: 0; background: #fff;
}
.guess-row .btn { padding: 13px 26px; font-size: 1.05rem; }
.feedback { text-align: center; min-height: 1.5em; margin-top: 10px; font-size: 1.1rem; font-weight: 800; color: #fff; }
.feedback.good { color: #8bf0a4; }
.feedback.bad { color: #ffb3b3; }
.hint { text-align: center; color: rgba(255,255,255,.65); font-size: .85rem; margin-top: 6px; }
.game-controls { display: flex; justify-content: center; margin-top: 16px; }

.strike-overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(120, 0, 0, .45); z-index: 60; pointer-events: none;
}
.strike-overlay span {
  font-size: clamp(10rem, 40vw, 22rem); color: var(--bad); font-weight: 900;
  text-shadow: 0 0 60px rgba(239,68,68,.9); animation: strikePop .8s ease;
}
@keyframes strikePop { 0% { transform: scale(.3); opacity: 0; } 25% { transform: scale(1.15); opacity: 1; } 45% { transform: scale(1); } 100% { transform: scale(1); opacity: 1; } }

/* ---------- modals ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(4, 10, 30, .72);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal-box {
  background: #fff; border-radius: var(--radius); padding: 28px; max-width: 560px; width: 100%;
  box-shadow: 0 24px 60px rgba(0,0,0,.5); text-align: center; max-height: 90vh; overflow-y: auto;
}
.modal-box h2 { font-size: 1.7rem; margin-bottom: 10px; }
.modal-text { font-size: 1.08rem; line-height: 1.5; color: #333; margin-bottom: 12px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.modal-actions.center { justify-content: center; }
.standings { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.standings .srow {
  display: flex; justify-content: space-between; padding: 9px 14px; border-radius: 10px;
  background: #f2f6ff; font-weight: 800; border-left: 6px solid #999;
}
.winner-line { font-size: 1.3rem; font-weight: 900; margin-bottom: 8px; }

/* ---------- fast money ---------- */
.fm-card { max-width: 720px; margin: 0 auto; }
.fm-timerbar { height: 12px; background: #e8edfb; border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
#fmTimerFill { height: 100%; width: 100%; background: var(--good); border-radius: 999px; transition: width 1s linear, background .3s; }
.fm-progress { text-align: center; font-weight: 800; color: #555; letter-spacing: .05em; }
.fm-q { text-align: center; font-size: clamp(1.3rem, 3.4vw, 1.9rem); font-weight: 900; margin: 14px 0 18px; }
.fm-reveal-list { display: flex; flex-direction: column; gap: 8px; }
.fm-reveal-list .frow {
  display: flex; align-items: center; gap: 10px; background: #f2f6ff; border-radius: 10px; padding: 10px 14px;
}
.fm-reveal-list .fq { flex: 1; font-weight: 700; text-align: left; }
.fm-reveal-list .fa { font-weight: 800; }
.fm-reveal-list .fp {
  flex: none; background: var(--gold); color: #231900; font-weight: 900; border-radius: 8px;
  padding: 4px 12px; min-width: 52px; text-align: center;
}
.fm-reveal-list .frow.miss .fp { background: #f3c1c1; }
.fm-total { text-align: center; font-size: 1.3rem; font-weight: 900; margin-top: 14px; }

/* ---------- go overlay ---------- */
.go-overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(4, 10, 30, .55); z-index: 70; pointer-events: none;
}
.go-overlay span {
  font-size: clamp(3rem, 10vw, 6rem); font-weight: 900; color: #fff;
  text-shadow: 0 6px 0 rgba(0,0,0,.35); animation: goPop 1.2s ease;
}
@keyframes goPop { 0% { transform: scale(.4); opacity: 0; } 30% { transform: scale(1.1); opacity: 1; } 55% { transform: scale(1); } 100% { transform: scale(1); opacity: 1; } }

/* ---------- TV mode ---------- */
body.tv .screen { max-width: none; }
body.tv .question-text { font-size: clamp(2rem, 4.6vw, 3.2rem); }
body.tv .answer-row { font-size: 1.5rem; min-height: 68px; }
body.tv .team-card .tscore { font-size: 2.7rem; }
body.tv .coin { width: 260px; height: 260px; }
body.tv .coin-face { font-size: 1.7rem; }

@media (max-width: 640px) {
  .coin { width: 160px; height: 160px; }
  .coin-face { font-size: 1.05rem; }
  .scoreboard { gap: 8px; }
  .vs-badge { width: 40px; height: 40px; font-size: .8rem; }
  .team-card .tscore { font-size: 1.5rem; }
  .answer-row { font-size: 1rem; }
}
.fm-card .feedback { color: var(--ink); }
.fm-card .feedback.good { color: #15803d; }
.fm-card .feedback.bad { color: #b91c1c; }

/* ---------- question sets library ---------- */
.library { margin-top: 10px; }
.lib-row { display: flex; align-items: center; gap: 10px; background: #eef2ff; border-radius: 12px; padding: 9px 12px; margin-bottom: 7px; }
.lib-info { flex: 1; min-width: 0; }
.lib-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-meta { font-size: .8rem; color: #666; margin-top: 1px; }
.btn-small { padding: 6px 14px; font-size: .9rem; }
.lib-del { border: 1.5px solid #b91c1c; background: #fff; color: #b91c1c; font-weight: 700; font-size: .85rem; border-radius: 999px; cursor: pointer; padding: 5px 12px; }
.lib-del:hover { background: #b91c1c; color: #fff; }
.lib-hint { font-size: .82rem; color: #777; margin-top: 4px; line-height: 1.45; }
#libCount { opacity: .75; font-weight: 600; }
.team-card .tadjust { margin-top: 4px; }
.team-card .tadjust button {
  border: 0; background: #e8edfb; border-radius: 7px; width: 28px; height: 24px;
  font-weight: 900; cursor: pointer; color: #173a7d; margin: 0 2px; font-size: 1rem;
}
.team-card .tadjust button:hover { background: var(--gold); }
