:root {
  --bg: #201a33;
  --bg-rgb: 32, 26, 51;
  --bg-panel: #2b2447;
  --bg-panel-2: #362d59;
  --accent: #f2c94c;
  --accent-2: #7d6bd6;
  --text: #f3f1fa;
  --text-dim: #b9b2d6;
  --good: #4caf80;
  --bad: #e05c5c;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100%;
}

a { color: var(--accent); }

.hidden { display: none !important; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 600;
  background: var(--accent);
  color: #241f38;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
button:hover { opacity: 0.9; }
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

button.secondary {
  background: var(--bg-panel-2);
  color: var(--text);
}

button.danger {
  background: var(--bad);
  color: white;
}

input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 2px solid var(--bg-panel-2);
  background: var(--bg-panel);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }

.error-box {
  background: rgba(224, 92, 92, 0.15);
  border: 1px solid var(--bad);
  color: #ffb3b3;
  padding: 10px 14px;
  border-radius: 10px;
  margin: 10px 0;
}

.info-box {
  background: rgba(125, 107, 214, 0.15);
  border: 1px solid var(--accent-2);
  border-radius: 10px;
  padding: 20px 16px;
  margin: 10px 0;
  text-align: center;
}
.info-box-spinner {
  width: 30px;
  height: 30px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px solid var(--bg-panel-2);
  border-top-color: var(--accent-2);
  animation: info-spin 0.9s linear infinite;
}
@keyframes info-spin {
  to { transform: rotate(360deg); }
}

/* ---------- centered card layout (index/admin login) ---------- */
.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.card {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}

.card h1 {
  margin-top: 0;
  color: var(--accent);
  font-size: 28px;
}

.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; color: var(--text-dim); font-size: 14px; }

/* ---------- avatar ---------- */
.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
  color: white;
  flex-shrink: 0;
}

/* ---------- screen page ---------- */
body.screen-body { padding: 30px; }

.screen-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 20px;
}
.screen-header h1 { color: var(--accent); margin: 0; font-size: 32px; }
h1.app-title {
  font-size: 48px;
  color: var(--accent);
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent));
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: title-shimmer 7s ease-in-out infinite;
}
@keyframes title-shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
.round-badge {
  color: var(--accent-2);
  font-size: 16px;
  font-weight: 700;
}

.phase-badge {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 18px;
  font-weight: 700;
}
.phase-badge.phase-answering { background: rgba(242, 201, 76, 0.2); color: var(--accent); }
.phase-badge.phase-voting { background: rgba(76, 175, 128, 0.2); color: var(--good); }

.final-round-badge {
  background: linear-gradient(90deg, #e05c5c, #f2c94c);
  color: #241f38;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 18px;
  font-weight: 800;
  animation: final-round-pulse 1.2s ease-in-out infinite;
}
@keyframes final-round-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.news-hint-badge {
  background: rgba(125, 107, 214, 0.25);
  color: var(--accent-2);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 18px;
  font-weight: 700;
}

.back-to-game-btn {
  position: fixed;
  top: 16px;
  left: 16px;
  background: var(--bg-panel-2);
  color: var(--text);
  border: 1px solid var(--bg-panel-2);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  z-index: 20;
}
.back-to-game-btn:hover { color: var(--accent); border-color: var(--accent); }

.reset-corner-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--bg-panel-2);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  z-index: 10;
}
.reset-corner-btn:hover { color: var(--bad); border-color: var(--bad); }

.start-hero-btn {
  font-size: 32px;
  padding: 24px 64px;
  border-radius: 20px;
  box-shadow: 0 8px 30px rgba(242, 201, 76, 0.35);
  animation: start-btn-pulse 2s ease-in-out infinite;
}
@keyframes start-btn-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}
.start-hero-btn:disabled { animation: none; }

.admin-link-btn {
  display: inline-block;
  margin-top: 22px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 14px;
  border: 1px solid var(--bg-panel-2);
  border-radius: 20px;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.admin-link-btn:hover { color: var(--accent-2); border-color: var(--accent-2); }

.timer-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
}
.timer {
  font-size: 48px;
  font-weight: 800;
  color: var(--accent);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.timer-bar-track {
  width: 100%;
  max-width: 260px;
  height: 8px;
  border-radius: 6px;
  background: var(--bg-panel-2);
  overflow: hidden;
}
.timer-bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 6px;
  background: var(--accent);
  transition: width 0.25s linear;
}

/* Keep answer options from stretching edge-to-edge on the wide screen page -
   still long/readable, just not glued to the left/right margins. */
.screen-body .options-list {
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

.player-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  margin-top: 20px;
}
.player-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-panel);
  border-radius: 30px;
  padding: 8px 18px 8px 8px;
}
.player-chip.answered { border: 2px solid var(--good); }
.player-chip .name { font-weight: 600; }
.player-chip .score { color: var(--text-dim); font-size: 14px; }

