/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #1a1a2e;
  color: #eee;
  min-height: 100vh;
}

#app {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
}

/* ===== Game Banner ===== */
.banner-htp-row {
  display: flex;
  justify-content: center;
  padding: 0 4px 6px;
}

.game-banner {
  text-align: center;
  margin-bottom: 2px;
}

.game-banner img {
  width: 100%;
  max-width: 900px;
  height: auto;
  border-radius: 12px;
}

.game-banner img.logo-natural {
  width: auto;
  max-width: 717px;
}

/* ===== Screens ===== */
.screen { animation: fadeIn 0.3s ease-in; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Center Card (join / no-game) ===== */
.center-card {
  text-align: center;
  margin-top: 3vh;
}

.center-card h1 {
  font-size: 2.4rem;
  margin-bottom: 12px;
}

.center-card p {
  margin-bottom: 20px;
  color: #aaa;
}

.center-card code {
  background: #333;
  padding: 2px 8px;
  border-radius: 4px;
}

.inline-form {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.inline-form input {
  padding: 10px 14px;
  border-radius: 8px;
  border: 2px solid #444;
  background: #222;
  color: #eee;
  font-size: 1rem;
  width: 240px;
}

.inline-form input:focus {
  outline: none;
  border-color: #e94560;
}

/* ===== Game Name Row ===== */
.game-name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-bottom: 12px;
}

.game-name-row p,
.game-name-row h2 {
  margin-bottom: 0;
}

.btn-secondary {
  background: #333;
  color: #eee;
  border: 1px solid #555;
}

.btn-secondary:hover {
  background: #444;
}

.btn-small {
  padding: 6px 14px;
  font-size: 0.85rem;
}

/* ===== Rounds Dropdown ===== */
.rounds-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.rounds-row label {
  color: #aaa;
  font-size: 0.95rem;
}

.rounds-select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 2px solid #444;
  background: #222;
  color: #eee;
  font-size: 0.95rem;
  cursor: pointer;
}

.rounds-select:focus {
  outline: none;
  border-color: #e94560;
}

/* ===== Buttons ===== */
.btn {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s;
}

.btn:hover { transform: scale(1.03); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: #e94560;
  color: #fff;
}

