: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",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

/* Header */
.app-header {
  padding: 12px 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;
}

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

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

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

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

.score-display {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-panel);
  border: 2px solid var(--accent-green);
  border-radius: 12px;
  padding: 6px 14px;
  box-shadow: 0 0 20px rgba(111, 227, 162, 0.3);
}

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

.score-value {
  font-family: "Space Mono", monospace;
  font-size: 24px;
  font-weight: 900;
  color: var(--accent-green);
  text-shadow: 0 0 10px var(--accent-green);
  min-width: 80px;
  text-align: center;
}

.tagline {
  font-family: "Space Mono", monospace;
  font-size: 12px;
  color: var(--accent-pink);
  text-shadow: 0 0 10px var(--accent-pink);
  margin-top: 6px;
  text-align: center;
}

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

/* Question Section */
.question-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.question-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-panel);
  border: 2px solid #303560;
  border-radius: 14px;
  padding: 12px 20px;
  box-shadow: var(--shadow);
}

.question-header h3 {
  margin: 0;
  color: var(--accent-cyan);
  font-size: 18px;
}

.timer-display {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #141938;
  border: 2px solid var(--accent-yellow);
  border-radius: 10px;
  padding: 6px 14px;
  box-shadow: 0 0 15px rgba(255, 216, 107, 0.3);
}

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

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

.timer-value.warning {
  color: var(--accent-red);
  animation: pulse-timer 0.5s ease-in-out infinite;
}

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

.question-card {
  background: var(--bg-panel);
  border: 3px solid var(--accent-blue);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow);
  text-align: center;
}

.question-text {
  font-size: 20px;
  color: var(--text);
  margin-bottom: 20px;
  line-height: 1.6;
}

.question-math {
  font-family: "Space Mono", monospace;
  font-size: 32px;
  font-weight: 900;
  color: var(--accent-cyan);
  text-shadow: 0 0 15px var(--accent-cyan);
  padding: 20px;
  background: #141938;
  border-radius: 12px;
  border: 2px solid var(--accent-cyan);
}