.question-box {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  margin: 24px 0;
}
.question-box .question-text {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.3;
}
.question-box img { max-width: 100%; max-height: 320px; border-radius: 10px; margin-bottom: 20px; }

.options-list { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.option-row {
  background: var(--bg-panel-2);
  border-radius: 12px;
  padding: 18px 24px;
  font-size: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transform-origin: center;
  transition: transform 0.3s ease;
  position: relative;
  overflow: hidden;
}
.option-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: rgba(125, 107, 214, 0.35);
  transition: width 1.8s cubic-bezier(0.22, 0.61, 0.36, 1);
  z-index: 0;
}
.option-row.winner .option-fill { background: rgba(242, 201, 76, 0.4); }
.option-row .option-label,
.option-row .option-votes { position: relative; z-index: 1; }
.option-row.winner {
  outline: 3px solid var(--accent);
  background: rgba(242,201,76,0.15);
  animation: winner-option-grow 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
  position: relative;
  z-index: 2;
}
@keyframes winner-option-grow {
  0% { transform: scale(1); }
  60% { transform: scale(1.09); }
  100% { transform: scale(1.05); }
}
.option-row .option-votes { color: var(--accent); font-weight: 700; }
.option-row .option-author { color: var(--text-dim); font-size: 16px; margin-left: 10px; }

.final-table { width: 100%; border-collapse: collapse; font-size: 22px; margin-top: 20px; }
.final-table td, .final-table th { padding: 12px 18px; border-bottom: 1px solid var(--bg-panel-2); }
.final-table tr:first-child td { color: var(--accent); font-size: 28px; font-weight: 800; }

/* ---------- winner celebration ---------- */
.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 5;
}
.confetti-piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 16px;
  opacity: 0.9;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(540deg); opacity: 0.3; }
}

