/* ─── Design Tokens ─────────────────────────────────────────────────────── */
:root {
  --bg-color: #0f1117;
  --surface: #1a1d27;
  --surface-alt: #22263a;
  --text-primary: #e8eaf0;
  --text-secondary: #9ca3b4;
  --accent-gold: #fbbf24;
  --accent-amber: #f59e0b;
  --p1-color: #22c55e;
  --p1-dark: #15803d;
  --p2-color: #ef4444;
  --p2-dark: #b91c1c;
  --glass-bg: rgba(26, 29, 39, 0.75);
  --glass-border: rgba(255, 255, 255, 0.08);
  --shadow-heavy: 0 20px 50px rgba(0, 0, 0, 0.5);
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: linear-gradient(135deg, #0f1117 0%, #1a1030 50%, #0f1117 100%);
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── App Container ─────────────────────────────────────────────────────── */
.app {
  margin: 1.5rem;
  padding: 2rem;
  max-width: 1100px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.app__header {
  text-align: center;
}

.app__header h1 {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--p1-color), var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.25rem;
}

.app__header p {
  font-size: 1rem;
  color: var(--text-secondary);
}

/* ─── Game Layout ───────────────────────────────────────────────────────── */
.game-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  width: 100%;
  justify-content: center;
}

/* ─── Canvas ────────────────────────────────────────────────────────────── */
.canvas-wrap {
  position: relative;
  border-radius: 50%;
  box-shadow: 0 0 60px rgba(34, 197, 94, 0.08), var(--shadow-heavy);
}

canvas {
  display: block;
  border-radius: 50%;
  cursor: pointer;
}

/* ─── Scores Row ────────────────────────────────────────────────────────── */
.scores-row {
  display: flex;
  gap: 1rem;
}

.score-card {
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 0.6rem 1.5rem;
  text-align: center;
  min-width: 140px;
}

.score-card--p1 .score-value { color: var(--p1-color); }
.score-card--p2 .score-value { color: var(--p2-color); }

.score-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.2rem;
}

.score-value {
  font-size: 1.4rem;
  font-weight: 700;
}

/* ─── Dashboard ─────────────────────────────────────────────────────────── */
.dashboard {
  width: 260px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--shadow-heavy);
}

.dashboard h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-gold);
  border-bottom: 2px solid var(--accent-amber);
  padding-bottom: 0.4rem;
  margin: 0;
}

.chance-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.chance-value {
  font-weight: 700;
  color: var(--text-primary);
}

/* ─── History Panel ─────────────────────────────────────────────────────── */
.history-panel {
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  max-height: 160px;
  overflow-y: auto;
}

.history-panel h3 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-list {
  list-style: none;
  font-size: 0.8rem;
}

.history-list li {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-secondary);
}

/* ─── Controls ──────────────────────────────────────────────────────────── */
.controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.btn {
  width: 100%;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--p1-color), #16a34a);
  color: #fff;
}

.btn-primary:hover { filter: brightness(1.15); transform: translateY(-1px); }

.btn-secondary {
  background: var(--surface-alt);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
}

.btn-secondary:hover { background: #2d3148; transform: translateY(-1px); }

.btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none !important;
  filter: none !important;
}

.status-msg {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent-gold);
  text-align: center;
  margin: 0;
}

/* ─── Modal Overlay ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: modal-fade-in 0.3s ease;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  text-align: center;
  min-width: 340px;
  max-width: 420px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  animation: modal-pop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modal-pop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-content h2 {
  font-size: 1.8rem;
  margin-bottom: 0.75rem;
}

.modal-content p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.modal-content .subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

/* ─── Form ──────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 1rem;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
  font-weight: 600;
}

.form-group input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: var(--surface-alt);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--p1-color);
}

.modal-btn {
  display: block;
  width: 100%;
  padding: 0.8rem;
  margin-top: 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  background: linear-gradient(135deg, var(--p1-color), #16a34a);
  color: #fff;
}

.modal-btn:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

/* ─── Victory Styles ────────────────────────────────────────────────────── */
.victory-title--win { color: var(--p1-color); }
.victory-title--lose { color: var(--p2-color); }

/* ─── Chance Bubble ─────────────────────────────────────────────────────── */
.chance-bubble {
  position: fixed;
  background: var(--surface);
  border: 2px solid var(--accent-gold);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  z-index: 500;
  pointer-events: none;
  min-width: 130px;
  text-align: center;
  animation: bubble-in 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.chance-bubble::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -8px;
  border-width: 8px;
  border-style: solid;
  border-color: var(--accent-gold) transparent transparent transparent;
}

@keyframes bubble-in {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.chance-bubble h3 {
  margin: 0;
  color: var(--accent-gold);
  font-size: 1rem;
}

.chance-bubble p {
  margin: 3px 0 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
}

/* ─── Balloons ──────────────────────────────────────────────────────────── */
.balloons {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 999;
}

.balloon {
  position: absolute;
  bottom: -100px;
  width: 50px;
  height: 60px;
  background: var(--c);
  opacity: 0.8;
  border-radius: 50%;
  box-shadow: inset -5px -5px 10px rgba(0,0,0,0.15);
}

.balloon::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 24px;
  width: 2px;
  height: 20px;
  background: #888;
}

.balloon:nth-child(1) { left: 10%; animation: floatUp 4s ease-in infinite var(--d); }
.balloon:nth-child(2) { left: 30%; animation: floatUp 5s ease-in infinite var(--d); }
.balloon:nth-child(3) { left: 50%; animation: floatUp 4.5s ease-in infinite var(--d); }
.balloon:nth-child(4) { left: 70%; animation: floatUp 5.5s ease-in infinite var(--d); }
.balloon:nth-child(5) { left: 90%; animation: floatUp 4s ease-in infinite var(--d); }

@keyframes floatUp {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translateY(-110vh) rotate(25deg); opacity: 0; }
}

/* ─── Rust Badge ────────────────────────────────────────────────────────── */
.rust-badge {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: #555;
  text-align: center;
}

/* ─── Small Button ──────────────────────────────────────────────────────── */
.small-btn {
  padding: 3px 8px;
  font-size: 0.7rem;
  background: var(--surface-alt);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

.small-btn:hover { background: #2d3148; }

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .game-layout {
    flex-direction: column;
    align-items: center;
  }
  .dashboard { width: 100%; max-width: 400px; }
}
