: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;
}
.help-btn:hover {
  background: #38406c;
}
.help-btn:active {
  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;
}
.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 420px;
  gap: 16px;
  padding: 16px;
  height: calc(100vh - 85px);
}
.table {
  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;
}

/* Arena */
.arena {
  position: absolute;
  inset: 0;
  padding: 16px;
}
.center-area {
  position: absolute;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%);
  display: grid;
  gap: 10px;
  justify-items: center;
}
.pile-wrap {
  display: grid;
  grid-auto-flow: column;
  gap: 16px;
  align-items: center;
}
.pile {
  width: 100px;
  height: 140px;
  border-radius: 10px;
  background: #111429;
  border: 2px solid #4a4f80;
  box-shadow: var(--shadow);
  position: relative;
}
.pile.draw::after {
  content: "Draw";
  position: absolute;
  inset: auto 0 8px 0;
  text-align: center;
  color: var(--muted);
  font-family: "Space Mono";
  font-size: 12px;
}
.pile.play::after {
  content: "Play";
  position: absolute;
  inset: auto 0 8px 0;
  text-align: center;
  color: var(--muted);
  font-family: "Space Mono";
  font-size: 12px;
}
.deck-count {
  position: absolute;
  top: 6px;
  right: 8px;
  background: #2a2d4a;
  color: #fff;
  font-family: "Space Mono";
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid #4a4f80;
}

.total-box {
  background: var(--bg-panel);
  border: 1px solid #303560;
  border-radius: 12px;
  padding: 10px 14px;
  text-align: center;
  box-shadow: var(--shadow);
}
.total-label { color: var(--muted); font-size: 12px; }
.total-value { font-family: "Space Mono"; font-size: 38px; font-weight: 700; color: var(--accent-yellow); }
.equation { font-family: "Space Mono"; color: var(--text); font-size: 14px; min-height: 20px; }
.flow-badge { margin-top: 6px; color: var(--accent-pink); font-family: "Space Mono"; }
.flow-badge.hidden { display: none; }

/* Players ring */
.players-ring { position: absolute; inset: 0; }
.player {
  position: absolute;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  justify-items: start;
  gap: 6px 10px;
}
.player .avatar { grid-column: 1; grid-row: 1; }
.player .hand { grid-column: 2; grid-row: 1; min-height: 104px; }
.player .name { grid-column: 1 / span 2; grid-row: 2; justify-self: center; }
.player .points { grid-column: 1 / span 2; grid-row: 3; justify-self: center; font-family: "Space Mono"; color: var(--accent-green); }