.final-heading {
  text-align: center;
  animation: final-heading-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes final-heading-in {
  0% { transform: scale(0.4); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.winner-trophy {
  display: inline-block;
  font-size: 1em;
  animation: trophy-bounce 1.4s ease-in-out infinite;
}
@keyframes trophy-bounce {
  0%, 100% { transform: translateY(0) rotate(-8deg); }
  50% { transform: translateY(-10px) rotate(8deg); }
}

.final-table tr:first-child {
  animation: winner-row-in 0.7s ease-out 0.15s both, winner-glow 1.8s ease-in-out 0.9s infinite;
  border-radius: 10px;
}
@keyframes winner-row-in {
  0% { transform: translateX(-30px); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}
@keyframes winner-glow {
  0%, 100% { text-shadow: 0 0 0 rgba(242,201,76,0); }
  50% { text-shadow: 0 0 16px rgba(242,201,76,0.8); }
}
.final-table tr:not(:first-child) {
  animation: row-fade-in 0.5s ease-out both;
}
.final-table tr:nth-child(2) { animation-delay: 0.35s; }
.final-table tr:nth-child(3) { animation-delay: 0.45s; }
.final-table tr:nth-child(4) { animation-delay: 0.55s; }
.final-table tr:nth-child(n+5) { animation-delay: 0.65s; }
@keyframes row-fade-in {
  0% { transform: translateY(10px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

.admin-mini {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 16px;
  width: 260px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.admin-mini h3 { margin: 0 0 10px 0; font-size: 15px; color: var(--text-dim); }
.admin-mini .row { display: flex; gap: 8px; margin-top: 8px; }
.admin-mini .row button { flex: 1; }

/* ---------- play page ---------- */
body.play-body {
  padding: 16px;
  max-width: 480px;
  margin: 0 auto;
}
.play-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.play-header .score-pill { background: var(--bg-panel-2); border-radius: 20px; padding: 6px 14px; font-weight: 700; }

.status-line { color: var(--text-dim); text-align: center; margin: 20px 0; }

.char-counter { text-align: right; color: var(--text-dim); font-size: 13px; margin-top: 4px; }

.vote-option {
  background: var(--bg-panel);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  font-size: 18px;
  cursor: pointer;
}
.vote-option:hover { border-color: var(--accent-2); }
.vote-option.selected { border-color: var(--accent); background: rgba(242,201,76,0.12); }

.result-me {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  margin: 16px 0;
}
.result-me .points { font-size: 40px; font-weight: 800; color: var(--accent); }

.double-points-banner {
  background: linear-gradient(90deg, #e05c5c, #f2c94c);
  color: #241f38;
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 18px;
  text-align: center;
  margin-bottom: 14px;
  animation: final-round-pulse 1.2s ease-in-out infinite;
}

.pair-hint {
  text-align: center;
  color: var(--text-dim);
  font-size: 15px;
  margin: 0 0 10px;
}

.double-points-tag {
  display: inline-block;
  background: var(--accent);
  color: #241f38;
  font-weight: 800;
  padding: 4px 14px;
  border-radius: 20px;
  margin: 6px 0;
  animation: double-tag-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes double-tag-pop {
  0% { transform: scale(0.3); opacity: 0; }
  70% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}

/* ---------- admin page ---------- */
.admin-wrap { max-width: 900px; margin: 0 auto; padding: 24px; }
.tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.tabs button { background: var(--bg-panel-2); color: var(--text); }
.tabs button.active { background: var(--accent); color: #241f38; }

.item-row {
  background: var(--bg-panel);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  gap: 12px;
  align-items: center;
}
.item-row .item-text { flex: 1; }
.item-row img { width: 60px; height: 45px; object-fit: cover; border-radius: 6px; }
.item-row .item-actions { display: flex; gap: 8px; }
.item-row .item-actions button { padding: 8px 12px; font-size: 14px; }

.add-form {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 20px;
}

/* ---------- spoiler toggle (admin questions list) ---------- */
.spoiler-toggle-btn {
  background: var(--bg-panel-2);
  color: var(--text-dim);
  margin-bottom: 16px;
}
.spoiler-toggle-btn.active {
  background: var(--accent);
  color: #241f38;
  box-shadow: 0 0 0 3px rgba(242, 201, 76, 0.3);
}
#questions-list.spoiler-active .item-row {
  filter: blur(6px);
  pointer-events: none;
  user-select: none;
}
.add-form .row { display: flex; gap: 10px; }

/* ---------- round intro splash ---------- */
.round-intro-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 16px;
  min-height: 40vh;
}
.round-intro-heading {
  font-size: 64px;
  font-weight: 900;
  color: var(--accent);
  margin: 0;
  animation: intro-heading-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.play-body .round-intro-heading { font-size: 38px; }
@keyframes intro-heading-in {
  0% { transform: scale(0.3); opacity: 0; }
  70% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}
.round-intro-double {
  font-size: 26px;
  font-weight: 800;
  color: #241f38;
  background: linear-gradient(90deg, #e05c5c, #f2c94c);
  padding: 8px 22px;
  border-radius: 30px;
  margin-top: 18px;
  animation: intro-double-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s both, final-round-pulse 1.2s ease-in-out 0.8s infinite;
}
.play-body .round-intro-double { font-size: 18px; }
@keyframes intro-double-in {
  0% { transform: scale(0) rotate(-6deg); opacity: 0; }
  100% { transform: scale(1) rotate(-2deg); opacity: 1; }
}
.round-intro-subtext {
  font-size: 18px;
  color: var(--text-dim);
  margin-top: 20px;
  max-width: 480px;
  animation: intro-subtext-in 0.5s ease-out 0.45s both;
}
.play-body .round-intro-subtext { font-size: 15px; }
@keyframes intro-subtext-in {
  0% { transform: translateY(12px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* ---------- QR join box (lobby, screen page) ---------- */
.join-qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 28px auto 32px;
}
.join-qr-img {
  width: 260px;
  height: 260px;
  background: #fff;
  padding: 18px;
  border-radius: 20px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.35);
}
.join-qr-caption {
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  margin: 4px 0 0;
  text-align: center;
}
.join-qr-url {
  font-size: 15px;
  color: var(--text-dim);
  margin: 0;
  letter-spacing: 0.5px;
}

/* ---------- round summary (standings between rounds) ---------- */
.round-summary-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 16px;
}
.round-summary-heading {
  color: var(--accent);
  font-size: 30px;
  margin: 0 0 20px;
  animation: intro-heading-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.play-body .round-summary-heading { font-size: 22px; }
.round-summary-view .final-table { max-width: 480px; }

.winner-callout {
  font-size: 26px;
  font-weight: 800;
  color: var(--accent);
  margin-top: 8px;
  line-height: 1.3;
}

/* ---------- voting transition overlay ---------- */
/* Fully opaque while held - nothing behind is visible until the word starts
   shrinking, at which point playVotingTransitionAnimation() (common.js)
   fades this background out at the same time the word animates (via
   shrinkTextInto) toward the phase-badge's actual on-screen position, so it
   reads as the word physically becoming that badge rather than vanishing. */
.voting-transition-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  pointer-events: none;
  background-color: rgba(var(--bg-rgb), 1);
}
.voting-transition-word {
  font-size: 72px;
  font-weight: 900;
  color: var(--good);
  transform: scale(1);
}
.play-body .voting-transition-word { font-size: 42px; }

/* ---------- comics round ---------- */
.comic-caption-list { margin: 14px 0; display: flex; flex-direction: column; gap: 8px; }
.comic-caption-chip {
  background: var(--bg-panel-2);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 15px;
}
.comic-vote-hint {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  margin: 8px 0 12px;
}
.vote-option.comic-selected {
  border-color: var(--good);
  background: rgba(76, 175, 128, 0.15);
}
.comic-progress-line {
  text-align: center;
  color: var(--text-dim);
  font-size: 16px;
  margin: 10px 0;
}
.comic-player-totals {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.comic-player-totals .item-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 16px;
  margin: 0;
}
