:root {
  --bg-dark: #0d0f1a;
  --bg-panel: #1a1d33;
  --text: #e0e8ff;
  --muted: #a0a8c8;
  --accent-blue: #6fa8ff;
  --accent-pink: #ff7ac2;
  --accent-green: #6fe3a2;
  --accent-yellow: #ffd86b;
  --accent-red: #ff6f6f;
  --accent-purple: #b794f6;
  --accent-orange: #ffa94d;
  --accent-cyan: #5ce8f5;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background: radial-gradient(circle at top, #1e2245, var(--bg-dark) 70%);
  color: var(--text);
  font-family: "Lexend", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

/* Header */
.app-header {
  padding: 16px 24px;
  border-bottom: 1px solid #303560;
  background: linear-gradient(180deg, #1a1d33 0%, var(--bg-dark) 100%);
}

.title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.help-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--accent-blue);
  background: var(--bg-panel);
  color: var(--accent-blue);
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.help-btn:hover {
  background: var(--accent-blue);
  color: var(--bg-dark);
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(111, 168, 255, 0.5);
}

.limit-badge,
.game-title {
  font-size: 32px;
  font-weight: 900;
  color: var(--accent-blue);
  line-height: 1;
  text-shadow: 0 0 6px #1a1d33;
}

.timer-display {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-panel);
  border: 2px solid var(--accent-yellow);
  border-radius: 12px;
  padding: 8px 16px;
  box-shadow: 0 0 20px rgba(255, 216, 107, 0.3);
}

.timer-label {
  font-family: "Space Mono", monospace;
  font-size: 14px;
  color: var(--muted);
}

.timer-value {
  font-family: "Space Mono", monospace;
  font-size: 28px;
  font-weight: 900;
  color: var(--accent-yellow);
  text-shadow: 0 0 10px var(--accent-yellow);
  min-width: 60px;
  text-align: center;
}

.timer-value.warning {
  color: var(--accent-red);
  text-shadow: 0 0 10px var(--accent-red);
  animation: pulse 0.5s infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.tagline {
  font-family: "Space Mono", monospace;
  font-size: 14px;
  color: var(--accent-green);
  text-shadow: 0 0 10px var(--accent-green);
  margin-top: 8px;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 300px 1fr 350px;
  gap: 16px;
  padding: 16px;
  height: calc(100vh - 120px);
}

/* Left Panel - Players */
.left-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.player-card {
  background: var(--bg-panel);
  border: 2px solid #4a4f80;
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
}

.player-card.active {
  border-color: var(--accent-green);
  box-shadow: 0 0 20px rgba(111, 227, 162, 0.4);
}

.player-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid #4a4f80;
  background: #1a1d33;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.player-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bunny-avatar {
  background: linear-gradient(135deg, #ff7ac2, #ffa94d);
}

.bunny-face {
  font-size: 40px;
  animation: bunny-idle 2s ease-in-out infinite;
}

.bunny-face-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  animation: bunny-idle 2s ease-in-out infinite;
}

@keyframes bunny-idle {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

.player-info {
  flex: 1;
}

.player-name {
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  margin-bottom: 4px;
}

.player-color-display {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.color-box {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.player-status {
  margin-top: 12px;
  padding: 8px;
  background: #141938;
  border-radius: 8px;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--accent-yellow);
}

/* Bunny Distraction */
.bunny-distraction {
  margin-top: 12px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.distraction-animation {
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: bounce 0.6s ease-in-out infinite;
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-10px) rotate(5deg);
  }
}

.distraction-animation.wiggle {
  animation: wiggle 0.5s ease-in-out infinite;
}

@keyframes wiggle {
  0%,
  100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-15deg);
  }
  75% {
    transform: rotate(15deg);
  }
}

.distraction-animation.shake {
  animation: shake 0.4s ease-in-out infinite;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-10px);
  }
  75% {
    transform: translateX(10px);
  }
}

.distraction-animation.spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.distraction-text {
  font-size: 12px;
  color: var(--accent-pink);
  text-align: center;
  font-weight: 700;
  font-style: italic;
}