.avatar {
  width: 86px; height: 86px; border-radius: 50%; border: 3px solid #4a4f80; background: #111429; box-shadow: var(--shadow); background-size: cover; background-position: center;
}
.avatar.human { background-image: url('./assets/avatars/human.svg'), radial-gradient(circle at 30% 30%, #d1d1ff, #4747a3); }
.avatar.female { background-image: url('./assets/avatars/human.svg'), radial-gradient(circle at 30% 30%, #ff9bd8, #7b2e6f); }
.avatar.male { background-image: url('./assets/avatars/human.svg'), radial-gradient(circle at 30% 30%, #7bd0ff, #1e4d7b); }
.avatar.robot { background-image: url('./assets/avatars/robot.svg'), radial-gradient(circle at 30% 30%, #b8e1ff, #3c627a); }
.avatar.bunny { background-image: url('./assets/avatars/bunny.svg'), radial-gradient(circle at 30% 30%, #ffd6e8, #b35d8a); }
.avatar.wizard { background-image: url('./assets/avatars/wizard.svg'), radial-gradient(circle at 30% 30%, #e6d5ff, #6a3fb3); }

/* Cards */
.hand { display: grid; grid-auto-flow: column; gap: 8px; min-height: 120px; }
.card { width: 72px; height: 102px; border-radius: 12px; background: linear-gradient(180deg, #ffffff 0%, #eaf0ff 100%); color: #222; border: 2px solid #d0d4e6; box-shadow: var(--shadow); position: relative; cursor: pointer; transition: transform 0.15s ease, box-shadow 0.15s ease; }
.card:hover { transform: translateY(-4px); box-shadow: 0 12px 36px rgba(0,0,0,0.45); }
.card .rank { position: absolute; top: 8px; left: 10px; font-family: "Space Mono"; font-weight: 700; }
.card .suit { position: absolute; bottom: 8px; right: 10px; font-size: 18px; }
.card.back { background: radial-gradient(circle at 30% 30%, #6fa8ff, #1a1d33); border-color: #6fa8ff; color: #fff; display: grid; place-items: center; font-weight: 900; letter-spacing: 0.5px; font-size: 12px; }
.card.joker { outline: 3px dashed var(--accent-pink); }

/* AI animations */
.avatar.ai-thinking { animation: pulse 1.2s ease-in-out infinite; box-shadow: 0 0 0 0 rgba(111,168,255,0.55); }
@keyframes pulse { 0%{ box-shadow: 0 0 0 0 rgba(111,168,255,0.55);} 70%{ box-shadow: 0 0 0 12px rgba(111,168,255,0);} 100%{ box-shadow: 0 0 0 0 rgba(111,168,255,0);} }
.card.ai-playing { animation: lift 0.6s ease-out forwards; }
@keyframes lift { 0% { transform: translateY(0) scale(1); box-shadow: var(--shadow);} 100% { transform: translateY(-8px) scale(1.02); box-shadow: 0 12px 36px rgba(0,0,0,0.5);} }
.drop-in { animation: drop-in 0.4s ease-out; }
@keyframes drop-in { from { transform: translateY(-10px) scale(0.96); opacity: 0.8; } to { transform: translateY(0) scale(1); opacity: 1; } }

/* Panels */
.status-box, .controls-box, .explain, .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; }
.controls-box { display: flex; flex-direction: column; gap: 10px; }
.question { text-align: center; font-weight: 700; color: var(--accent-blue); }
.play-prompt { text-align: center; color: var(--muted); font-size: 14px; }
.chip { border: 1px solid #4a4f80; background: #2a2d4a; color: #fff; padding: 6px 10px; border-radius: 999px; margin-right: 6px; cursor: pointer; }
.chip.active { background: #4150a6; }
.hidden { display: none !important; }
.feedback { min-height: 22px; text-align: center; color: var(--accent-pink); font-family: "Space Mono"; }
.choice-buttons { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }

/* Enter new total */
.guess-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
#totalInput { height: 48px; padding: 0 12px; border-radius: 10px; border: 1px solid #4a4f80; background: linear-gradient(180deg, #141938 0%, #0d112b 100%); color: var(--text); font-size: 18px; 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; }
#totalInput::placeholder { color: var(--muted); opacity: 0.85; }
#totalInput:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 3px rgba(111,168,255,0.2), inset 0 2px 6px rgba(0,0,0,0.55); }
.guess-form .primary { width: auto; height: 48px; padding: 0 16px; }

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

.explain { height: 160px; overflow: auto; font-size: 14px; line-height: 1.5; }
.explain .note { color: var(--muted); }
.history-box h3 { margin: 0 0 6px; text-align: center; color: var(--accent-blue); }
.history-list { margin: 0; padding-left: 20px; height: 120px; max-height: 120px; 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); }

/* 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(1100px, 96vw); min-height: 40vh; max-height: 90vh; background: #000; border: 1px solid #000; padding: 28px; color: #fff; box-shadow: var(--shadow); overflow-y: auto; }
.overlay .card.instructions { min-height: 60vh; }
.overlay .card.gameover { text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; overflow-y: visible; }
.overlay .card.help { width: min(1400px, 98vw); min-height: 70vh; max-height: 90vh; }
.close-btn { background: #2a2d4a; border: 1px solid #4a4f80; color: #fff; border-radius: 8px; font-size: 18px; width: 36px; height: 36px; cursor: pointer; }

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


