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

:root {
  --bg: #000000;
  --bg-card: #111111;
  --bg-card-hover: #1a1a1a;
  --border: #2a2a2a;
  --border-hover: #444444;
  --accent: #ffffff;
  --accent2: #ffffff;
  --text: #eeeeee;
  --text-muted: #666666;
  --common: #888888;
  --rare: #aaaaaa;
  --epic: #cccccc;
  --legendary: #eeeeee;
  --hp-green: #44cc77;
  --hp-yellow: #ccaa33;
  --hp-red: #cc4444;
  --player-color: #ffffff;
  --opp-color: #aaaaaa;
  --radius: 8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== SCREENS ===== */
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

/* ===== SITE HEADER ===== */
.site-header {
  text-align: center;
  padding: 28px 20px 16px;
  border-bottom: 1px solid var(--border);
  background: #0d0d0f;
}

.site-title {
  font-size: clamp(1.6rem, 4vw, 2.8rem);
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text);
}

.title-icon { -webkit-text-fill-color: initial; font-size: 0.8em; }

.site-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 6px;
  letter-spacing: 0.08em;
}

/* ===== SELECTOR LAYOUT ===== */
.selector-layout {
  display: grid;
  grid-template-columns: 1fr 200px 1fr;
  gap: 0;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  min-height: calc(100vh - 120px);
  align-items: start;
}

@media (max-width: 1024px) {
  .selector-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }
  .battle-preview { order: 3; flex-direction: row; padding: 20px 0; }
}

/* ===== SELECTION PANELS ===== */
.selection-panel { padding: 0 12px; }

.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}

.panel-header h2 { font-size: 1rem; font-weight: 700; letter-spacing: 0.06em; color: var(--text-muted); text-transform: uppercase; }

.panel-badge {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.player-badge { background: var(--player-color); color: #000; }
.opponent-badge { background: var(--opp-color); color: #fff; }

/* ===== BALLS GRID ===== */
.balls-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 1200px) {
  .balls-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ===== BALL CARD ===== */
.ball-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s, box-shadow 0.2s;
  position: relative;
  user-select: none;
}

.ball-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.ball-card.selected-player {
  border-color: var(--player-color);
  box-shadow: none;
}

.ball-card.selected-opponent {
  border-color: var(--opp-color);
  box-shadow: none;
}

/* Ball preview circle in card */
.card-ball-preview {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  position: relative;
  flex-shrink: 0;
}

.card-ball-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
}

.card-rarity {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 4px;
}

.rarity-Common  { color: var(--common); }
.rarity-Rare    { color: var(--rare); }
.rarity-Epic    { color: var(--epic); }
.rarity-Legendary { color: var(--legendary); }


.card-name {
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  margin-bottom: 2px;
}

.card-desc {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.35;
  margin-bottom: 10px;
}

/* Stat bars */
.card-stats { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }

.stat-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.62rem;
}

.stat-row-label {
  width: 26px;
  color: var(--text-muted);
  font-weight: 600;
  flex-shrink: 0;
}

.stat-bar-wrap {
  flex: 1;
  height: 5px;
  background: rgba(255,255,255,0.07);
  border-radius: 3px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

/* Special ability badge */
.card-special {
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
  padding: 5px 7px;
  text-align: center;
}

.special-name {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.special-desc {
  font-size: 0.6rem;
  color: var(--text-muted);
  line-height: 1.3;
  margin-top: 2px;
}

/* ===== BATTLE PREVIEW (center column) ===== */
.battle-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 20px 0;
  position: sticky;
  top: 20px;
}

.preview-slot { text-align: center; }

.preview-ball {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin: 0 auto 10px;
  background: rgba(255,255,255,0.04);
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.preview-ball.has-ball { border-style: solid; }

.preview-name {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

.vs-center { text-align: center; }

.vs-text {
  font-size: 2rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent2), #ff9944);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 20px;
}

.battle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #2a2a38;
  color: var(--text);
  border: 1px solid var(--border-hover);
  border-radius: 8px;
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, opacity 0.2s;
}

.battle-btn:hover:not(:disabled) {
  background: #383848;
}

.battle-btn:disabled { opacity: 0.35; cursor: not-allowed; box-shadow: none; }

/* ===== BATTLE SCREEN ===== */
.battle-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 16px;
  background: #000000;
}

/* Battle HUD */
.battle-hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 840px;
  padding: 14px 20px;
  background: rgba(10,10,30,0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: none;
}