.btn-primary:hover { background: #d63851; }

.btn-restart { background: #e67e22; color: #fff; }
.btn-restart:hover { background: #cf6d17; }

.btn-large {
  padding: 14px 40px;
  font-size: 1.2rem;
}

#btn-spin {
  animation: slow-pulse-scale 1.8s ease-in-out infinite;
}
#btn-spin:hover,
#btn-spin:disabled {
  animation: none;
}

.btn-correct  { background: #2ecc71; color: #fff; }
.btn-incorrect { background: #e74c3c; color: #fff; }
.btn-bad { background: #f39c12; color: #fff; }

.btn-correct:hover  { background: #27ae60; }
.btn-incorrect:hover { background: #c0392b; }
.btn-bad:hover { background: #d68910; }

/* ===== Lobby ===== */
.lobby-container {
  text-align: center;
  margin-top: 2vh;
}

.lobby-container h1 { font-size: 2.2rem; margin-bottom: 8px; }
.lobby-container h2 { color: #aaa; font-weight: 400; margin-bottom: 24px; }
.lobby-container .game-name-row h2 { margin-bottom: 0; }

.player-list-container {
  background: #16213e;
  border-radius: 12px;
  padding: 20px;
  max-width: 400px;
  margin: 0 auto 24px;
}

.player-list-container h3 {
  margin-bottom: 12px;
  color: #e94560;
}

#lobby-player-list {
  list-style: none;
}

#lobby-player-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid #253557;
}

#lobby-player-list li:last-child { border-bottom: none; }

.player-name { font-weight: 600; flex: 1; }
.player-host-badge {
  background: #e94560;
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 12px;
  margin-left: 8px;
}

.player-disconnected { opacity: 0.4; }

#join-player-list {
  list-style: none;
}

#join-player-list li {
  padding: 8px 12px;
  border-bottom: 1px solid #253557;
}

#join-player-list li:last-child { border-bottom: none; }

.btn-remove {
  background: transparent;
  border: 1px solid #e74c3c;
  color: #e74c3c;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  margin-left: auto;
  flex-shrink: 0;
}

.btn-remove:hover { background: #e74c3c; color: #fff; }

.muted { color: #777; font-style: italic; margin-top: 12px; }

/* ===== Scoreboard ===== */
.scoreboard {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  padding: 12px;
  background: #16213e;
  border-radius: 12px;
  margin-bottom: 20px;
}

.score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 16px;
  border-radius: 8px;
  background: #1a1a2e;
  min-width: 80px;
  transition: all 0.3s;
  position: relative;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(241, 196, 15, 0.3); }
  50%       { box-shadow: 0 0 22px rgba(241, 196, 15, 0.9); }
}

@keyframes slow-pulse-scale {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.07); }
}

.score-item.active {
  background: #e94560;
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(241, 196, 15, 0.4);
  animation: pulse-glow 1.5s ease-in-out infinite;
}

.score-item.disconnected { opacity: 0.4; }
/* Connection dot in score-item: anchor to top-right corner */
.score-item .conn-dot  { position: absolute; top: 4px; right: 6px; }

.score-name { font-size: 0.85rem; font-weight: 600; }
.score-value { font-size: 1.3rem; font-weight: 700; }
@keyframes scorePop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}
.score-value.score-pop { animation: scorePop 0.4s ease-out; }

/* ===== Spin Slots ===== */
.spin-slots {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin: 24px 0;
}

.slot {
  width: 180px;
  background: #16213e;
  border-radius: 16px;
  padding: 20px 16px 24px;
  text-align: center;
  border: 3px solid #253557;
  transition: all 0.3s;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 190px;
}

.slot.spinning {
  animation: slotSpin 0.15s infinite;
}

@keyframes slotSpin {
  0%   { transform: translateY(-4px); }
  50%  { transform: translateY(4px); }
  100% { transform: translateY(-4px); }
}

.slot.revealed {
  border-color: #e94560;
  animation: none;
}

.slot-name {
  font-weight: 700;
  font-size: 1.3rem;
  margin-bottom: 8px;
}

.slot-name:empty {
  display: none;
}

.slot:not(.revealed) .slot-name {
  font-size: 2rem;
}

.slot-image {
  margin: 8px 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cat-card-img {
  width: 100px;
  object-fit: contain;
  display: block;
}

.cat-inline-img {
  height: 1.2em;
  width: auto;
  object-fit: contain;
  vertical-align: middle;
}

.slot-points {
  font-size: 1.4rem;
  font-weight: 700;
  color: #f1c40f;
}

/* ===== Category Choices ===== */
.category-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin: 20px 0;
}

.category-btn {
  padding: 18px 20px;
  border: 2px solid #e94560;
  background: #16213e;
  color: #eee;
  border-radius: 16px;
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  min-width: 150px;
  max-width: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.category-btn:hover {
  background: #e94560;
  transform: scale(1.05);
}

.category-btn .cat-emoji {
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
}

.category-btn .cat-name {
  display: block;
  white-space: normal;
  word-break: break-word;
  line-height: 1.3;
}

.category-btn-display {
  cursor: default;
  pointer-events: none;
  opacity: 0.85;
}

.category-btn-display:hover {
  background: #16213e;
  transform: none;
}

.category-btn .cat-points {
  font-size: 1rem;
  color: #f1c40f;
  display: block;
}

#watching-spin-slots .slot {
  padding: 12px 14px 16px;
}

#watching-spin-slots .slot-image {
  min-height: auto;
}

.inline-points {
  font-size: 1.2rem;
  font-weight: 700;
  color: #f1c40f;
  margin-left: 10px;
}

.question-category-img {
  display: flex;
  justify-content: center;
  margin: 12px 0 4px;
}

.question-category-img .cat-card-img,
.voting-cat-img {
  width: 150px;
  object-fit: contain;
  display: block;
}

/* ===== Slide-in-from-left animation ===== */
@keyframes slideInFromLeft {
  from { opacity: 0; transform: translateX(-60px); }
  to   { opacity: 1; transform: translateX(0); }
}

.slide-in-left {
  opacity: 0;
  animation: slideInFromLeft 0.4s ease-out forwards;
  animation-delay: var(--slide-delay, 0s);
}

/* ===== Question Card ===== */
.question-card {
  background: #16213e;
  border-radius: 16px;
  padding: 32px;
  margin: 20px auto;
  max-width: 600px;
  text-align: center;
}

.question-text {
  font-size: 1.3rem;
  line-height: 1.6;
  font-weight: 500;
}

