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

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: 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;
  padding-bottom: 20px;
}

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

.help-btn {
  margin-left: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #4a4f80;
  background: #2a2d4a;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

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

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

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

/* Calculator */
.calculator {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(26, 29, 51, 0.95);
  border: 1px solid #303560;
  border-radius: 14px;
  padding: 12px;
  box-shadow: var(--shadow);
  width: 280px;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.calc-display {
  width: 100%;
  height: 45px;
  background: linear-gradient(180deg, #141938 0%, #0d112b 100%);
  border: 1px solid #4a4f80;
  border-radius: 8px;
  color: var(--accent-yellow);
  font-family: "Space Mono", monospace;
  font-size: 18px;
  font-weight: 700;
  text-align: right;
  padding: 0 12px;
  margin-bottom: 8px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5);
}

.calc-buttons {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.calc-btn {
  height: 36px;
  border: 1px solid #4a4f80;
  border-radius: 6px;
  background: #2a2d4a;
  color: var(--text);
  font-family: "Space Mono", monospace;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.calc-btn:hover {
  background: #38406c;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(111, 168, 255, 0.3);
}

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

.calc-btn.op {
  background: linear-gradient(135deg, #4a4f80, #2a2d4a);
  color: var(--accent-blue);
}

.calc-btn.fn {
  background: linear-gradient(135deg, #5a3f80, #2a2d4a);
  color: var(--accent-purple);
  font-size: 11px;
}

.calc-btn.clear {
  background: linear-gradient(135deg, #804a4a, #4a2d2d);
  color: var(--accent-red);
}

.calc-btn.equals {
  background: linear-gradient(135deg, var(--accent-green), #2d6f4a);
  color: #fff;
  font-size: 16px;
}

/* Activity Log Panel (in bunny arena) */
.activity-log-panel {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(26, 29, 51, 0.95);
  border: 1px solid #303560;
  border-radius: 14px;
  box-shadow: var(--shadow);
  width: 320px;
  max-height: 400px;
  z-index: 10;
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  transition: max-height 0.3s ease;
}

.activity-log-toggle {
  background: transparent;
  border: none;
  color: var(--accent-blue);
  padding: 12px;
  font-family: "Lexend", sans-serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  text-align: left;
  transition: color 0.2s ease;
}

.activity-log-toggle:hover {
  color: var(--accent-pink);
}

.toggle-icon {
  font-size: 12px;
  transition: transform 0.3s ease;
}

.activity-log-toggle.open .toggle-icon {
  transform: rotate(180deg);
}

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

.activity-log {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  font-family: "Space Mono", monospace;
  font-size: 11px;
  line-height: 1.6;
  max-height: 350px;
  padding: 0 12px 12px 12px;
  transition: max-height 0.3s ease, padding 0.3s ease;
}

.activity-log.collapsed {
  max-height: 0;
  padding: 0 12px;
  overflow: hidden;
}

.log-entry {
  padding: 6px;
  margin: 4px 0;
  border-left: 2px solid #4a4f80;
  padding-left: 8px;
  color: var(--muted);
}

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

/* Game Layout */
.game-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
  padding: 16px;
  max-width: 1600px;
  margin: 0 auto;
  min-height: calc(100vh - 130px);
}

/* Stats Panel */
.stats-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--bg-panel);
  border: 1px solid #303560;
  border-radius: 14px;
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-label {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 8px;
}

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

#investmentDisplay {
  font-size: 28px;
  line-height: 1.3;
}

/* Bunny Arena */
.bunny-arena {
  grid-column: 1;
  grid-row: 2;
  background: linear-gradient(180deg, #000 0%, #0d0f1a 100%);
  border: 1px solid #303560;
  border-radius: 16px;
  min-height: 500px;
  padding: 32px;
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 32px;
  position: relative;
  overflow: hidden;
}

/* Hide bunny arena when setup section is visible */
.bunny-arena:has(+ * #setupSection:not(.hidden)),
body:has(#setupSection:not(.hidden)) .bunny-arena {
  display: none;
}

/* Bunny */
.bunny {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.5s ease;
}

.bunny-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.bunny-sprite {
  font-size: 33px;
  animation: hop 1.2s ease-in-out infinite;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.5));
  transition: font-size 0.5s ease;
}

.bunny.dead .bunny-sprite {
  animation: none;
  transform: rotate(90deg);
  opacity: 0.5;
  filter: grayscale(100%);
}

.bunny-weight {
  margin-top: 8px;
  font-family: "Space Mono", monospace;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-green);
  text-shadow: 0 0 8px var(--accent-green);
  background: rgba(26, 29, 51, 0.8);
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--accent-green);
}

.bunny.dead .bunny-weight {
  color: var(--accent-red);
  border-color: var(--accent-red);
  text-shadow: none;
}

@keyframes hop {
  0%,
  100% {
    transform: translateY(0) scaleY(1);
  }
  15% {
    transform: translateY(-20px) scaleY(1.1);
  }
  30% {
    transform: translateY(0) scaleY(0.9);
  }
  45% {
    transform: translateY(-10px) scaleY(1.05);
  }
  60% {
    transform: translateY(0) scaleY(1);
  }
}

/* Explosion effect */
.explosion {
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    var(--accent-yellow),
    var(--accent-red),
    transparent
  );
  animation: explode 1s ease-out forwards;
  pointer-events: none;
  z-index: 100;
}

.mushroom-cloud {
  position: absolute;
  width: 150px;
  height: 200px;
  pointer-events: none;
  z-index: 101;
  animation: mushroomRise 2s ease-out forwards;
}

.mushroom-stem {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 100px;
  background: linear-gradient(to top, #ff6b35, #ff8c42, #ffa552);
  border-radius: 20px;
  animation: stemGrow 0.8s ease-out forwards;
}

.mushroom-cap {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 120px;
  background: radial-gradient(circle at 50% 70%, #ff4500, #ff6347, #ff7f50);
  border-radius: 50%;
  animation: capExpand 1s ease-out 0.3s forwards;
  transform-origin: bottom center;
  opacity: 0;
  box-shadow: 0 0 40px rgba(255, 69, 0, 0.8);
}

@keyframes mushroomRise {
  0% {
    transform: translateY(0) scale(0.5);
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  100% {
    transform: translateY(-150px) scale(1);
    opacity: 0;
  }
}

@keyframes stemGrow {
  0% {
    height: 0;
    opacity: 1;
  }
  100% {
    height: 100px;
    opacity: 1;
  }
}

@keyframes capExpand {
  0% {
    transform: translateX(-50%) scale(0);
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: translateX(-50%) scale(1);
    opacity: 1;
  }
}

@keyframes explode {
  0% {
    transform: scale(0);
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
  100% {
    transform: scale(3);
    opacity: 0;
  }
}

.bunny-part {
  position: absolute;
  font-size: 40px;
  animation: flyAway 1.5s ease-out forwards;
  z-index: 99;
}

@keyframes flyAway {
  0% {
    transform: translate(0, 0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) rotate(var(--rot));
    opacity: 0;
  }
}

/* Control Panels */
.controls-panel {
  grid-column: 2;
  grid-row: 2;
  background: var(--bg-panel);
  border: 1px solid #303560;
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
  max-height: 600px;
  overflow-y: auto;
}

/* Center the controls panel when setup section is visible */
.controls-panel:has(#setupSection:not(.hidden)) {
  grid-column: 1 / -1;
  grid-row: 2;
  max-width: 500px;
  width: 100%;
  margin: 0 auto;
  align-self: center;
  justify-self: center;
}

.game-message {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-pink);
  margin-bottom: 20px;
  padding: 12px;
  background: rgba(255, 122, 194, 0.1);
  border-radius: 8px;
  border: 1px solid rgba(255, 122, 194, 0.3);
}

.control-section {
  margin-bottom: 20px;
}

.control-section h3 {
  color: var(--accent-blue);
  margin: 0 0 16px;
  text-align: center;
}

.control-section label {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
}

.control-section input,
.control-section select {
  width: 100%;
  height: 44px;
  margin-top: 6px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid #4a4f80;
  background: linear-gradient(180deg, #141938 0%, #0d112b 100%);
  color: var(--text);
  font-size: 16px;
  font-family: "Space Mono", monospace;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5);
  transition: border-color 0.2s;
}

.control-section input:focus,
.control-section select:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(111, 168, 255, 0.2);
}

.hidden {
  display: none !important;
}

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

button.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(111, 168, 255, 0.6);
}

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

.button-group {
  display: flex;
  gap: 8px;
}

/* Investment Choices */
.investment-option {
  background: rgba(111, 168, 255, 0.1);
  border: 2px solid #4a4f80;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.investment-option:hover {
  border-color: var(--accent-blue);
  background: rgba(111, 168, 255, 0.2);
  transform: translateX(4px);
}

.investment-option.selected {
  border-color: var(--accent-green);
  background: rgba(111, 227, 162, 0.2);
  box-shadow: 0 0 12px rgba(111, 227, 162, 0.4);
}

.investment-title {
  font-weight: 700;
  color: var(--accent-blue);
  margin-bottom: 6px;
}

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

/* Work Question */
.work-question {
  background: rgba(255, 216, 107, 0.1);
  border: 1px solid rgba(255, 216, 107, 0.3);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  font-family: "Space Mono", monospace;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

/* Month Summary */
.month-summary {
  background: rgba(111, 168, 255, 0.1);
  border: 1px solid #4a4f80;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  font-family: "Space Mono", monospace;
  font-size: 14px;
  line-height: 1.8;
}

.month-summary .event {
  margin: 6px 0;
  padding: 6px;
  border-left: 3px solid var(--accent-blue);
  padding-left: 12px;
}

.month-summary .event.good {
  border-left-color: var(--accent-green);
  color: var(--accent-green);
}

.month-summary .event.bad {
  border-left-color: var(--accent-red);
  color: var(--accent-red);
}

.month-summary .event.neutral {
  border-left-color: var(--accent-yellow);
  color: var(--accent-yellow);
}

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

.overlay.visible {
  display: grid;
}

.overlay .card {
  width: min(900px, 96vw);
  max-height: 90vh;
  background: var(--bg-panel);
  border: 1px solid #303560;
  border-radius: 16px;
  padding: 32px;
  color: var(--text);
  box-shadow: var(--shadow);
  overflow-y: auto;
}

.overlay .card.help {
  width: min(1200px, 98vw);
}

.overlay .card.gameover {
  text-align: center;
}

.help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.help-header h2 {
  color: var(--accent-blue);
  margin: 0;
}

.close-btn {
  background: #2a2d4a;
  border: 1px solid #4a4f80;
  color: #fff;
  border-radius: 8px;
  font-size: 24px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  transition: all 0.2s;
}

.close-btn:hover {
  background: #38406c;
  transform: rotate(90deg);
}

.help-content h3 {
  color: var(--accent-pink);
  margin-top: 24px;
}

.help-content ul,
.help-content p {
  color: var(--muted);
  line-height: 1.8;
}

.help-content ul {
  margin: 12px 0;
}

.help-content strong {
  color: var(--text);
}

/* Game Over */
.final-stats {
  background: rgba(111, 168, 255, 0.1);
  border: 1px solid #4a4f80;
  border-radius: 12px;
  padding: 24px;
  margin: 24px 0;
}

.final-stat {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid #303560;
  font-family: "Space Mono", monospace;
}

.final-stat:last-child {
  border-bottom: none;
}

.final-stat .label {
  color: var(--muted);
}

.final-stat .value {
  color: var(--accent-yellow);
  font-weight: 700;
  font-size: 20px;
}

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

  .stats-panel {
    grid-column: 1;
  }

  .bunny-arena {
    grid-column: 1;
  }

  .controls-panel {
    grid-column: 1;
    grid-row: auto;
  }
}

@media (max-width: 600px) {
  .activity-log-panel {
    width: 280px;
    max-height: 320px;
    top: 8px;
    left: 8px;
  }

  .activity-log-toggle {
    font-size: 14px;
    padding: 8px;
  }

  .activity-log {
    font-size: 10px;
    max-height: 270px;
  }

  .calculator {
    width: 240px;
    top: 8px;
    right: 8px;
    padding: 8px;
  }

  .calc-display {
    height: 38px;
    font-size: 16px;
    padding: 0 8px;
  }

  .calc-buttons {
    grid-template-columns: repeat(5, 1fr);
    gap: 3px;
  }

  .calc-btn {
    height: 32px;
    font-size: 11px;
  }

  .calc-btn.fn {
    font-size: 9px;
  }

  .calc-btn.equals {
    font-size: 14px;
  }

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

  .tagline {
    font-size: 14px;
  }
}

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

::-webkit-scrollbar-track {
  background: var(--bg-dark);
  border-radius: 4px;
}

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

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-blue);
}
