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

.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 ease;
  align-self: center;
}

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

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

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

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

.game-area {
  background: var(--bg-panel);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: auto;
  border: 1px solid #303560;
  padding: 24px;
}

.game-container {
  max-width: 900px;
  margin: 0 auto;
}

.right-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Status Box */
.status-box {
  background: var(--bg-panel);
  border: 1px solid #303560;
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
  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;
  color: var(--accent-yellow);
}

.status-item .value.time {
  color: var(--accent-green);
}

.status-item .value.time.warning {
  color: var(--accent-red);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Players Box */
.players-box {
  background: var(--bg-panel);
  border: 1px solid #303560;
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
  flex: 1;
  overflow: auto;
}

.players-box h3 {
  margin: 0 0 12px;
  text-align: center;
  color: var(--accent-blue);
}

.players-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: #0d112b;
  border-radius: 8px;
  border: 1px solid #303560;
  transition: all 0.3s ease;
}

.player-item.active {
  border-color: var(--accent-blue);
  background: #1a2547;
  box-shadow: 0 0 12px rgba(111, 168, 255, 0.3);
}

.player-item.completed {
  opacity: 0.6;
}

.player-name {
  font-weight: 700;
  color: var(--text);
}

.player-points {
  font-family: "Space Mono";
  color: var(--accent-green);
  font-weight: 700;
}

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

.history-box h3 {
  margin: 0 0 12px;
  text-align: center;
  color: var(--accent-blue);
}

.history-list {
  margin: 0;
  padding-left: 20px;
  max-height: 200px;
  overflow-y: auto;
  font-family: "Space Mono";
  font-size: 13px;
}

.history-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0;
  padding: 4px 0;
  line-height: 20px;
}

/* Game Content */
.game-content {
  text-align: center;
}

.game-content h2 {
  color: var(--accent-pink);
  font-size: 36px;
  margin-bottom: 12px;
  text-shadow: 0 0 20px rgba(255, 122, 194, 0.4);
}

.instruction {
  color: var(--muted);
  font-size: 18px;
  margin-bottom: 24px;
  line-height: 1.6;
}

.hint {
  color: var(--accent-yellow);
  font-size: 14px;
  font-style: italic;
  margin-bottom: 16px;
}

.game-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  min-height: 300px;
}

.game-type {
  font-size: 48px;
  font-weight: 900;
  color: var(--accent-yellow);
  text-shadow: 0 0 30px rgba(255, 216, 107, 0.5);
}

/* Monte Hall */
.shells-container {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin: 40px 0;
  flex-wrap: wrap;
}

.shell-wrapper {
  cursor: pointer;
}