.hud-side {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hud-opponent { justify-content: flex-end; }

.hud-ball-icon { font-size: 2.2rem; flex-shrink: 0; }

.hud-info { min-width: 0; flex: 1; }
.hud-info-right { text-align: right; }

.hud-ball-name {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-sub { font-size: 0.65rem; color: var(--text-muted); margin-bottom: 4px; }

.hp-bar-wrap {
  height: 10px;
  background: rgba(255,255,255,0.08);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 3px;
}

.hp-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.15s, background 0.3s;
}

.player-fill {
  background: var(--hp-green);
  box-shadow: 0 0 8px var(--hp-green);
  float: none;
}

.opp-fill {
  background: var(--hp-green);
  box-shadow: 0 0 8px var(--hp-green);
  float: right;
}

.hp-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.hud-vs {
  text-align: center;
  flex-shrink: 0;
}

.hud-vs-text {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--accent2);
  text-shadow: 0 0 12px var(--accent2);
  line-height: 1;
}

.round-timer {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin-top: 3px;
}

/* Canvas */
.canvas-wrap {
  width: 100%;
  max-width: 840px;
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0,0,0,0.6);
}

#arena-canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* Battle footer */
.battle-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 840px;
  margin-top: 12px;
  gap: 12px;
}

.back-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: border-color 0.2s, color 0.2s;
}

.back-btn:hover { border-color: var(--accent); color: var(--accent); }

.special-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.72rem;
}

.special-vs-label { color: var(--text-muted); }

.special-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.player-sp { background: rgba(255,255,255,0.08); color: #eeeeee; border: 1px solid rgba(255,255,255,0.2); }
.opp-sp { background: rgba(255,255,255,0.05); color: #aaaaaa; border: 1px solid rgba(255,255,255,0.15); }

/* ===== RESULTS SCREEN ===== */
#screen-results {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: #000000;
}

#screen-results.active { display: flex; }

.results-container {
  max-width: 600px;
  width: 100%;
  text-align: center;
}

.result-header { margin-bottom: 32px; }

.result-title {
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1;
}

.result-title.victory { color: #ffcc00; }
.result-title.defeat  { color: #ff4444; }

.result-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Result ball cards */
.result-balls {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.result-ball-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  min-width: 130px;
  transition: box-shadow 0.3s;
}

.winner-card {
  border-color: #ffcc00;
  box-shadow: none;
}

.loser-card { opacity: 0.55; }

.result-ball-preview {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.result-ball-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 6px;
}

.result-crown { font-size: 1.4rem; }

/* Stats */
.stats-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 28px;
}

.stats-panel h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

@media (max-width: 480px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

.stat-item .stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.stat-item .stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* Result action buttons */
.result-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.btn-play-again {
  background: #2a2a38;
  color: var(--text);
  border: 1px solid var(--border-hover);
  padding: 14px 32px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-play-again:hover { background: #383848; }

.btn-change-ball {
  background: transparent;
  border: 1px solid var(--border-hover);
  color: var(--text-muted);
  padding: 14px 28px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-change-ball:hover {
  background: rgba(255,255,255,0.08);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }

/* ===== DAILY QUESTS ===== */
.quests-section {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 28px 40px;
  border-top: 1px solid var(--border);
}
.quests-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.quests-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}
.quests-reset-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-left: auto;
}
.quests-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (max-width: 700px) { .quests-grid { grid-template-columns: 1fr; } }
.quest-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: border-color 0.3s;
}
.quest-card.done { border-color: #44cc77; }
.quest-header-row { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.quest-header-row .quest-label { margin-bottom: 0; }
.quest-icon { font-size: 1.2rem; flex-shrink: 0; line-height: 1.2; }
.quest-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.3;
}
.quest-card.done .quest-label { color: var(--text-muted); }
.quest-btn {
  background: #222222;
  border: 1px solid #444444;
  color: #eeeeee;
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.quest-btn:hover { background: #333333; }
.quest-progress-wrap {
  height: 5px;
  background: rgba(255,255,255,0.07);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.quest-progress-fill {
  height: 100%;
  background: #666666;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.quest-card.done .quest-progress-fill { background: #44cc77; }
.quest-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.65rem;
  color: var(--text-muted);
}
.quest-badge {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #44cc77;
}
.quest-lock-msg { font-size: 0.7rem; color: var(--text-muted); text-align: center; margin-top: 8px; display: none; }
.quest-lock-msg.visible { display: block; }
.quests-all-done {
  text-align: center;
  padding: 14px;
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: none;
}

/* ===== CREDITS ===== */
.credits-section {
  max-width: 1400px;
  margin: 32px auto 24px;
  padding: 0 24px;
  text-align: center;
}
.credits-inner {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.75rem;
  color: var(--text-muted);
}
.credits-inner strong {
  color: var(--text-secondary);
  font-weight: 600;
}
.credits-divider {
  color: var(--border);
}