.question-answer {
  margin-top: 16px;
  font-size: 1.1rem;
  color: #2ecc71;
  font-weight: 700;
  border-top: 1px solid #253557;
  padding-top: 16px;
}

/* ===== Timer ===== */
.timer {
  font-size: 3rem;
  font-weight: 700;
  text-align: center;
  margin: 16px 0;
  color: #f1c40f;
}

.timer.urgent { color: #e74c3c; animation: pulse 0.5s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ===== Voting ===== */
.voting-category-label {
  font-size: 1.4rem;
  font-weight: 700;
  color: #aaa;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

#voting-category-name {
  color: #eee;
}

#watching-spin-slots .slot-name {
  font-size: 1.1rem;
}

.voting-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 20px 0;
}

.voting-buttons .btn { padding: 14px 28px; font-size: 1.1rem; animation: slow-pulse-scale 1.8s ease-in-out infinite; }
.voting-buttons .btn:hover { animation: none; }

.voting-status { text-align: center; }

.vote-bar {
  width: 300px;
  height: 8px;
  background: #333;
  border-radius: 4px;
  margin: 8px auto;
  overflow: hidden;
}

.vote-bar-fill {
  height: 100%;
  background: #e94560;
  border-radius: 4px;
  transition: width 0.3s;
  width: 0%;
}

/* ===== Waiting ===== */
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-18px); }
}

#phase-spin .slot:not(.spinning):not(.revealed) {
  animation: bounce 1s ease-in-out infinite;
}
#phase-spin .slot:nth-child(1):not(.spinning):not(.revealed) { animation-delay: 0s; }
#phase-spin .slot:nth-child(2):not(.spinning):not(.revealed) { animation-delay: 0.2s; }
#phase-spin .slot:nth-child(3):not(.spinning):not(.revealed) { animation-delay: 0.4s; }

/* ===== Results ===== */
#phase-results {
  text-align: center;
  margin-top: 40px;
}

#phase-results h2 { font-size: 2rem; margin-bottom: 12px; }

/* ===== Game Over ===== */
#phase-game-over { text-align: center; margin-top: 2vh; }
#phase-game-over h1 { margin-bottom: 8px; }

.final-scores {
  max-width: 400px;
  margin: 8px auto;
}

.final-score-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #16213e;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.final-score-item:first-child {
  background: #e94560;
  font-size: 1.3rem;
  font-weight: 700;
}

.final-score-item .rank { margin-right: 12px; }

/* ===== Slide-in-from-top animation ===== */
@keyframes slideInFromTop {
  from { opacity: 0; transform: translateY(-40px); }
  to   { opacity: 1; transform: translateY(0); }
}

.slide-in-top {
  opacity: 0;
  animation: slideInFromTop 0.4s ease-out forwards;
  animation-delay: var(--slide-delay, 0s);
}

/* ===== Round Indicator Row ===== */
.game-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}

.game-title-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #888;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.round-indicator-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.game-room-display {
  font-size: 0.9rem;
  font-weight: 700;
  color: #ccc;
  letter-spacing: 0.5px;
  white-space: nowrap;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