/* Game Log */
.game-log {
  background: var(--bg-panel);
  border: 1px solid #303560;
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 200px;
}

.game-log h3 {
  margin: 0 0 12px;
  color: var(--accent-blue);
  font-size: 16px;
  text-align: center;
}

.log-content {
  flex: 1;
  overflow-y: auto;
  font-family: "Space Mono", monospace;
  font-size: 12px;
  line-height: 1.6;
}

.log-entry {
  margin: 6px 0;
  padding: 4px 8px;
  border-left: 3px solid var(--accent-green);
  background: #141938;
  border-radius: 4px;
}

.log-entry.bunny {
  border-left-color: var(--accent-pink);
}

.log-entry.error {
  border-left-color: var(--accent-red);
}

/* Bingo Board */
.bingo-section {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.bingo-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 8px;
  width: min(600px, 100%);
  height: min(600px, 100%);
  aspect-ratio: 1;
}

.bingo-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: 3px solid #4a4f80;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.bingo-card:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 24px rgba(111, 168, 255, 0.4);
  z-index: 10;
}

.bingo-card.face-down {
  background: radial-gradient(circle at 30% 30%, #6fa8ff, #1a1d33);
}

.bingo-card .joker {
  font-size: 48px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

.bingo-card .question {
  font-family: "Space Mono", monospace;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  text-align: center;
  padding: 8px;
}

.bingo-card.claimed {
  cursor: default;
  border-width: 4px;
}

.bingo-card.claimed.blue {
  background: linear-gradient(135deg, #74c0fc, #339af0);
  border-color: var(--accent-blue);
}

.bingo-card.claimed.green {
  background: linear-gradient(135deg, #51cf66, #2f9e44);
  border-color: var(--accent-green);
}

.bingo-card.claimed.purple {
  background: linear-gradient(135deg, #b197fc, #7950f2);
  border-color: var(--accent-purple);
}

.bingo-card.claimed.orange {
  background: linear-gradient(135deg, #ffa94d, #ff8c00);
  border-color: var(--accent-orange);
}

.bingo-card.claimed.red {
  background: linear-gradient(135deg, #ff6b6b, #c92a2a);
  border-color: var(--accent-red);
}

.bingo-card.claimed.cyan {
  background: linear-gradient(135deg, #5ce8f5, #339af0);
  border-color: var(--accent-cyan);
}

.bingo-card.claimed.pink {
  background: linear-gradient(135deg, #ff7ac2, #ff5da2);
  border-color: var(--accent-pink);
}

.bingo-card.claimed:hover {
  transform: none;
}

.bingo-card.selected {
  border-color: var(--accent-yellow);
  box-shadow: 0 0 30px rgba(255, 216, 107, 0.8);
  animation: glow 1s ease-in-out infinite;
}

@keyframes glow {
  0%,
  100% {
    box-shadow: 0 0 30px rgba(255, 216, 107, 0.8);
  }
  50% {
    box-shadow: 0 0 40px rgba(255, 216, 107, 1);
  }
}

/* Right Panel */
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.question-area {
  background: var(--bg-panel);
  border: 2px solid #303560;
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.current-question h3 {
  margin: 0 0 12px;
  color: var(--accent-blue);
  font-size: 18px;
  text-align: center;
}

.question-display {
  background: #141938;
  border: 2px solid #4a4f80;
  border-radius: 10px;
  padding: 24px;
  font-family: "Space Mono", monospace;
  font-size: 32px;
  font-weight: 700;
  color: var(--accent-yellow);
  text-align: center;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.answer-area {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#answerInput {
  padding: 12px;
  border-radius: 10px;
  border: 2px solid #4a4f80;
  background: #141938;
  color: var(--text);
  font-family: "Space Mono", monospace;
  font-size: 20px;
  text-align: center;
  font-weight: 700;
  max-width: 200px;
  margin: 0 auto;
}

#answerInput:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 20px rgba(111, 168, 255, 0.3);
}

.answer-input-container {
  width: 100%;
}

.division-inputs {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  justify-content: center;
  align-items: flex-start;
}

.division-input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  max-width: 150px;
}

.division-input-group label {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-yellow);
  text-align: center;
}

.division-input-group input {
  padding: 12px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--bg-primary);
  color: var(--text);
  font-family: "Space Mono", monospace;
  font-size: 20px;
  text-align: center;
  font-weight: 700;
}

.division-input-group input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 20px rgba(111, 168, 255, 0.3);
}

.action-btn {
  padding: 14px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #74c0fc, #339af0);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow);
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
}

.action-btn:active {
  transform: translateY(0);
}

.action-btn.primary {
  background: linear-gradient(45deg, var(--accent-blue), var(--accent-pink));
}

.answer-feedback {
  text-align: center;
  font-weight: 700;
  font-size: 16px;
  min-height: 24px;
  padding: 8px;
  border-radius: 8px;
}

.answer-feedback.correct {
  color: var(--accent-green);
  background: rgba(111, 227, 162, 0.1);
}

.answer-feedback.incorrect {
  color: var(--accent-red);
  background: rgba(255, 111, 111, 0.1);
}

/* Joke Area */
.joke-area,
.knockknock-area {
  background: var(--bg-panel);
  border: 2px solid var(--accent-pink);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.joke-card,
.knockknock-card {
  text-align: center;
}

.joke-card.flash,
.knockknock-card.flash {
  animation: flash 0.5s ease-in-out infinite;
}

@keyframes flash {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.joke-content,
.knockknock-line {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-yellow);
  margin-bottom: 16px;
  line-height: 1.6;
}

.joke-btn {
  padding: 12px 24px;
  border-radius: 999px;
  border: 2px solid var(--accent-pink);
  background: linear-gradient(135deg, #ff7ac2, #ff5da2);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow);
  animation: wiggle-btn 1s ease-in-out infinite;
}

@keyframes wiggle-btn {
  0%,
  100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-5deg);
  }
  75% {
    transform: rotate(5deg);
  }
}

.joke-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 24px rgba(255, 122, 194, 0.6);
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: #0d0f1acc;
  backdrop-filter: blur(8px);
  z-index: 100;
}

.overlay.visible {
  display: grid;
}

.overlay .card {
  background: var(--bg-dark);
  border: 2px solid #303560;
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow);
  color: var(--text);
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
}

.overlay .card h2 {
  margin: 0 0 16px;
  color: var(--accent-blue);
  font-size: 32px;
  text-align: center;
}

.overlay .card h3 {
  color: var(--accent-pink);
  font-size: 20px;
  margin: 16px 0 8px;
}

/* Help Modal */
.help-modal {
  width: min(900px, 90vw);
  position: relative;
}

.help-content {
  max-height: 65vh;
  overflow-y: auto;
  padding-right: 10px;
  line-height: 1.6;
}

.help-content ul,
.help-content ol {
  padding-left: 24px;
}

.help-content li {
  margin: 6px 0;
}

.help-content p {
  margin: 8px 0;
}

.close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: 2px solid var(--accent-red);
  border-radius: 50%;
  background: var(--bg-dark);
  color: var(--accent-red);
  font-size: 32px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}

.close-btn:hover {
  background: var(--accent-red);
  color: var(--bg-dark);
  transform: rotate(90deg) scale(1.1);
  box-shadow: 0 0 20px rgba(255, 111, 111, 0.5);
}

/* Instructions */
.instructions {
  width: min(1000px, 90vw);
}

.instructions-content {
  max-height: 50vh;
  overflow-y: auto;
  padding-right: 10px;
  line-height: 1.6;
}

.instructions-content ul,
.instructions-content ol {
  padding-left: 24px;
}

.instructions-content li {
  margin: 6px 0;
}

.countdown {
  margin-top: 20px;
  text-align: center;
  color: var(--accent-yellow);
  font-family: "Space Mono";
  font-size: 18px;
  font-weight: 700;
}

button.primary {
  width: 100%;
  background: linear-gradient(45deg, var(--accent-blue), var(--accent-pink));
  border: none;
  color: #fff;
  padding: 16px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 18px;
  cursor: pointer;
  text-shadow: 0 1px 3px #0005;
  transition: transform 0.2s;
  margin-top: 16px;
}

button.primary:hover {
  transform: scale(1.02);
}

button.primary:active {
  transform: scale(0.98);
}

/* Setup */
.setup {
  width: min(700px, 90vw);
}

.setup form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.setup label {
  display: block;
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
}

.setup input,
.setup select {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  border-radius: 8px;
  background: #141938;
  color: var(--text);
  border: 2px solid #4a4f80;
  font-size: 16px;
  font-family: inherit;
}

.operations-checkboxes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 10px;
  border: 2px solid #4a4f80;
  border-radius: 8px;
  background: #141938;
  transition: all 0.2s;
}

.checkbox-label:hover {
  border-color: var(--accent-blue);
  background: #1a1d33;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.avatar-selector {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.avatar-option {
  width: 100%;
  aspect-ratio: 1;
  font-size: 32px;
  border: 3px solid #4a4f80;
  border-radius: 12px;
  background: #141938;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.avatar-option img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.avatar-option:hover {
  border-color: var(--accent-blue);
  transform: scale(1.1);
}

.avatar-option.selected {
  border-color: var(--accent-green);
  background: linear-gradient(135deg, #51cf66, #2f9e44);
  box-shadow: 0 0 20px rgba(111, 227, 162, 0.4);
}

.color-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.color-option {
  padding: 12px 16px;
  border: 3px solid #4a4f80;
  border-radius: 10px;
  background: #141938;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

.color-option:hover {
  border-color: var(--accent-blue);
  transform: scale(1.05);
}

.color-option.selected {
  border-color: var(--accent-green);
  background: linear-gradient(
    135deg,
    rgba(81, 207, 102, 0.2),
    rgba(47, 158, 68, 0.2)
  );
  box-shadow: 0 0 20px rgba(111, 227, 162, 0.4);
}

/* Game Over */
.gameover {
  width: min(800px, 90vw);
  text-align: center;
}

#gameOverMessage {
  font-size: 20px;
  margin: 20px 0;
  color: var(--accent-yellow);
}

.missed-jokes {
  margin: 24px 0;
  padding: 20px;
  background: #141938;
  border: 2px solid var(--accent-pink);
  border-radius: 12px;
  max-height: 300px;
  overflow-y: auto;
}

.missed-jokes h3 {
  color: var(--accent-pink);
  margin-top: 0;
}

#missedJokesList {
  text-align: left;
  line-height: 1.8;
}

.missed-joke-item {
  margin: 12px 0;
  padding: 12px;
  background: var(--bg-panel);
  border-radius: 8px;
  border-left: 4px solid var(--accent-yellow);
}

.gameover-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.gameover-actions button {
  flex: 1;
}

button.chip {
  background: #2a2d4a;
  border: 2px solid #4a4f80;
  color: #fff;
  padding: 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

button.chip:hover {
  background: #38406c;
  border-color: var(--accent-blue);
}

/* Utility */
.hidden {
  display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #141938;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #4a4f80;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #6fa8ff;
}

/* Responsive */
@media (max-width: 1400px) {
  .layout {
    grid-template-columns: 280px 1fr 320px;
  }
}

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .bingo-board {
    width: min(500px, 100%);
    height: min(500px, 100%);
  }

  .left-panel,
  .right-panel {
    flex-direction: row;
    overflow-x: auto;
  }
}

@media (max-width: 768px) {
  .title-wrap {
    flex-direction: column;
    align-items: flex-start;
  }

  .limit-badge,
  .game-title {
    font-size: 24px;
  }

  .bingo-board {
    width: min(400px, 100%);
    height: min(400px, 100%);
  }

  .question-display {
    font-size: 24px;
  }
}
