: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;
  --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-blue);
  line-height: 1;
  text-shadow: 0 0 6px #1a1d33;
}
.bunny-digits {
  font-family: "Space Mono", monospace;
  font-size: 18px;
  color: var(--accent-green);
  text-shadow: 0 0 10px var(--accent-green);
  white-space: nowrap;
}
.subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 16px;
  padding: 16px;
  height: calc(100vh - 85px);
}
.left-panel {
  background: #000;
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: auto;
  border: 1px solid #303560;
  position: relative;
}
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Number line */
.numberline-wrap {
  position: absolute;
  inset: 0;
  padding: 16px;
}
#numberLine {
  width: 100%;
  height: 100%;
  display: block;
}

/* Panels */
.status-box,
.controls-box,
.explain,
.leaderboard-box,
.history-box {
  background: var(--bg-panel);
  border: 1px solid #303560;
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.status-box {
  display: flex;
  justify-content: space-around;
  text-align: center;
}
.status-item .label {
  font-size: 14px;
  color: var(--muted);
}
.status-item .value {
  display: block;
  font-size: 28px;
  font-weight: 700;
  font-family: "Space Mono";
  margin-top: 4px;
}
#roundScoreDisplay {
  color: var(--accent-yellow);
}
#totalScoreDisplay {
  color: var(--accent-green);
}

.controls-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.range-line {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}
.question {
  text-align: center;
  font-weight: 700;
  color: var(--accent-blue);
}
.guess-form {
  display: flex;
  gap: 8px;
}
.guess-form input {
  flex: 1;
  height: 48px;
  font-size: 18px;
  text-align: center;
  background: var(--bg-dark);
  border: 1px solid #4a4f80;
  color: var(--text);
  border-radius: 8px;
  font-family: "Space Mono", monospace;
}
.feedback {
  min-height: 22px;
  text-align: center;
  color: var(--accent-pink);
  font-family: "Space Mono";
}

button.primary {
  width: 100%;
  background: linear-gradient(45deg, var(--accent-blue), var(--accent-pink));
  border: none;
  color: #fff;
  padding: 12px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  text-shadow: 0 1px 3px #0005;
  transition: transform 0.2s;
}
button.primary:hover {
  transform: scale(1.02);
}
button.secondary {
  width: 100%;
  background: #2a2d4a;
  color: #fff;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #4a4f80;
  cursor: pointer;
}
button.secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.explain {
  height: 140px;
  overflow: auto;
  font-size: 14px;
  line-height: 1.5;
}
.explain .note {
  color: var(--muted);
}

/* Leaderboard */
.leaderboard-box h3 {
  margin: 0 0 6px;
  text-align: center;
  color: var(--accent-pink);
}
.lb-controls {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}
.leaderboard {
  margin: 0;
  padding-left: 20px;
  max-height: 160px;
  overflow: auto;
}
.leaderboard li {
  margin: 4px 0;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}
.leaderboard li.me {
  color: var(--accent-green);
  font-weight: 700;
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: #0d0f1acc;
  backdrop-filter: blur(8px);
  z-index: 100;
}
.overlay.visible {
  display: grid;
}
.card {
  background: var(--bg-panel);
  border-radius: 16px;
  padding: 24px;
  width: min(480px, 92vw);
  text-align: center;
  box-shadow: var(--shadow);
}
.card h2 {
  margin-top: 0;
}
.instructions-text {
  text-align: left;
  font-size: 14px;
  line-height: 1.5;
  max-height: 45vh;
  overflow: auto;
}
.countdown {
  margin-top: 10px;
  color: var(--accent-yellow);
  font-family: "Space Mono";
}
.card label {
  display: block;
  text-align: left;
  margin-bottom: 12px;
}
.card input,
.card select {
  width: 100%;
  padding: 10px;
  margin-top: 4px;
  border-radius: 8px;
  background: var(--bg-dark);
  color: var(--text);
  border: 1px solid #4a4f80;
}

/* Game over */
.final-score-display {
  margin: 10px 0;
  font-size: 18px;
}

/* History */
.history-box h3 {
  margin: 0 0 6px;
  text-align: center;
  color: var(--accent-blue);
}
.history-list {
  margin: 0;
  padding-left: 20px;
  height: 68px;
  max-height: 68px;
  overflow-y: auto;
  overflow-x: hidden;
}
.history-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 2px 0;
  padding: 4px 0;
  line-height: 20px;
  font-family: "Space Mono";
  font-size: 13px;
}
.history-list {
  margin: 0;
  padding-left: 20px;
  height: 68px;
  max-height: 68px;
  overflow-y: auto;
  overflow-x: hidden;
}
.history-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 2px 0;
  padding: 4px 0;
  line-height: 20px;
  font-family: "Space Mono";
  font-size: 13px;
}
.history-list li .tag {
  color: var(--muted);
}
.history-list li.good {
  color: var(--accent-green);
}
.history-list li.bad {
  color: var(--accent-yellow);
}

/* Number line styles via SVG classes */
.tick text {
  fill: var(--muted);
  font-family: "Space Mono";
  font-size: 12px;
}
.axis path,
.axis line {
  stroke: #4a4f80;
}
.range-fill {
  fill: url(#rangeGrad);
  opacity: 0.6;
}
.excluded {
  fill: #2a2d4a;
  opacity: 0.8;
}
.guess-marker {
  fill: none;
  stroke: var(--accent-yellow);
  stroke-width: 2;
}
.guess-label {
  fill: var(--text);
  font-family: "Space Mono";
  font-size: 12px;
}
.target-hint {
  stroke: var(--accent-pink);
  stroke-dasharray: 4 4;
}

@media (max-width: 760px) {
  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  body {
    overflow: auto;
  }
}