.round-indicator-left {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-new-game {
  font-size: 0.75rem !important;
  padding: 3px 10px !important;
}

.round-indicator {
  font-size: 0.85rem;
  font-weight: bold;
  color: #aaa;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ===== How to Play Link ===== */
.how-to-play-link {
  font-size: 0.8rem;
  color: #e94560;
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.5px;
  border: 1px solid #e94560;
  padding: 3px 10px;
  border-radius: 12px;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.how-to-play-link:hover {
  background: #e94560;
  color: #fff;
}

/* ===== How to Play Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease-in;
}

.modal-content {
  background: #16213e;
  border-radius: 16px;
  padding: 36px 32px 32px;
  max-width: 1008px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  border: 1px solid #253557;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}

.modal-content h2 {
  font-size: 1.6rem;
  color: #e94560;
  margin-bottom: 20px;
  text-align: center;
  letter-spacing: 1px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: #e94560;
  border: none;
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
  font-weight: 700;
}

.modal-close:hover {
  background: #c0392b;
  transform: scale(1.1);
}

.how-to-play-list {
  list-style: none;
  counter-reset: steps;
  padding: 0;
}

.how-to-play-list li {
  counter-increment: steps;
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid #253557;
  font-size: 0.95rem;
  line-height: 1.6;
  color: #ddd;
}

.how-to-play-list li:last-child {
  border-bottom: none;
}

.how-to-play-list li::before {
  content: counter(steps);
  background: #e94560;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.how-to-play-list li strong {
  color: #fff;
  display: block;
  margin-bottom: 2px;
}

.vote-correct  { color: #2ecc71; font-weight: 700; }
.vote-incorrect { color: #e74c3c; font-weight: 700; }
.vote-bad      { color: #f39c12; font-weight: 700; }

/* ===== How to Play — Categories Info ===== */
.htp-categories {
  margin-top: 18px;
  padding: 14px 16px;
  background: #1a2540;
  border: 1px solid #253557;
  border-radius: 8px;
}

.htp-categories-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #aaa;
  margin: 0 0 10px;
  font-weight: 600;
}

.htp-categories-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.htp-categories-list li {
  background: #0d1b2a;
  border: 1px solid #2e4070;
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.88rem;
  color: #ddd;
}

/* ===== Points Table (inside modal) ===== */
.points-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 0.88rem;
}

.points-table tr {
  border-bottom: 1px solid #253557;
}

.points-table tr:last-child {
  border-bottom: none;
}

.points-table td {
  padding: 6px 8px;
  color: #ccc;
}

.pts-val {
  text-align: right;
  font-weight: 700;
  color: #f1c40f;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .modal-content { padding: 28px 18px 24px; }
  .how-to-play-link { font-size: 0.72rem; padding: 2px 8px; }
}

/* ===== Game Phase Headers ===== */
.game-phase {
  text-align: center;
}

.game-phase h2 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.category-heading {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .spin-slots { flex-direction: column; align-items: center; }
  .slot { width: 90%; }
  .voting-buttons { flex-direction: column; align-items: center; }
  .scoreboard { gap: 10px; }
  .score-item { padding: 6px 10px; min-width: 60px; }
  .score-name { font-size: 0.75rem; }
  .score-value { font-size: 1rem; }
}

/* ===== Ask a Friend ===== */
.ask-friend-section {
  margin-top: 24px;
  border-top: 1px solid #253557;
  padding-top: 20px;
}

.btn-ask-friend {
  background: #0d4f6e;
  color: #fff;
  border: 2px solid #2196f3;
}

.btn-ask-friend:hover {
  background: #1565a0;
}

.friend-picker {
  margin-top: 16px;
  background: #16213e;
  border: 1px solid #2196f3;
  border-radius: 12px;
  padding: 16px;
  animation: fadeIn 0.2s ease-in;
}

.friend-picker-prompt {
  color: #aaa;
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.friend-picker-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.friend-picker-player {
  background: #0d3353;
  color: #eee;
  border: 2px solid #2196f3;
  animation: slow-pulse-scale 1.8s ease-in-out infinite;
}

.friend-picker-player:hover {
  animation: none;
  background: #2196f3;
  color: #fff;
}

.friend-selected-info {
  background: #0a2a3d;
  border: 2px solid #2196f3;
  border-radius: 12px;
  padding: 14px 20px;
  color: #eee;
  font-size: 1rem;
}

.friend-selected-info strong {
  color: #64b5f6;
}

/* ===== Score Toast Notifications ===== */
#score-notifications {
  position: fixed;
  top: 10rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  align-items: flex-end;
}

.score-toast {
  background: #1a6e1a;
  border: 1px solid #2ecc71;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  box-shadow: 0 4px 18px rgba(0,0,0,0.7), 0 0 8px rgba(46,204,113,0.4);
  animation: score-toast-in 0.3s ease forwards;
  white-space: nowrap;
}

.score-toast.score-toast-loss {
  background: #7a1020;
  border-color: #e94560;
  box-shadow: 0 4px 18px rgba(0,0,0,0.7), 0 0 8px rgba(233,69,96,0.5);
}

.score-toast.score-toast-join {
  background: #0d47a1;
  border-color: #42a5f5;
  box-shadow: 0 4px 18px rgba(0,0,0,0.7), 0 0 8px rgba(66,165,245,0.5);
}

.score-toast.score-toast-error {
  background: #8b0000;
  border-color: #ff2222;
  box-shadow: 0 4px 18px rgba(0,0,0,0.7), 0 0 8px rgba(255,34,34,0.5);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: normal;
  max-width: 320px;
}

.score-toast.score-toast-error .toast-close-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
  padding: 0 0 0 0.25rem;
  line-height: 1;
  opacity: 0.8;
  flex-shrink: 0;
}

