/* ── TOKENS: LIGHT (default) ─────────────────────────────── */
:root {
  --bg-page:       #F3E8FF;
  --bg-card:       #FFFFFF;
  --bg-stat:       #EDE7F6;
  --bg-header:     linear-gradient(90deg, #7B2FBE, #2196F3);
  --border-card:   1.5px solid #7B2FBE;
  --shadow-card:   0 0 14px rgba(123,47,190,.2);
  --text-primary:  #1A1A2E;
  --text-sec:      #666666;
  --text-muted:    #999999;
  --grad-primary:  linear-gradient(135deg, #7B2FBE, #2196F3);
  --grad-danger:   linear-gradient(135deg, #E91E63, #FF6D00);
  --grad-super:    linear-gradient(135deg, #F57F17, #FF6D00);
  --accent:        #CE93D8;
  --timer-safe:    linear-gradient(90deg, #7B2FBE, #00BCD4);
  --timer-danger:  linear-gradient(90deg, #FF1744, #FF6D00);
  --health-bg: #EDE7F6;  --health-tx: #7B2FBE;
  --motor-bg:  #E3F2FD;  --motor-tx:  #1565C0;
  --home-bg:   #E8F5E9;  --home-tx:   #2E7D32;
  --super-bg:  #FFF8E1;  --super-tx:  #F57F17;
}

/* ── TOKENS: DARK ────────────────────────────────────────── */
[data-theme="dark"] {
  --bg-page:       #0A0015;
  --bg-card:       #120025;
  --bg-stat:       #1A0030;
  --bg-header:     linear-gradient(90deg, #4A0080, #0D47A1);
  --border-card:   1.5px solid #7B2FBE;
  --shadow-card:   0 0 18px rgba(123,47,190,.4);
  --text-primary:  #E0E0E0;
  --text-sec:      #AAAAAA;
  --text-muted:    #555555;
  --grad-primary:  linear-gradient(135deg, #7B2FBE, #00BCD4);
  --grad-danger:   linear-gradient(135deg, #FF4081, #FF6D00);
  --grad-super:    linear-gradient(135deg, #FF8F00, #FF6D00);
  --accent:        #00E5FF;
  --timer-safe:    linear-gradient(90deg, #7B2FBE, #00BCD4);
  --timer-danger:  linear-gradient(90deg, #FF1744, #FF6D00);
  --health-bg: #1A0030;  --health-tx: #CE93D8;
  --motor-bg:  #001A30;  --motor-tx:  #64B5F6;
  --home-bg:   #001A05;  --home-tx:   #81C784;
  --super-bg:  #1A0F00;  --super-tx:  #FFD54F;
}

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

body {
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  transition: background .3s, color .3s;
}

#app {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 2rem;
}

/* ── HEADER ──────────────────────────────────────────────── */
#hdr {
  background: var(--bg-header);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 0 0 16px 16px;
}
#hdr-title {
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1px;
}
#hdr-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
#round-label {
  color: rgba(255,255,255,.8);
  font-size: 12px;
  font-weight: 600;
}
#theme-btn {
  background: rgba(255,255,255,.15);
  border: none;
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 14px;
  cursor: pointer;
  transition: background .2s;
}
#theme-btn:hover { background: rgba(255,255,255,.25); }

/* ── STATS ───────────────────────────────────────────────── */
#stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding: 0 12px;
}
.stat-box {
  background: var(--bg-stat);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
  border: 1px solid var(--accent);
  transition: background .3s;
}
.stat-val {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.stat-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── COVER BADGES ────────────────────────────────────────── */
#covers-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 0 12px;
}
.cover-badge {
  border-radius: 10px;
  padding: 7px 4px;
  text-align: center;
  border: 1.5px solid transparent;
  transition: background .3s, opacity .2s;
}
.cover-badge[data-type="health"] { background: var(--health-bg); border-color: var(--health-tx); }
.cover-badge[data-type="motor"]  { background: var(--motor-bg);  border-color: var(--motor-tx); }
.cover-badge[data-type="home"]   { background: var(--home-bg);   border-color: var(--home-tx); }
.cover-badge[data-type="super"]  { background: var(--super-bg);  border-color: var(--super-tx); }
.cover-badge.empty { opacity: .35; }
.cover-count {
  font-size: 16px;
  font-weight: 700;
  display: block;
}
.cover-badge[data-type="health"] .cover-count { color: var(--health-tx); }
.cover-badge[data-type="motor"]  .cover-count { color: var(--motor-tx); }
.cover-badge[data-type="home"]   .cover-count { color: var(--home-tx); }
.cover-badge[data-type="super"]  .cover-count { color: var(--super-tx); }
.cover-lbl {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── DISASTER CARD ───────────────────────────────────────── */
#card {
  margin: 0 12px;
  background: var(--bg-card);
  border: var(--border-card);
  border-radius: 18px;
  padding: 20px 18px;
  text-align: center;
  min-height: 168px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-card);
  transition: background .3s, box-shadow .3s;
  position: relative;
  overflow: hidden;
}
#card-character {
  font-size: 44px;
  line-height: 1;
  transition: transform .2s;
}
#card-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
}
#card-desc {
  font-size: 13px;
  color: var(--text-sec);
  line-height: 1.5;
}
#card-damage {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(233,30,99,.12);
  color: #E91E63;
}

/* Combo burst overlay (injected by JS) */
#combo-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(255,215,0,.08);
  border-radius: 18px;
  pointer-events: none;
}
.combo-badge {
  background: linear-gradient(135deg, #FFD700, #FF6D00);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  padding: 8px 20px;
  border-radius: 30px;
  box-shadow: 0 0 20px rgba(255,215,0,.5);
  animation: burst .5s ease forwards;
}
.combo-coins {
  color: #FFD740;
  font-size: 13px;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(255,215,0,.8);
}

/* Luck wheel overlay (injected by JS) */
#wheel-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--bg-card);
  border-radius: 18px;
}
#wheel-needle {
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 20px solid #FFD740;
  filter: drop-shadow(0 0 4px rgba(255,215,64,.8));
}
#wheel {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: conic-gradient(
    #E91E63 0deg 90deg,
    #1E88E5 90deg 180deg,
    #E91E63 180deg 270deg,
    #1E88E5 270deg 360deg
  );
  border: 4px solid #fff;
  box-shadow: 0 0 20px rgba(123,47,190,.5);
  position: relative;
  will-change: transform;
}
#wheel-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 34px; height: 34px;
  background: var(--bg-card);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