/* Bunnies Section */
.bunnies-section {
  background: var(--bg-panel);
  border: 2px solid #303560;
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.bunnies-section h3 {
  margin: 0 0 20px;
  color: var(--accent-pink);
  font-size: 20px;
  text-align: center;
}

.bunnies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.bunny-card {
  background: linear-gradient(135deg, #252850 0%, #1e2040 100%);
  border: 3px solid #4a4f80;
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  position: relative;
}

.bunny-card:hover:not(.selected):not(.disabled) {
  transform: translateY(-4px);
  border-color: var(--accent-blue);
  box-shadow: 0 8px 24px rgba(111, 168, 255, 0.4);
}

.bunny-card.selected {
  border-color: var(--accent-green);
  box-shadow: 0 0 30px rgba(111, 227, 162, 0.6);
  background: linear-gradient(135deg, #1e3a2e 0%, #152820 100%);
}

.bunny-card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bunny-avatar {
  width: 80px;
  height: 80px;
  margin: 0 auto 12px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #4a4f80;
  box-shadow: var(--shadow);
}

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

.bunny-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-yellow);
  margin-bottom: 8px;
}

.bunny-answer {
  font-family: "Space Mono", monospace;
  font-size: 24px;
  font-weight: 900;
  color: var(--accent-cyan);
  padding: 10px;
  background: #141938;
  border-radius: 8px;
  margin-bottom: 8px;
}

.bunny-plea {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  line-height: 1.4;
}

/* Drama Section */
.drama-section {
  background: var(--bg-panel);
  border: 2px solid #303560;
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
  min-height: 150px;
  max-height: 300px;
  overflow-y: auto;
}

.drama-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.drama-message {
  padding: 12px 16px;
  border-radius: 10px;
  border-left: 4px solid;
  animation: slide-in 0.4s ease;
  line-height: 1.5;
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.drama-message.insult {
  background: rgba(255, 111, 111, 0.1);
  border-left-color: var(--accent-red);
  color: var(--accent-red);
}

.drama-message.compliment {
  background: rgba(111, 227, 162, 0.1);
  border-left-color: var(--accent-green);
  color: var(--accent-green);
}

.drama-message.poem {
  background: rgba(183, 148, 246, 0.1);
  border-left-color: var(--accent-purple);
  color: var(--accent-purple);
  font-style: italic;
  white-space: pre-line;
}

.drama-speaker {
  font-weight: 700;
  margin-right: 6px;
}

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

.player-info-card {
  background: var(--bg-panel);
  border: 2px solid #4a4f80;
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
  text-align: center;
}

.player-info-card h3 {
  margin: 0 0 12px;
  color: var(--accent-blue);
  font-size: 16px;
}

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

.level-badge {
  display: inline-block;
  background: var(--accent-orange);
  color: #fff;
  font-family: "Space Mono", monospace;
  font-size: 14px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 20px;
}

/* Progress Panel */
.progress-panel {
  background: var(--bg-panel);
  border: 2px solid #303560;
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.progress-panel h3 {
  margin: 0 0 16px;
  color: var(--accent-blue);
  font-size: 15px;
  text-align: center;
}

.question-progress {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.progress-item {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #141938;
  border: 2px solid #4a4f80;
  border-radius: 8px;
  font-family: "Space Mono", monospace;
  font-size: 16px;
  font-weight: 700;
  color: var(--muted);
  transition: all 0.3s ease;
}

.progress-item.current {
  border-color: var(--accent-yellow);
  background: rgba(255, 216, 107, 0.15);
  color: var(--accent-yellow);
  box-shadow: 0 0 15px rgba(255, 216, 107, 0.3);
  animation: pulse-progress 1.5s ease-in-out infinite;
}

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

.progress-item.correct {
  border-color: var(--accent-green);
  background: rgba(111, 227, 162, 0.2);
  color: var(--accent-green);
}

.progress-item.incorrect {
  border-color: var(--accent-red);
  background: rgba(255, 111, 111, 0.2);
  color: var(--accent-red);
}

/* 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-cyan);
  background: #141938;
  border-radius: 4px;
}

.log-entry.correct {
  border-left-color: var(--accent-green);
}

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

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

.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;
  width: 100%;
}

.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;
}

/* Instructions */
.instructions {
  width: min(700px, 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", monospace;
  font-size: 18px;
  font-weight: 700;
}

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

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

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

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

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

button.primary {
  padding: 16px 32px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #74c0fc, #339af0);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow);
  font-family: inherit;
}

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

button.primary:active {
  transform: translateY(0);
}

.instructions button.primary {
  display: block;
  margin: 0 auto;
}

/* Game Over */
.gameover {
  width: min(1200px, 90vw);
}

.final-score-section {
  text-align: center;
  margin: 20px 0;
}

.score-display-large {
  font-family: "Space Mono", monospace;
  font-size: 64px;
  font-weight: 900;
  color: var(--accent-green);
  text-shadow: 0 0 20px var(--accent-green);
  margin: 20px 0;
}

.review-section {
  margin: 30px 0;
  max-height: 400px;
  overflow-y: auto;
  padding: 20px;
  background: var(--bg-panel);
  border-radius: 12px;
}

.review-item {
  margin: 20px 0;
  padding: 16px;
  background: #141938;
  border-radius: 10px;
  border-left: 4px solid;
}

.review-item.correct {
  border-left-color: var(--accent-green);
}

.review-item.incorrect {
  border-left-color: var(--accent-red);
}

.review-question {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-cyan);
  margin-bottom: 8px;
}

.review-answer {
  font-family: "Space Mono", monospace;
  font-size: 14px;
  color: var(--text);
  margin: 6px 0;
}

.review-explanation {
  font-size: 14px;
  color: var(--muted);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #303560;
  line-height: 1.6;
}

.celebration-section {
  margin: 30px 0;
  padding: 20px;
  background: var(--bg-panel);
  border-radius: 12px;
}

.bunny-celebration {
  margin: 12px 0;
  padding: 12px;
  background: #141938;
  border-radius: 8px;
  border-left: 4px solid var(--accent-pink);
  display: flex;
  align-items: center;
  gap: 12px;
}

.bunny-celebration-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

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

.bunny-celebration-message {
  flex: 1;
  color: var(--accent-pink);
  font-style: italic;
}

.gameover-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
}

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

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

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

button.chip {
  background: linear-gradient(135deg, #b794f6, #8b5cf6);
}

/* 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: #5a5f90;
}

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

  .right-panel {
    max-height: 300px;
  }
}

@media (max-width: 768px) {
  .bunnies-grid {
    grid-template-columns: 1fr;
  }

  .question-progress {
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
  }

  .progress-item {
    font-size: 14px;
  }
}
