: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: #b47cff;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

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

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

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

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

.score-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-panel);
  padding: 8px 20px;
  border-radius: 12px;
  border: 1px solid #303560;
}

.score-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.score-value {
  font-family: "Space Mono", monospace;
  font-size: 32px;
  font-weight: 700;
  color: var(--accent-yellow);
  text-shadow: 0 0 10px var(--accent-yellow);
}

.subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

/* Main game container */
.game-container {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
  padding: 16px;
  height: calc(100vh - 100px);
}

.game-area {
  background: linear-gradient(180deg, #1a1d33 0%, #0d0f1a 100%);
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid #303560;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 40px;
}

.controls-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Pillars */
.pillars-container {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 20px;
  height: 100%;
  position: relative;
}

.pillar {
  width: 80px;
  background: linear-gradient(180deg, var(--accent-purple), var(--accent-blue));
  border-radius: 8px 8px 0 0;
  border: 3px solid var(--accent-blue);
  box-shadow: 0 4px 20px rgba(111, 168, 255, 0.4);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 10px;
  transition: all 0.3s ease;
}

.pillar-label {
  font-family: "Space Mono", monospace;
  font-weight: 700;
  font-size: 18px;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.carrots {
  position: absolute;
  top: -30px;
  font-size: 24px;
  animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* Characters */
.bunny,
.policewoman {
  position: absolute;
  font-size: 48px;
  transition: all 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 10;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.bunny.hopping {
  animation: hop 0.5s ease-in-out;
}

@keyframes hop {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-30px) scale(1.1); }
}

.bunny.munching {
  animation: munch 0.8s ease-in-out 3;
}

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

.policewoman.climbing {
  animation: climb 0.8s ease-in-out;
}

@keyframes climb {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* Speech bubble */
.speech-bubble {
  position: absolute;
  background: white;
  color: #222;
  padding: 16px 20px;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  max-width: 300px;
  z-index: 20;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  animation: popIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid white;
}

@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Ladder */
.ladder {
  position: absolute;
  width: 20px;
  background: repeating-linear-gradient(
    180deg,
    var(--accent-yellow) 0px,
    var(--accent-yellow) 3px,
    transparent 3px,
    transparent 15px
  );
  border-left: 3px solid var(--accent-yellow);
  border-right: 3px solid var(--accent-yellow);
  z-index: 5;
  animation: placeLadder 0.5s ease-out;
}

@keyframes placeLadder {
  0% { transform: translateY(-20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

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

.question-text {
  font-family: "Space Mono", monospace;
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-green);
  text-align: center;
  margin-bottom: 16px;
  padding: 12px;
  background: rgba(111, 227, 162, 0.1);
  border-radius: 8px;
}

.answer-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#answerInput {
  height: 52px;
  padding: 0 16px;
  border-radius: 10px;
  border: 2px solid #4a4f80;
  background: linear-gradient(180deg, #141938 0%, #0d112b 100%);
  color: var(--text);
  font-size: 24px;
  font-family: "Space Mono", monospace;
  text-align: center;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5);
  outline: none;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

#answerInput::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

#answerInput:focus {
  border-color: var(--accent-green);
  box-shadow: 0 0 0 3px rgba(111, 227, 162, 0.3), inset 0 2px 6px rgba(0, 0, 0, 0.55);
}

.feedback {
  min-height: 28px;
  text-align: center;
  font-family: "Space Mono", monospace;
  font-size: 16px;
  font-weight: 700;
  margin-top: 8px;
  padding: 8px;
  border-radius: 8px;
}

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

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

/* Leaderboard */
.leaderboard-box {
  background: var(--bg-panel);
  border: 1px solid #303560;
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.leaderboard-box h3 {
  margin: 0 0 12px;
  text-align: center;
  color: var(--accent-pink);
  font-size: 18px;
}

.leaderboard-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  max-height: 300px;
  overflow-y: auto;
}

.leaderboard-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0;
  padding: 10px 12px;
  background: rgba(111, 168, 255, 0.05);
  border-radius: 8px;
  font-family: "Space Mono", monospace;
  font-size: 14px;
  border: 1px solid #303560;
}

.leaderboard-list li:nth-child(1) {
  background: rgba(255, 215, 0, 0.15);
  border-color: var(--accent-yellow);
}

.leaderboard-list li:nth-child(2) {
  background: rgba(192, 192, 192, 0.15);
  border-color: var(--muted);
}

.leaderboard-list li:nth-child(3) {
  background: rgba(205, 127, 50, 0.15);
  border-color: #cd7f32;
}

/* Buttons */
button.primary {
  width: 100%;
  background: linear-gradient(45deg, var(--accent-green), var(--accent-blue));
  border: none;
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 12px rgba(111, 227, 162, 0.3);
}

button.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(111, 227, 162, 0.4);
}

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

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

.chip:hover {
  background: #38406c;
  transform: translateY(-1px);
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(13, 15, 26, 0.95);
  backdrop-filter: blur(8px);
  z-index: 100;
}

.overlay.visible {
  display: grid;
}

.overlay .card {
  width: min(700px, 94vw);
  min-height: 40vh;
  max-height: 90vh;
  background: linear-gradient(180deg, #1a1d33 0%, #0d0f1a 100%);
  border: 2px solid var(--accent-pink);
  border-radius: 20px;
  padding: 32px;
  color: var(--text);
  box-shadow: 0 20px 60px rgba(255, 122, 194, 0.3);
  overflow-y: auto;
}

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

.overlay .card.instructions {
  width: min(900px, 94vw);
  min-height: 60vh;
}

.instructions-text {
  line-height: 1.8;
  font-size: 16px;
}

.instructions-text h3 {
  color: var(--accent-green);
  margin-top: 24px;
  margin-bottom: 12px;
}

.instructions-text ul {
  padding-left: 24px;
}

.instructions-text li {
  margin: 8px 0;
}

.instructions-text .tip {
  background: rgba(111, 227, 162, 0.1);
  padding: 12px;
  border-radius: 8px;
  border-left: 4px solid var(--accent-green);
  margin-top: 20px;
}

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

/* Setup form */
.overlay .card.setup {
  width: min(500px, 94vw);
}

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

.overlay .card.setup label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 600;
  color: var(--accent-blue);
}

.overlay .card.setup input {
  height: 48px;
  padding: 0 16px;
  border-radius: 10px;
  border: 2px solid #4a4f80;
  background: linear-gradient(180deg, #141938 0%, #0d112b 100%);
  color: var(--text);
  font-size: 18px;
  font-family: "Lexend", sans-serif;
  outline: none;
  transition: border-color 0.2s;
}

.overlay .card.setup input:focus {
  border-color: var(--accent-green);
}

.level-preview {
  text-align: center;
  padding: 12px;
  background: rgba(111, 168, 255, 0.1);
  border-radius: 8px;
  font-family: "Space Mono", monospace;
  color: var(--accent-yellow);
}

/* Victory */
.overlay .card.victory {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.victory-actions {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 400px;
}

.victory-actions button {
  flex: 1;
}

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

/* Responsive */
@media (max-width: 900px) {
  .game-container {
    grid-template-columns: 1fr;
    height: auto;
  }
  
  .pillars-container {
    gap: 12px;
  }
  
  .pillar {
    width: 60px;
  }
  
  .bunny,
  .policewoman {
    font-size: 36px;
  }
}