.score-toast.score-toast-error .toast-close-btn:hover {
  opacity: 1;
}

.score-toast.fade-out {
  animation: score-toast-out 0.6s ease forwards;
}

@keyframes score-toast-in {
  from { opacity: 0; transform: translateX(60px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes score-toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(60px); }
}

/* ===== QR Invite Button ===== */
.btn-qr {
  background: transparent;
  border: none;
  outline: none;
  color: #bbb;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: color 0.2s, background 0.2s;
}

.btn-qr:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #e94560;
}

/* ===== QR Modal ===== */
.qr-modal-content {
  max-width: 320px;
  text-align: center;
}

/* ===== Idle Pause Overlay ===== */
#idle-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#idle-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  text-align: center;
  padding: 2.5rem 2rem;
  pointer-events: none;
}

#idle-pause-icon {
  font-size: 5rem;
  line-height: 1;
  filter: drop-shadow(0 0 18px rgba(255, 215, 0, 0.55));
  animation: idle-pulse 2s ease-in-out infinite;
}

@keyframes idle-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.7; transform: scale(0.93); }
}

#idle-pause-title {
  color: #ffd700;
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
  text-shadow: 0 2px 8px rgba(0,0,0,0.7);
}

#idle-pause-msg {
  color: #ccc;
  font-size: 1.05rem;
  margin: 0;
  line-height: 1.6;
}

#btn-idle-resume {
  pointer-events: auto;
  font-size: 1.1rem;
  padding: 0.75rem 2.2rem;
  margin-top: 0.5rem;
}

.qr-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-top: 4px;
}

.qr-img {
  width: 220px;
  height: 220px;
  display: block;
}

#qr-code-container canvas {
  border-radius: 8px;
  display: block;
}

.qr-url-text {
  font-size: 0.75rem;
  color: #888;
  word-break: break-all;
  max-width: 280px;
  text-align: center;
  margin: 0;
}

/* ===== Settings Gear Button ===== */
.btn-settings {
  background: transparent;
  border: none;
  outline: none;
  color: #bbb;
  font-size: 1.15rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.btn-settings:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  transform: rotate(90deg);
}

/* ===== Settings Modal ===== */
.settings-modal-content {
  max-width: 520px;
}

/* Settings tab bar — reuses host-panel-tabs style, scoped to settings modal */
.settings-tab-bar {
  border-bottom: 1px solid #253557;
  margin: 0;
  border-radius: 0;
}
.settings-tab-content {
  display: block; /* shown/hidden via JS */
}
/* Read-only question items in non-host Custom Category tab */
.settings-cat-readonly-q {
  font-size: 0.88rem;
  color: #b0b8d0;
  padding: 5px 0;
  border-bottom: 1px solid #1e2a45;
  margin: 0;
}

.settings-body {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid #253557;
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-label-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.settings-label {
  font-size: 1rem;
  color: #ddd;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.settings-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  background: #3a2a10;
  color: #f1c40f;
  border: 1px solid #8a6200;
}

.settings-meta {
  font-size: 0.75rem;
  color: #888;
  min-height: 1em;
}

.settings-control {
  display: flex;
  align-items: center;
}

.settings-locked-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #aaa;
  min-width: 32px;
  text-align: center;
  background: #1a2540;
  border: 1px solid #2e4070;
  border-radius: 8px;
  padding: 5px 14px;
  cursor: not-allowed;
}

/* ===== Toggle Switch ===== */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #444;
  border-radius: 24px;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: #2ecc71;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

/* ===== Host Controls Crown Button ===== */
.btn-host-crown {
  background: transparent;
  border: none;
  outline: none;
  color: #ffd700;
  font-size: 1.1rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: background 0.2s, transform 0.2s;
  flex-shrink: 0;
}
.btn-host-crown:hover {
  background: rgba(255, 215, 0, 0.15);
  transform: scale(1.15);
}

/* ===== Host Panel Modal ===== */
.host-panel-box {
  background: #16213e;
  border: 1px solid #2d3a5e;
  border-radius: 16px;
  padding: 0;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.7);
  position: relative;
}