#wheel-label {
  font-size: 12px;
  color: var(--text-sec);
  font-weight: 600;
}

/* ── TIMER ───────────────────────────────────────────────── */
#timer-wrap {
  margin: 0 12px;
  background: var(--bg-stat);
  border-radius: 6px;
  height: 8px;
  overflow: hidden;
}
#timer-bar {
  height: 8px;
  width: 0%;
  border-radius: 6px;
  background: var(--timer-safe);
  transition: width 3s linear;
}
#timer-bar.danger {
  background: var(--timer-danger);
  animation: timer-pulse .6s ease infinite;
}

/* ── BUTTONS ─────────────────────────────────────────────── */
#actions {
  padding: 0 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 44px;
}
.btn {
  flex: 1;
  min-width: 100px;
  border: none;
  border-radius: 12px;
  padding: 12px 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .1s, opacity .15s;
  color: #fff;
  font-family: inherit;
}
.btn:active:not(:disabled) { transform: scale(.96); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn-health   { background: linear-gradient(135deg, #7B2FBE, #2196F3); }
.btn-motor    { background: linear-gradient(135deg, #1565C0, #00BCD4); }
.btn-home     { background: linear-gradient(135deg, #2E7D32, #8BC34A); }
.btn-super    { background: var(--grad-super); }
.btn-risk     { background: var(--grad-danger); }
.btn-next     { background: var(--grad-primary); flex: unset; width: 100%; }
.btn-start    { background: var(--grad-primary); flex: unset; width: 100%; font-size: 15px; padding: 14px; }
.btn-continue { background: var(--grad-primary); flex: unset; width: 100%; }

/* ── LOG ─────────────────────────────────────────────────── */
#log {
  padding: 0 12px;
  min-height: 36px;
  font-size: 13px;
  text-align: center;
  color: var(--text-sec);
  line-height: 1.6;
}
#log.success { color: #4CAF50; }
#log.danger  { color: #E91E63; }
#log.warning { color: #FF8F00; }

/* ── CONFETTI CONTAINER ──────────────────────────────────── */
#confetti-wrap {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 999;
}
.confetti-dot {
  position: absolute;
  top: -10px;
  width: 8px;
  height: 10px;
  border-radius: 2px;
  animation: confetti-fall 3s ease-in forwards;
}

/* ── ANIMATIONS ──────────────────────────────────────────── */
@keyframes card-shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-10px); }
  60%     { transform: translateX(10px); }
}
@keyframes card-pop {
  0%,100% { transform: scale(1); }
  50%     { transform: scale(1.05); }
}
@keyframes burst {
  0%   { transform: scale(.4); opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes timer-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,23,68,.3); }
  50%     { box-shadow: 0 0 0 4px rgba(255,23,68,.5); }
}
@keyframes wheel-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(var(--spin-end, 720deg)); }
}
@keyframes confetti-fall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}
@keyframes glow-gold {
  0%,100% { box-shadow: var(--shadow-card); }
  50%     { box-shadow: 0 0 30px rgba(255,215,0,.6); }
}

.card-shake     { animation: card-shake .4s ease; }
.card-pop       { animation: card-pop .3s ease; }
.card-glow-gold { animation: glow-gold .6s ease; }
.wheel-spinning { animation: wheel-spin 1.5s cubic-bezier(.3,0,.2,1) forwards; }