.shell {
  width: 120px;
  height: 120px;
  background: linear-gradient(135deg, #8b6f47, #d4a574);
  border-radius: 50% 50% 45% 45%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
}

.shell:hover {
  transform: translateY(-8px) scale(1.05);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

.shell.selected {
  border: 4px solid var(--accent-blue);
  box-shadow: 0 0 20px rgba(111, 168, 255, 0.6);
}

.shell.revealed {
  background: linear-gradient(135deg, #4a4f80, #6fa8ff);
  transform: scale(0.95);
}

.monte-message,
.hl-message,
.poker-message,
.calc-message,
.match-message,
.simplify-message,
.bonus-message {
  margin-top: 24px;
  padding: 16px;
  background: #0d112b;
  border-radius: 12px;
  border: 1px solid #303560;
}

.monte-actions,
.hl-actions,
.match-actions,
.simplify-actions {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Higher-Lower */
.cards-container {
  display: flex;
  justify-content: center;
  gap: 60px;
  margin: 40px 0;
  flex-wrap: wrap;
}

.number-card {
  width: 140px;
  height: 200px;
  background: linear-gradient(180deg, #ffffff 0%, #eaf0ff 100%);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 72px;
  font-weight: 900;
  font-family: "Space Mono";
  color: #222;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease;
}

.number-card.hidden {
  background: radial-gradient(circle at 30% 30%, #6fa8ff, #1a1d33);
  color: #fff;
  font-size: 64px;
}

.number-card.flipped {
  animation: flip 0.6s ease;
}

@keyframes flip {
  0% { transform: rotateY(0deg); }
  50% { transform: rotateY(90deg); }
  100% { transform: rotateY(0deg); }
}

/* Poker */
.poker-hand {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 40px 0;
  flex-wrap: wrap;
}

.playing-card {
  width: 100px;
  height: 140px;
  background: linear-gradient(180deg, #ffffff 0%, #eaf0ff 100%);
  border-radius: 12px;
  border: 2px solid #d0d4e6;
  box-shadow: var(--shadow);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px;
  transition: transform 0.3s ease;
}

.playing-card.back {
  background: radial-gradient(circle at 30% 30%, #6fa8ff, #1a1d33);
  color: #fff;
  font-weight: 900;
  font-size: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.playing-card:hover {
  transform: translateY(-4px);
}

.card-rank {
  font-family: "Space Mono";
  font-weight: 700;
  font-size: 24px;
  color: #222;
}

.card-suit {
  font-size: 32px;
}

.card-suit.red {
  color: #e03e3e;
}

.card-suit.black {
  color: #222;
}

.poker-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 500px;
  margin: 0 auto;
}

/* Calculation */
.question-box {
  background: #0d112b;
  border: 1px solid #303560;
  border-radius: 12px;
  padding: 24px;
  margin: 24px 0;
  font-size: 20px;
  line-height: 1.8;
  color: var(--text);
}

.expression {
  font-family: "Space Mono";
  color: var(--accent-yellow);
  font-size: 24px;
  font-weight: 700;
}

.calc-choices {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 500px;
  margin: 24px auto;
}

/* Match Game */
.match-container {
  margin: 24px 0;
}

.match-questions {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.match-item {
  background: #0d112b;
  border: 1px solid #303560;
  border-radius: 12px;
  padding: 16px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  text-align: left;
}

.match-number {
  font-family: "Space Mono";
  color: var(--accent-blue);
  font-weight: 700;
  font-size: 18px;
}

.match-text {
  color: var(--text);
  font-size: 16px;
}

.match-select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #4a4f80;
  background: #1a1d33;
  color: var(--text);
  font-family: "Space Mono";
  font-size: 14px;
  min-width: 120px;
}

.match-result {
  background: #0d112b;
  border: 1px solid #303560;
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0;
  text-align: left;
  font-size: 14px;
  line-height: 1.6;
}

.match-result.correct {
  border-color: var(--accent-green);
  background: rgba(111, 227, 162, 0.1);
}

.match-result.incorrect {
  border-color: var(--accent-red);
  background: rgba(255, 111, 111, 0.1);
}

/* Simplification */
.simplify-input {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 24px 0;
}

.simplify-input input {
  width: 150px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #4a4f80;
  background: #0d112b;
  color: var(--text);
  font-family: "Space Mono";
  font-size: 20px;
  text-align: center;
}

.simplify-input span {
  font-size: 32px;
  font-weight: 700;
  color: var(--muted);
}

/* Bonus Game */
.bowl {
  background: linear-gradient(135deg, #8b6f47, #d4a574);
  border-radius: 50% 50% 45% 45%;
  padding: 30px;
  margin: 24px auto;
  max-width: 600px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  box-shadow: var(--shadow);
  min-height: 300px;
  border: 4px solid #6b5433;
}

.bowl-item {
  font-size: 28px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.bowl-item:hover {
  transform: scale(1.2);
}

.bonus-players {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 24px 0;
}

.bonus-player {
  background: #0d112b;
  border: 1px solid #303560;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
}

.bonus-input {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bonus-input input {
  width: 120px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #4a4f80;
  background: #1a1d33;
  color: var(--text);
  font-family: "Space Mono";
  text-align: center;
}

.submit-bonus {
  padding: 8px 16px;
}

.submitted-mark {
  color: var(--accent-green);
  font-weight: 700;
}

.bonus-result {
  padding: 12px;
  background: #0d112b;
  border: 1px solid #303560;
  border-radius: 8px;
  margin: 8px 0;
}

.bonus-result.winner {
  border-color: var(--accent-yellow);
  background: rgba(255, 216, 107, 0.1);
  box-shadow: 0 0 20px rgba(255, 216, 107, 0.3);
}

/* Buttons */
.chip {
  border: 1px solid #4a4f80;
  background: #2a2d4a;
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  cursor: pointer;
  font-family: "Lexend";
  font-size: 16px;
  transition: all 0.2s ease;
}

.chip:hover {
  background: #4150a6;
  transform: translateY(-2px);
}

.chip:active {
  transform: translateY(0);
}

.chip.large {
  padding: 16px 24px;
  font-size: 18px;
  border-radius: 12px;
}

.choice-btn {
  width: 100%;
}

button.primary {
  background: linear-gradient(45deg, var(--accent-blue), var(--accent-pink));
  border: none;
  color: #fff;
  padding: 14px 32px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 18px;
  cursor: pointer;
  text-shadow: 0 1px 3px #0005;
  transition: transform 0.2s;
  font-family: "Lexend";
  box-shadow: var(--shadow);
}

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

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

/* Messages */
.success {
  color: var(--accent-green);
  font-size: 20px;
  font-weight: 700;
}

.failure {
  color: var(--accent-red);
  font-size: 20px;
  font-weight: 700;
}

.explanation {
  margin-top: 16px;
  padding: 16px;
  background: rgba(111, 168, 255, 0.1);
  border: 1px solid var(--accent-blue);
  border-radius: 8px;
  text-align: left;
  line-height: 1.6;
  color: var(--text);
}

/* 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 {
  width: min(700px, 96vw);
  background: var(--bg-panel);
  border: 1px solid #303560;
  border-radius: 16px;
  padding: 32px;
  color: var(--text);
  box-shadow: var(--shadow);
  max-height: 90vh;
  overflow-y: auto;
}

.overlay .card h2 {
  color: var(--accent-blue);
  margin-top: 0;
  text-align: center;
}

/* Help Overlay */
.card.help {
  width: min(1200px, 98vw);
  max-height: 90vh;
}

.help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 2px solid #303560;
  padding-bottom: 16px;
}

.help-header h2 {
  margin: 0;
  text-align: left;
}

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

.close-btn:hover {
  background: #38406c;
  transform: scale(1.05);
}

.close-btn:active {
  transform: scale(0.95);
}

.help-content {
  line-height: 1.7;
  color: var(--text);
}

.help-content h3 {
  color: var(--accent-pink);
  margin-top: 24px;
  margin-bottom: 12px;
  font-size: 22px;
}

.help-content h4 {
  color: var(--accent-yellow);
  margin-top: 16px;
  margin-bottom: 8px;
  font-size: 18px;
}

.help-content p {
  margin: 8px 0;
  color: var(--text);
}

.help-content ul,
.help-content ol {
  margin: 8px 0;
  padding-left: 24px;
}

.help-content li {
  margin: 6px 0;
  color: var(--text);
}

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

.game-rules {
  background: #0d112b;
  border: 1px solid #303560;
  border-radius: 8px;
  padding: 16px;
  margin: 12px 0;
}

.game-rules h4 {
  margin-top: 0;
  color: var(--accent-blue);
}

.game-rules p {
  font-size: 15px;
}

/* Setup */
.card.setup form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card.setup label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text);
  font-weight: 600;
}

.card.setup input,
.card.setup select {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #4a4f80;
  background: #0d112b;
  color: var(--text);
  font-family: "Lexend";
  font-size: 16px;
}

.player-input {
  background: #0d112b;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #303560;
}

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

.winners-display,
.final-scores {
  width: 100%;
}

.player-score,
.final-player {
  background: #0d112b;
  padding: 16px;
  margin: 8px 0;
  border-radius: 8px;
  border: 1px solid #303560;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 18px;
}

.final-player.first {
  border-color: var(--accent-yellow);
  background: rgba(255, 216, 107, 0.1);
  box-shadow: 0 0 20px rgba(255, 216, 107, 0.3);
}

.final-player .rank {
  font-family: "Space Mono";
  color: var(--accent-blue);
  font-weight: 700;
  font-size: 24px;
}

.final-player .name {
  font-weight: 700;
  flex: 1;
  text-align: center;
}

.final-player .points {
  font-family: "Space Mono";
  color: var(--accent-green);
  font-weight: 700;
  font-size: 20px;
}

.bonus-message {
  padding: 16px;
  background: rgba(255, 122, 194, 0.1);
  border: 1px solid var(--accent-pink);
  border-radius: 12px;
}

.celebration-message {
  font-size: 24px;
  color: var(--accent-green);
}

.gameover-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Responsive */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  
  .shells-container {
    gap: 20px;
  }
  
  .shell {
    width: 90px;
    height: 90px;
    font-size: 36px;
  }
  
  .cards-container {
    gap: 30px;
  }
  
  .number-card {
    width: 110px;
    height: 160px;
    font-size: 56px;
  }
  
  .poker-hand {
    gap: 8px;
  }
  
  .playing-card {
    width: 80px;
    height: 112px;
  }
}

