* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-0);
  color: var(--ink);
  font-family: "Segoe UI", "SF Pro Text", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-0);
  display: block;
  cursor: default;
}

.scene {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.3), rgba(0,0,0,0.85));
  z-index: 50;
  pointer-events: auto;
}
.scene.hidden { display: none; }

.menu-card {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  padding: 36px 44px;
  min-width: 360px;
  max-width: 520px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  text-align: center;
}
.menu-card.wide { max-width: 820px; width: 80%; }

.game-title {
  font-size: 44px;
  letter-spacing: 6px;
  margin: 0 0 8px;
  font-weight: 800;
}
.game-title .accent {
  color: var(--accent);
  margin-left: 8px;
}
.tagline {
  color: var(--ink-dim);
  margin-bottom: 28px;
  letter-spacing: 0.5px;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 18px 0 14px;
  align-items: stretch;
}

.btn {
  font: inherit;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 12px 18px;
  background: var(--bg-2);
  color: var(--ink);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: var(--bg-1); border-color: var(--accent-dim); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent-dim); color: #0b1612; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent); }
.btn.danger { background: #5b2a23; border-color: var(--danger); }
.btn.small { padding: 6px 10px; font-size: 12px; letter-spacing: 1px; }

.meta-strip {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-dim);
  font-size: 12px;
  margin-top: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* --- Deck / draft / collection grid --- */
.deck-panel, .draft-panel {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  padding: 28px 32px;
  max-width: 900px;
  width: 90%;
}
.deck-panel h2, .draft-panel h2, .menu-card h2 { margin-top: 0; letter-spacing: 2px; }
.hint { color: var(--ink-dim); font-weight: 400; font-size: 14px; letter-spacing: 1px; }

.card-pool {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  max-height: 64vh;
  overflow-y: auto;
  padding: 8px;
  justify-items: center;
}

/* ===== Hearthstone-style card ===== */
.hs-card {
  position: relative;
  width: 180px;
  height: 252px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(0,0,0,0.4) 70%),
    radial-gradient(circle at 50% 0%, #353f47 0%, #1c252b 65%);
  border-radius: 14px;
  border: 2px solid #2c3a42;
  box-shadow:
    0 2px 0 rgba(255,255,255,0.05) inset,
    0 -2px 0 rgba(0,0,0,0.4) inset,
    0 8px 24px rgba(0,0,0,0.55);
  padding: 10px 10px 8px;
  display: grid;
  grid-template-rows: 110px auto auto 1fr auto;
  gap: 4px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  color: var(--ink);
  user-select: none;
}
.hs-card:hover {
  transform: translateY(-4px) rotate(-0.5deg);
  box-shadow:
    0 2px 0 rgba(255,255,255,0.05) inset,
    0 -2px 0 rgba(0,0,0,0.4) inset,
    0 14px 32px rgba(0,0,0,0.65);
  border-color: var(--accent);
}
.hs-card.selected {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px var(--accent),
    0 0 24px var(--accent-dim),
    0 8px 24px rgba(0,0,0,0.65);
  transform: translateY(-2px);
}
.hs-card.locked { opacity: 0.45; filter: grayscale(0.7); cursor: not-allowed; }
.hs-card.depleted { opacity: 0.4; filter: grayscale(0.6); cursor: not-allowed; pointer-events: none; }

/* Rarity colored borders + frame glow */
.hs-card.rarity-common    { border-color: #5a6770; }
.hs-card.rarity-rare      { border-color: #4a8ec6; box-shadow: 0 0 0 0 transparent, 0 0 18px rgba(74,142,198,0.25), 0 8px 24px rgba(0,0,0,0.55); }
.hs-card.rarity-epic      { border-color: #b07ee2; box-shadow: 0 0 0 0 transparent, 0 0 18px rgba(176,126,226,0.3),  0 8px 24px rgba(0,0,0,0.55); }
.hs-card.rarity-legendary { border-color: #f0c54a; box-shadow: 0 0 0 0 transparent, 0 0 22px rgba(240,197,74,0.4),  0 8px 24px rgba(0,0,0,0.55); }

.hs-card .hs-art-frame {
  position: relative;
  border-radius: 50% 50% 46% 46% / 60% 60% 40% 40%;
  background:
    radial-gradient(circle at 50% 40%, #2a3640 0%, #11181c 75%);
  border: 2px solid rgba(0,0,0,0.6);
  box-shadow: 0 2px 6px rgba(0,0,0,0.6) inset, 0 0 0 1px rgba(255,255,255,0.06) inset;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hs-card .hs-art-frame.upgrade {
  background: radial-gradient(circle at 50% 40%, #46361a 0%, #1b1308 80%);
}
.hs-card .hs-art {
  width: 100%;
  height: 100%;
}

/* Rarity gem (centered below art) */
.hs-card .hs-gem {
  position: absolute;
  top: 110px;
  left: 50%;
  transform: translate(-50%, -50%) rotate(45deg);
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: #5a6770;
  box-shadow: 0 1px 0 rgba(255,255,255,0.2) inset, 0 -1px 0 rgba(0,0,0,0.4) inset;
  z-index: 2;
}
.hs-card.rarity-rare      .hs-gem { background: #4a8ec6; }
.hs-card.rarity-epic      .hs-gem { background: #b07ee2; }
.hs-card.rarity-legendary .hs-gem { background: #f0c54a; box-shadow: 0 0 8px #f0c54a; }

.hs-card .hs-name-banner {
  text-align: center;
  margin-top: 6px;
  background: linear-gradient(180deg, #0c1115 0%, #1a232a 100%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  padding: 4px 6px;
}
.hs-card .hs-name {
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(0,0,0,0.8);
}
.hs-card.rarity-rare      .hs-name { color: #b1dafa; }
.hs-card.rarity-epic      .hs-name { color: #e2c2ff; }
.hs-card.rarity-legendary .hs-name { color: #ffe28a; }

.hs-card .hs-tags {
  font-size: 9px;
  text-align: center;
  letter-spacing: 1.5px;
  color: var(--accent);
  text-transform: uppercase;
}

.hs-card .hs-desc {
  font-size: 11px;
  line-height: 1.3;
  color: var(--ink-dim);
  text-align: center;
  padding: 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hs-card .hs-stats {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  padding: 0 4px;
}
.hs-card .hs-stat {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  text-shadow: 0 1px 0 rgba(0,0,0,0.7);
  border: 2px solid rgba(0,0,0,0.6);
  box-shadow: 0 1px 0 rgba(255,255,255,0.2) inset, 0 2px 4px rgba(0,0,0,0.5);
}
.hs-card .hs-stat-hp  { background: radial-gradient(circle at 40% 30%, #ff8c75 0%, #a13525 80%); margin-right: auto; }
.hs-card .hs-stat-dmg { background: radial-gradient(circle at 40% 30%, #ffd76b 0%, #8a5b14 80%); margin: 0 auto; }
.hs-card .hs-stat-rng { background: radial-gradient(circle at 40% 30%, #95e0c2 0%, #2c6e57 80%); margin-left: auto; }

/* Compact size (hand) */
.hs-card.hs-sm {
  width: 110px;
  height: 158px;
  padding: 6px 6px 6px;
  grid-template-rows: 64px auto auto 1fr auto;
  border-radius: 10px;
}
.hs-card.hs-sm .hs-gem { top: 64px; width: 8px; height: 8px; }
.hs-card.hs-sm .hs-name { font-size: 10px; letter-spacing: 0.5px; }
.hs-card.hs-sm .hs-tags { font-size: 7px; letter-spacing: 1px; }
.hs-card.hs-sm .hs-desc { font-size: 9px; line-height: 1.2; -webkit-line-clamp: 3; }
.hs-card.hs-sm .hs-stat { width: 20px; height: 20px; font-size: 10px; }

/* Upgrade cards: no stats row */
.hs-card.kind-upgrade .hs-stats { display: none; }
.hs-card.kind-upgrade .hs-name { color: var(--gold); }

.deck-footer {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

/* --- In-game HUD --- */
#game-hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 40;
}
#game-hud.hidden { display: none; }
#game-hud > * { pointer-events: auto; }

.hud-bar {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  gap: 18px;
  align-items: center;
  box-shadow: 0 4px 18px rgba(0,0,0,0.5);
}

#top-bar { top: 14px; left: 50%; transform: translateX(-50%); }
.hud-cell { display: flex; flex-direction: column; align-items: center; min-width: 70px; }
.hud-cell .label { font-size: 10px; color: var(--ink-dim); letter-spacing: 2px; }
.hud-cell .value { font-size: 18px; font-weight: 700; }
.hud-cell .value.mono { font-family: ui-monospace, "SF Mono", monospace; font-size: 13px; }
.hud-cell.phase .value { color: var(--accent); }

#bottom-bar { bottom: 14px; left: 50%; transform: translateX(-50%); align-items: flex-end; padding: 10px 14px 14px; }
.hand { display: flex; gap: 8px; align-items: flex-end; }
.bottom-controls { display: flex; gap: 8px; margin-left: 12px; padding-bottom: 8px; }

.selected-panel {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
  padding: 14px 14px;
  width: 200px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.5);
}
.selected-panel.hidden { display: none; }
.sel-name { font-weight: 700; letter-spacing: 1px; margin-bottom: 8px; text-align: center; text-transform: uppercase; font-size: 13px; }
.sel-bar { height: 6px; background: var(--bg-2); border-radius: 3px; overflow: hidden; margin-bottom: 10px; }
.sel-hp-fill { height: 100%; background: var(--hp-good); width: 100%; transition: width 0.15s ease; }
.sel-stats { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-dim); margin-bottom: 12px; }
.sel-stats span span { color: var(--ink); font-weight: 700; margin-left: 4px; }

/* Mode selector sidebar */
.sel-modes {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-top: 4px;
}
.mode-btn {
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px 6px;
  background: linear-gradient(180deg, #1a232a, #0f1418);
  border: 1px solid #2c3a42;
  border-radius: 8px;
  color: var(--ink-dim);
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}
.mode-btn:hover {
  border-color: var(--accent-dim);
  color: var(--ink);
  transform: translateY(-1px);
}
.mode-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: linear-gradient(180deg, #1f3a31, #0e221d);
  box-shadow: 0 0 0 1px var(--accent-dim) inset, 0 0 12px rgba(122,214,179,0.25);
}
.mode-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.mode-btn svg { display: block; }
.mode-btn .mode-label {
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 700;
}
.mode-tooltip {
  margin-top: 10px;
  padding: 8px 10px;
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--panel-edge);
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--ink);
  min-height: 36px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.mode-tooltip.show { opacity: 1; }

.banner {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 8px;
  color: var(--danger);
  text-shadow: 0 4px 24px rgba(226,107,92,0.7);
  pointer-events: none;
  animation: banner-sweep 1.6s ease both;
}
.banner.hidden { display: none; }
@keyframes banner-sweep {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.1); }
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--panel-edge);
  letter-spacing: 1px;
}
.setting-row input[type="range"] { width: 160px; }

#result-title { letter-spacing: 6px; color: var(--accent); }
#result-title.lose { color: var(--danger); }