.host-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 52px 14px 20px;
  border-bottom: 1px solid #2d3a5e;
  font-size: 1.2rem;
  font-weight: 700;
  color: #ffd700;
}

.host-panel-tabs {
  display: flex;
  border-bottom: 1px solid #2d3a5e;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 12px 16px;
  color: #aaa;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.tab-btn:hover { color: #eee; }
.tab-btn.active {
  color: #ffd700;
  border-bottom-color: #ffd700;
}

.host-tab-content {
  padding: 18px 20px;
  min-height: 520px;
}

/* ===== Host Players Tab ===== */
.hp-player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #1e2d4a;
}
.hp-player-row:last-child { border-bottom: none; }

.conn-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #555;
}
.conn-dot.connected {
  background: #2ecc71;
  box-shadow: 0 0 5px #2ecc71;
}
.conn-dot.disconnected {
  background: #e53935;
  box-shadow: 0 0 5px rgba(229, 57, 53, 0.4);
}

.hp-player-name {
  flex: 1;
  font-size: 0.95rem;
  color: #eee;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.hp-badge {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
}
.hp-badge-host { background: #ffd700; color: #1a1a2e; }
.hp-badge-you  { background: #555; color: #eee; }

.hp-answered-badge {
  font-size: 0.72rem;
  color: #2ecc71;
  font-weight: 700;
}
.hp-pending-badge {
  font-size: 0.72rem;
  color: #f39c12;
}

.btn-remove-player {
  background: #4a0a0a;
  color: #e74c3c;
  border: 1px solid #7a1a1a;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-remove-player:hover { background: #7a1a1a; color: #fff; }

/* ===== Host Category Tab ===== */
.host-cat-section {
  margin-bottom: 16px;
}
.host-field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #aaa;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.host-field-hint {
  font-size: 0.8rem;
  color: #666;
  text-transform: none;
  font-weight: 400;
  letter-spacing: 0;
}
.host-text-input {
  width: 100%;
  padding: 8px 12px;
  background: #0f1926;
  border: 1px solid #2d3a5e;
  border-radius: 8px;
  color: #eee;
  font-size: 0.95rem;
  box-sizing: border-box;
}
.host-text-input:focus {
  outline: none;
  border-color: #ffd700;
}

.host-question-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.host-question-input {
  flex: 1;
  padding: 7px 10px;
  background: #0f1926;
  border: 1px solid #2d3a5e;
  border-radius: 7px;
  color: #eee;
  font-size: 0.9rem;
  box-sizing: border-box;
}
.host-question-input:focus {
  outline: none;
  border-color: #ffd700;
}
.btn-remove-question {
  background: transparent;
  border: 1px solid #444;
  color: #e74c3c;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.btn-remove-question:hover { background: #4a0a0a; border-color: #e74c3c; }

.host-cat-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 6px;
}
.host-save-status {
  font-size: 0.88rem;
  padding: 6px 10px;
  border-radius: 6px;
  text-align: center;
}
.host-save-status.success { background: #0d3a1e; color: #2ecc71; border: 1px solid #2ecc71; }
.host-save-status.error   { background: #3a0d0d; color: #e74c3c; border: 1px solid #e74c3c; }

/* ===== Lobby Checkmark Badges ===== */
.answered-badge {
  font-size: 0.8rem;
  color: #2ecc71;
  font-weight: 700;
  margin-left: 4px;
}
.answered-badge[title] { cursor: default; }
.pending-badge {
  font-size: 0.78rem;
  color: #f39c12;
  margin-left: 4px;
}

/* ===== Pre-game Questions Modal ===== */
.pregame-modal-box {
  background: #16213e;
  border: 1px solid #2d3a5e;
  border-radius: 16px;
  padding: 28px 24px;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.7);
}
.pregame-modal-box h2 {
  color: #ffd700;
  font-size: 1.4rem;
  margin-bottom: 6px;
  text-align: center;
}
.pregame-intro {
  color: #aaa;
  font-size: 0.9rem;
  text-align: center;
  margin-bottom: 18px;
}
.pregame-question-row {
  background: #0f1926;
  border: 1px solid #2d3a5e;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.pregame-question-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: #eee;
  margin-bottom: 8px;
  line-height: 1.4;
}
.pregame-answer-input {
  width: 100%;
  padding: 7px 10px;
  background: #16213e;
  border: 1px solid #2d3a5e;
  border-radius: 7px;
  color: #eee;
  font-size: 0.9rem;
  resize: none;
  box-sizing: border-box;
  font-family: inherit;
}
.pregame-answer-input:focus {
  outline: none;
  border-color: #ffd700;
}
.pregame-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}
.pregame-status {
  font-size: 0.88rem;
  color: #e74c3c;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.pregame-status.saving { color: #aaa; }

/* ===== Inline Spinner ===== */
@keyframes spin-ring {
  to { transform: rotate(360deg); }
}
.inline-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #ffd700;
  border-radius: 50%;
  animation: spin-ring 0.7s linear infinite;
  flex-shrink: 0;
}

/* ── Playing Card Suit Rain ───────────────────────────────── */
.card-piece {
  position: fixed; top: -60px;
  pointer-events: none; z-index: 1000;
  animation: card-fall linear forwards;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
  user-select: none;
  line-height: 1;
}
@keyframes card-fall {
  0%   { transform: translateY(0)     rotateX(0deg)   rotateZ(0deg);   opacity: 1; }
  25%  { transform: translateY(25vh)  rotateX(90deg)  rotateZ(15deg);  opacity: 1; }
  60%  { transform: translateY(65vh)  rotateX(220deg) rotateZ(-10deg); opacity: 0.9; }
  100% { transform: translateY(115vh) rotateX(360deg) rotateZ(5deg);   opacity: 0; }
}


/* -- Site Footer ----------------------------------- */
:root {
  --footer-bg:     #141428;
  --footer-text:   #a0aec0;
  --footer-accent: #e94560;
}

.br-input {
  display: block;
  width: 100%;
  background: #12122a;
  border: 1px solid rgba(233,69,96,0.3);
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 0.95rem;
  padding: 0.5rem 0.75rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  box-sizing: border-box;
}
.br-input:focus {
  border-color: var(--footer-accent);
  box-shadow: 0 0 0 2px rgba(233,69,96,0.18);
}
textarea.br-input { resize: vertical; }

.modal-close-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.85rem;
  background: none;
  border: none;
  color: #a0aec0;
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem 0.4rem;
}
.modal-close-btn:hover { color: #fff; }

.site-footer {
  background: var(--footer-bg);
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 2.5rem 1.5rem 1.75rem;
  margin-top: 3rem;
}
.site-footer__inner {
  max-width: 960px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 2rem;
  align-items: start;
}
.site-footer__heading {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--footer-accent);
  margin: 0 0 0.75rem;
}
.site-footer__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.site-footer__link {
  font-size: 0.85rem;
  color: var(--footer-text);
  text-decoration: none;
  transition: color 0.15s;
}
.site-footer__link:hover,
.site-footer__link[aria-current="page"] {
  color: #fff;
}
.site-footer__link[aria-current="page"] {
  font-weight: 600;
}
.site-footer__brand {
  text-align: right;
}
.site-footer__home-link {
  display: inline-block;
  font-size: 1rem;
  font-weight: 700;
  color: var(--footer-accent);
  text-decoration: none;
  margin-bottom: 0.5rem;
  transition: opacity 0.15s;
}
.site-footer__home-link:hover { opacity: 0.8; }
.site-footer__copyright {
  font-size: 0.75rem;
  color: var(--footer-text);
  margin: 0;
}
@media (max-width: 700px) {
  .site-footer__inner {
    grid-template-columns: 1fr 1fr;
  }
  .site-footer__brand {
    text-align: left;
    grid-column: 1 / -1;
  }
}
@media (max-width: 420px) {
  .site-footer__inner {
    grid-template-columns: 1fr;
  }
}

/* ===== Ad Containers ===== */
/* Hidden by default; ADS.show() makes them visible only when ads are enabled. */
.ad-container {
  display: none;
  width: 100%;
  max-width: 728px;
  margin: 16px auto;
  padding: 0 8px;
  text-align: center;
  min-height: 90px;
}

.ad-placeholder {
  background: rgba(40, 40, 60, 0.7);
  border: 1px dashed #555;
  border-radius: 6px;
  padding: 12px;
}

.ad-label {
  display: block;
  color: #888;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 6px;
}

.ad-mock-box {
  color: #666;
  font-size: 0.78rem;
  padding: 20px 0;
}

@media (max-width: 480px) {
  .ad-container { min-height: 60px; }
}
