: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-orange: #ff9b4a;
  --accent-purple: #b78cff;
  --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-purple);
  line-height: 1;
  text-shadow: 0 0 6px #b78cff;
}

.game-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100px;
}

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

.stat-value {
  font-family: "Space Mono", monospace;
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-green);
  text-shadow: 0 0 10px rgba(111, 227, 162, 0.3);
  margin-top: 4px;
}

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

/* Main Game Container */
.game-container {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 20px;
  padding: 20px;
  min-height: calc(100vh - 120px);
}

/* Player Cards */
.player-area,
.agent-area {
  display: flex;
  flex-direction: column;
}

.player-card {
  background: var(--bg-panel);
  border: 2px solid #303560;
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.avatar-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.avatar {
  font-size: 72px;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2a2d4a, #1a1d33);
  border: 3px solid var(--accent-blue);
  border-radius: 50%;
  box-shadow: 0 4px 20px rgba(111, 168, 255, 0.3);
}

.agent-area .avatar {
  border-color: var(--accent-red);
  box-shadow: 0 4px 20px rgba(255, 111, 111, 0.3);
}

.player-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-yellow);
  text-align: center;
}

.current-item-container {
  flex: 1;
  display: flex;
  flex-direction: column;
}

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

.current-item {
  background: linear-gradient(135deg, #141938, #0d112b);
  border: 2px solid #4a4f80;
  border-radius: 12px;
  padding: 20px;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.item-placeholder {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.item-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.item-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-yellow);
  text-align: center;
}

.money-display {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.bills-stack,
.coins-pile {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  align-items: center;
}

.bill {
  width: 60px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  font-family: "Space Mono", monospace;
  border: 2px solid;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Large denomination bills - bigger and more impressive */
.bill-100000 {
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #2c5f2d, #97c4a0, #2c5f2d);
  border-color: #1e4620;
  border-radius: 8px;
  color: #fff;
  font-size: 32px;
  box-shadow: 0 4px 12px rgba(44, 95, 45, 0.6),
    0 0 20px rgba(151, 196, 160, 0.4);
  animation: shimmer 2s infinite;
  cursor: help;
}

.bill-10000 {
  width: 75px;
  height: 35px;
  background: linear-gradient(135deg, #4169e1, #1e90ff, #4169e1);
  border-color: #0047ab;
  color: #fff;
  font-size: 11px;
  box-shadow: 0 4px 10px rgba(65, 105, 225, 0.5),
    0 0 15px rgba(65, 105, 225, 0.3);
  animation: shimmer 2s infinite;
}

.bill-1000 {
  width: 70px;
  height: 32px;
  background: linear-gradient(135deg, #ffa500, #ff8c00, #ffa500);
  border-color: #cc7000;
  color: #fff;
  font-size: 11px;
  box-shadow: 0 4px 8px rgba(255, 165, 0, 0.5), 0 0 12px rgba(255, 165, 0, 0.3);
  animation: shimmer 2.5s infinite;
}

.bill-500 {
  width: 65px;
  height: 30px;
  background: linear-gradient(135deg, #8b008b, #9932cc, #8b008b);
  border-color: #6a0080;
  color: #fff;
  font-size: 11px;
  box-shadow: 0 3px 6px rgba(139, 0, 139, 0.4);
}

@keyframes shimmer {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.2);
  }
}

.bill-100 {
  background: linear-gradient(135deg, #c9a0dc, #9b6db3);
  border-color: #7a4d91;
  color: #fff;
}

.bill-50 {
  background: linear-gradient(135deg, #ff9999, #ff6b6b);
  border-color: #d94444;
  color: #fff;
}

.bill-20 {
  background: linear-gradient(135deg, #90ee90, #5fb85f);
  border-color: #3d8b3d;
  color: #fff;
}

.bill-10 {
  background: linear-gradient(135deg, #ffd700, #ffb700);
  border-color: #d49200;
  color: #000;
}

.bill-5 {
  background: linear-gradient(135deg, #87ceeb, #5ba3c9);
  border-color: #3d7a96;
  color: #fff;
}

.bill-2 {
  background: linear-gradient(135deg, #ffb6c1, #ff85a1);
  border-color: #d65e7f;
  color: #fff;
}

.bill-1 {
  background: linear-gradient(135deg, #d3d3d3, #a8a8a8);
  border-color: #808080;
  color: #000;
}

.coin {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  font-family: "Space Mono", monospace;
  border: 2px solid;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.coin-200 {
  background: linear-gradient(135deg, #ffd700, #b8860b);
  border-color: #8b6914;
  color: #000;
}

.coin-100 {
  background: linear-gradient(135deg, #ffd700, #daa520);
  border-color: #b8860b;
  color: #000;
}

.coin-50 {
  background: linear-gradient(135deg, #e0e0e0, #b0b0b0);
  border-color: #808080;
  color: #000;
}

.coin-25 {
  background: linear-gradient(135deg, #c0c0c0, #909090);
  border-color: #707070;
  color: #000;
}

.coin-10 {
  background: linear-gradient(135deg, #cd7f32, #a0622c);
  border-color: #7d4a1f;
  color: #fff;
}

.coin-5 {
  background: linear-gradient(135deg, #c0c0c0, #a0a0a0);
  border-color: #808080;
  color: #000;
}

.coin-1 {
  background: linear-gradient(135deg, #b87333, #8b5a2b);
  border-color: #654321;
  color: #fff;
}

.item-value {
  font-size: 18px;
  font-weight: 700;
  font-family: "Space Mono", monospace;
  color: var(--accent-green);
  margin-top: 8px;
}

/* Game Board */
.game-board {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
}

.game-message {
  background: var(--bg-panel);
  border: 2px solid var(--accent-purple);
  border-radius: 12px;
  padding: 20px 30px;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-yellow);
  text-align: center;
  box-shadow: 0 4px 20px rgba(183, 140, 255, 0.2);
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.choices-container {
  background: var(--bg-panel);
  border: 2px solid #303560;
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  box-shadow: var(--shadow);
}

.choices-container h3 {
  margin: 0 0 20px;
  text-align: center;
  color: var(--accent-blue);
  font-size: 20px;
}

.choices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  max-width: 800px;
  margin: 0 auto;
}

.choice-card {
  background: linear-gradient(135deg, #141938, #0d112b);
  border: 3px solid #4a4f80;
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-height: 180px;
  position: relative;
}

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

.choice-card.selected {
  border-color: var(--accent-green);
  background: linear-gradient(135deg, #1a3828, #0d1f18);
}

.choice-card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Calculation Prompt */
.calculation-prompt {
  background: var(--bg-panel);
  border: 2px solid var(--accent-orange);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 4px 20px rgba(255, 155, 74, 0.3);
}

.calculation-prompt p {
  text-align: center;
  margin: 0 0 16px;
  font-size: 16px;
  color: var(--text);
}

.calc-formula {
  font-family: "Space Mono", monospace;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-yellow);
  background: rgba(255, 216, 107, 0.1);
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.calc-form {
  display: flex;
  gap: 12px;
  align-items: center;
}

.calc-form input {
  flex: 1;
  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: "Space Mono", monospace;
  text-align: center;
  outline: none;
  transition: border-color 0.2s ease;
}

.calc-form input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(111, 168, 255, 0.2);
}

.calc-form button {
  height: 48px;
  padding: 0 24px;
}

.calc-feedback {
  margin-top: 12px;
  text-align: center;
  font-weight: 700;
  font-size: 16px;
  min-height: 24px;
}

.calc-feedback.correct {
  color: var(--accent-green);
}

.calc-feedback.incorrect {
  color: var(--accent-red);
}

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

button.primary {
  background: linear-gradient(45deg, var(--accent-purple), var(--accent-pink));
  border: none;
  color: #fff;
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  text-shadow: 0 1px 3px #0005;
  transition: transform 0.2s;
  font-family: inherit;
}

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

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

/* 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 {
  width: min(900px, 96vw);
  min-height: 40vh;
  max-height: 90vh;
  background: linear-gradient(135deg, #1a1d33 0%, #0d0f1a 100%);
  border: 2px solid #303560;
  border-radius: 20px;
  padding: 32px;
  color: #fff;
  box-shadow: var(--shadow);
  overflow-y: auto;
}

.overlay .card h2 {
  color: var(--accent-purple);
  text-align: center;
  margin-bottom: 20px;
  font-size: 28px;
  text-shadow: 0 0 10px rgba(183, 140, 255, 0.3);
}

/* Instructions */
.overlay .card.instructions {
  min-height: 60vh;
}

.instructions-text {
  line-height: 1.7;
  font-size: 15px;
}

.instructions-text h3 {
  color: var(--accent-yellow);
  margin: 20px 0 10px;
  font-size: 18px;
}

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

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

.instructions-text strong {
  color: var(--accent-green);
}

.difficulty-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-family: "Space Mono", monospace;
  font-size: 13px;
}

.difficulty-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #303560;
  text-align: left;
}

.difficulty-table tr:hover {
  background: rgba(111, 168, 255, 0.05);
}

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

.countdown span {
  font-weight: 700;
  font-size: 24px;
}

/* Setup Form */
.setup label {
  display: block;
  margin: 16px 0;
  font-size: 15px;
}

.setup input,
.setup select {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #4a4f80;
  background: linear-gradient(180deg, #141938 0%, #0d112b 100%);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  outline: none;
}

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

/* Game Over */
.overlay .card.gameover {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.gameover-message {
  font-size: 20px;
  color: var(--accent-yellow);
  margin: 16px 0;
}

.gameover-stats {
  background: rgba(26, 29, 51, 0.5);
  border: 1px solid #303560;
  border-radius: 12px;
  padding: 20px;
  font-family: "Space Mono", monospace;
  font-size: 16px;
  line-height: 2;
}

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

.gameover-actions button {
  min-width: 180px;
}

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

  .player-area,
  .agent-area {
    max-width: 400px;
    margin: 0 auto;
    width: 100%;
  }

  .game-board {
    order: -1;
  }
}

@media (max-width: 600px) {
  .limit-badge,
  .game-title {
    font-size: 24px;
  }

  .game-stats {
    gap: 12px;
  }

  .stat-value {
    font-size: 18px;
  }

  .avatar {
    font-size: 56px;
    width: 90px;
    height: 90px;
  }

  .choices-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
  }
}
