/* Phase 0 styling. Deliberately plain — placeholder shapes and text only. */

:root {
  --bg: #14161c;
  --panel: #1e2230;
  --panel-2: #262b3d;
  --ink: #e7e9f0;
  --ink-dim: #9aa0b4;
  --accent: #6ea8fe;
  --accent-strong: #2f6fe0;
  --good: #4bd07a;
  --danger: #e2564d;
  --line: #333a52;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

.screen {
  max-width: 780px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

h1 {
  font-size: 22px;
  margin: 0 0 2px;
}
.tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--bg);
  background: var(--accent);
  border-radius: 999px;
  padding: 2px 8px;
  vertical-align: middle;
}
.phase { color: var(--ink-dim); margin: 0 0 20px; }

/* ---- turn timer ---- */
.turn-timer {
  position: relative;
  height: 26px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
}
.turn-timer-bar {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--accent-strong);
  transition: width 0.2s linear; /* matches the 200ms repaint tick */
}
.turn-timer--warn .turn-timer-bar { background: #b7791f; }
.turn-timer--danger .turn-timer-bar { background: var(--danger); }
.turn-timer-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

/* ---- handoff gate ---- */
.handoff-gate {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 36px 20px;
  text-align: center;
}
.handoff-notice {
  background: #2c2a1a;
  border: 1px solid #6b5d1f;
  color: #ffd66e;
  border-radius: 8px;
  padding: 8px 12px;
  margin: 0 auto 16px;
  max-width: 460px;
  font-size: 13px;
}
.handoff-turn { color: var(--ink-dim); margin: 0 0 4px; font-size: 13px; }
.handoff-who { font-size: 20px; font-weight: 700; margin: 0 0 14px; }
.handoff-hp {
  display: flex;
  gap: 20px;
  justify-content: center;
  color: var(--ink-dim);
  font-size: 13px;
  margin-bottom: 6px;
}
.phase-footer { color: var(--ink-dim); text-align: center; margin-top: 28px; font-size: 13px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
}

/* ---- start screen ---- */
.pick-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.pick-row label {
  flex: 1 1 200px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
}
.player-pick {
  flex: 1 1 300px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
.player-pick h3 { margin: 0 0 8px; font-size: 14px; }
.player-pick label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; margin-bottom: 8px; }
.deck-blurb { color: var(--ink-dim); font-size: 12px; line-height: 1.4; margin: 4px 0 0; }
select {
  font: inherit;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
}
.hint { color: var(--ink-dim); font-size: 13px; }

/* ---- battle board ---- */
.board {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.hero {
  flex: 1 1 320px;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  transition: border-color 0.15s;
}
.hero--active { border-color: var(--accent); }
.hero--winner { border-color: var(--good); }

.hero-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.hero-name { font-weight: 700; font-size: 16px; }
.hero-weight {
  font-size: 12px;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
}
.hero-form { color: var(--ink-dim); font-size: 13px; margin-bottom: 10px; }
.status-row { display: flex; flex-wrap: wrap; gap: 5px; margin: -4px 0 10px; }
.status-chip {
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  padding: 1px 8px;
  border: 1px solid;
}
.status-chip--buff { color: #7fe0a0; border-color: #2f6b45; background: #16351f; }
.status-chip--dormant { opacity: 0.45; }
.status-chip--debuff { color: #f0a29c; border-color: #6b2f2f; background: #351616; }

.hpbar {
  position: relative;
  height: 22px;
  background: var(--panel-2);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 10px;
}
.hpbar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--good), #7fe0a0);
  transition: width 0.2s;
}
.hpbar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9), 0 0 4px rgba(0, 0, 0, 0.7); /* readable over both the green fill and the empty track */
}
.meters,
.piles {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--ink-dim);
}
.meters { margin-bottom: 6px; }
.energy { color: #ffd66e; font-weight: 700; }
.fatigue { color: var(--danger); font-weight: 700; }
.turn-flag {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

/* ---- hand ---- */
.hand {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 18px;
}
.hand h3 { margin: 4px 0 10px; font-size: 14px; color: var(--ink-dim); }
.hand-row { display: flex; gap: 10px; flex-wrap: wrap; }
.game-card {
  width: 150px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.game-card:hover:not(:disabled) { border-color: var(--accent); }
.game-card--disabled { opacity: 0.4; cursor: not-allowed; }
.game-card--discard { border-color: var(--danger); }
.game-card--discard:hover { background: #3a1c1a; border-color: var(--danger); }
.controls--discard { border-color: var(--danger); }
.controls--transform { border-color: var(--accent); }
.warn { color: #ffb454; }
.game-card-cost { color: #ffd66e; font-weight: 700; font-size: 12px; }
.game-card-name { font-weight: 700; }
.game-card-text { font-size: 12px; color: var(--ink-dim); line-height: 1.35; }

/* ---- controls ---- */
.controls {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 18px;
}
.handoff { margin: 0 0 12px; }
.matchup {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--ink-dim);
}
.matchup--good { color: #7fe0a0; background: #16351f; }
.matchup--bad { color: #f0a29c; background: #351616; }
.btn-counter { background: #7a5cc0; }
.btn-counter:hover { background: #8f6fd8; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent-strong);
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
}
.btn:hover { background: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-secondary { background: #3a4160; }
.btn-secondary:hover { background: #4a5378; }
.btn-big { font-size: 16px; padding: 12px 22px; margin-top: 14px; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-dim);
}
.btn-ghost:hover { background: #2c1d1d; border-color: var(--danger); color: #f0a29c; }
.btn-danger-solid { background: #a23b33; }
.btn-danger-solid:hover { background: #c0463c; }
.btn small { font-weight: 400; opacity: 0.85; }

.gameover { font-size: 18px; font-weight: 700; color: var(--good); margin: 0 0 6px; }

/* ---- log ---- */
.log {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
}
.log-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.log-header h3 { margin: 4px 0 8px; }
.log h3 { margin: 4px 0 8px; font-size: 14px; color: var(--ink-dim); }
.btn-small { font-size: 12px; padding: 5px 10px; margin-top: 0; }
.log ul { margin: 0; padding-left: 18px; }
.log li { margin-bottom: 4px; font-size: 13px; }
.log li:first-child { color: var(--ink); font-weight: 600; }

/* ===== PoC additions: "the hero is the board" ===== */
.rel { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.rel--good { color: #7fe0a0; background: #16351f; }
.rel--bad { color: #f0a29c; background: #351616; }
.cd { color: #ffb454; font-weight: 700; }
.chip-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.chip {
  font-size: 11px; font-weight: 600; border-radius: 6px; padding: 2px 8px;
  color: #a9c7ff; background: #1a2540; border: 1px solid #33436b;
}
.btn-danger { background: #a23b33; color: #fff; }
.btn-danger:hover { background: #c0463c; }
.controls--transform { border-color: var(--accent); }

.game-card-kind {
  font-size: 9px; font-weight: 800; letter-spacing: 0.08em; color: var(--ink-dim);
}
.game-card { position: relative; border-left: 3px solid var(--line); }
.gc--transform { border-left-color: #6ea8fe; }
.gc--attach { border-left-color: #4bd07a; }
.gc--trick { border-left-color: #ffd66e; }
.gc--trap { border-left-color: #b06ee0; }

/* ===== Type picker (start screen) ===== */
.type-cols { display: flex; gap: 20px; flex-wrap: wrap; margin: 8px 0 16px; }
.type-col { flex: 1; min-width: 260px; }
.type-col h3 { margin: 0 0 8px; font-size: 14px; color: var(--ink-dim); }
.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.type-pick {
  display: flex; flex-direction: column; gap: 3px; text-align: left;
  padding: 9px 11px; border-radius: 10px; cursor: pointer;
  background: #141c2e; border: 1px solid #2b3752; color: var(--ink);
}
.type-pick:hover { border-color: #3f5a8c; }
.type-pick--on { border-color: var(--accent); background: #1a2846; box-shadow: 0 0 0 1px var(--accent) inset; }
.type-pick-name { font-weight: 700; font-size: 14px; }
.type-pick-blurb { font-size: 11px; color: var(--ink-dim); }
.type-pick-aff { font-size: 10px; color: #7fa8e0; }
.aff { font-size: 11px; font-weight: 700; color: #ffd66e; }

/* ===== Type detail panel + element-wheel reference ===== */
.type-detail {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px;
  background: #10182a; border: 1px solid #24304a;
}
.td-row { margin: 0 0 5px; font-size: 12px; line-height: 1.45; color: var(--ink-dim); }
.td-row:last-child { margin-bottom: 0; }
.td-row strong { color: var(--ink); font-weight: 600; }

.wheel-ref { margin: 4px 0 10px; font-size: 12px; }
.wheel-ref summary {
  cursor: pointer; color: #7fa8e0; font-weight: 600; padding: 4px 0;
  list-style: none;
}
.wheel-ref summary::before { content: "▸ "; }
.wheel-ref[open] summary::before { content: "▾ "; }
.wheel-ref .hint { margin: 6px 0 8px; }
.wheel-ref em { color: var(--ink); font-style: normal; font-weight: 600; }
.wheel-tbl { border-collapse: collapse; width: 100%; font-size: 12px; }
.wheel-tbl th, .wheel-tbl td {
  padding: 4px 8px; text-align: left; border-bottom: 1px solid #24304a;
}
.wheel-tbl th { color: var(--ink-dim); font-weight: 600; }
.wheel-tbl td:first-child { color: var(--ink); font-weight: 600; }

/* ===== Deck row (start screen) + Deck builder ===== */
.deck-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin: 4px 0 16px;
}
.db-total {
  font-size: 14px; font-weight: 700; margin: 0 0 10px;
  padding: 6px 10px; border-radius: 8px; display: inline-block;
  background: var(--panel-2); color: var(--ink-dim);
}
.db-total--ok { color: #7fe0a0; background: #16351f; }
.db-total--bad { color: #f0a29c; background: #351616; }
.db-errors { margin: 0 0 16px; padding-left: 18px; color: #f0a29c; font-size: 13px; }
.db-group { margin-bottom: 18px; }
.db-group h3 { margin: 0 0 8px; font-size: 14px; color: var(--ink-dim); }
.db-list { display: flex; flex-direction: column; gap: 6px; }
.db-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px;
}
.db-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.db-cost { color: #ffd66e; font-weight: 700; font-size: 12px; }
.db-name { font-weight: 700; font-size: 13px; }
.db-text { font-size: 12px; color: var(--ink-dim); }
.db-stepper { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.db-stepper .btn { padding: 4px 10px; }
.db-count { font-weight: 700; min-width: 16px; text-align: center; }

/* ---- collection ---- */
.coll-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 8px 0 16px; }
.coll-tile { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.coll-name { font-weight: 700; font-size: 15px; }
.coll-meta { font-size: 12px; color: var(--ink-dim); }
.coll-new { display: flex; gap: 8px; flex-wrap: wrap; }
.db-name-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-dim); margin: 0 0 10px; max-width: 280px; }
.db-name-field input { font: inherit; font-size: 14px; color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }

/* ---- perks ---- */
.chip--perk { background: #3a2f5c; color: #d9c8ff; }
.type-pick-perks { font-size: 10px; color: #d9c8ff; }
.perk-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px; }
.perk-opt { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: start; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.perk-opt--on { border-color: var(--accent); background: #1a2846; }
.perk-opt input { grid-row: span 2; margin-top: 3px; }
.perk-name { font-weight: 700; font-size: 13px; }
.perk-type { font-weight: 400; font-size: 11px; color: #7fa8e0; margin-left: 4px; }
.perk-text { font-size: 12px; color: var(--ink-dim); grid-column: 2; }

.bot-toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); cursor: pointer; }

/* ---- deck builder: big pool ---- */
.db-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; align-items: center; position: sticky; top: 0; z-index: 2; background: var(--bg, #0b1220); padding: 8px 0; }
.db-filters input[type="search"], .db-filters select { font: inherit; font-size: 13px; color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.db-filters input[type="search"] { flex: 1; min-width: 160px; }
.db-indeck { font-size: 12px; color: var(--ink-dim); display: flex; align-items: center; gap: 4px; }
.db-shown { font-weight: 400; font-size: 12px; color: var(--ink-dim); }
.db-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.db-row--in { border-color: var(--accent); background: #16213a; }
.db-kind, .db-class, .db-el { font-size: 10px; font-weight: 700; border-radius: 999px; padding: 1px 7px; background: #2b3350; color: #c9d4f5; }
.db-kind--trap { background: #4a2a5c; color: #e6c9ff; }
.db-kind--attach { background: #27425c; color: #bfe0ff; }
.db-kind--transform { background: #3f4a22; color: #e4f2b8; }
.db-class { background: #5c4a22; color: #ffe2a3; }
.db-el--fire { background: #5c2a22; color: #ffc4b8; }
.db-el--nature { background: #25502c; color: #bff0c8; }
.db-el--earth { background: #4f4125; color: #e8d6a6; }
.db-el--forge { background: #3a3f4a; color: #d3dae6; }
.db-el--water { background: #22425c; color: #b8dcff; }

/* ---- online ---- */
.online-banner { margin: 0 0 8px; font-size: 13px; font-weight: 700; color: #bfe0ff; }
.online-notice { margin: 0 0 10px; font-size: 13px; color: #ffd66e; background: #3a2f12; border-radius: 6px; padding: 6px 10px; }
.online-code { font-size: 44px; font-weight: 800; letter-spacing: 10px; margin: 4px 0 8px; color: var(--accent); }
.online-wait { text-align: center; }
.ol-code-input { font: inherit; font-size: 20px; font-weight: 700; letter-spacing: 6px; text-transform: uppercase; width: 120px; text-align: center; color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }

/* ---- rarity ---- */
.db-rarity { font-size: 10px; font-weight: 700; border-radius: 999px; padding: 1px 7px; background: #2b3350; color: #c9d4f5; }
.db-rarity--common { background: #2d3142; color: #aeb4c8; }
.db-rarity--rare { background: #1d3f73; color: #a9d0ff; }
.db-rarity--epic { background: #51286f; color: #e3bbff; }
.db-rarity--legendary { background: #7a4a0c; color: #ffd98a; }
.db-row--rare { border-left: 3px solid #3f7fd9; }
.db-row--epic { border-left: 3px solid #a65ad8; }
.db-row--legendary { border-left: 3px solid #f2a83b; box-shadow: 0 0 0 1px #5a3d12 inset; }
.gc-r--rare { box-shadow: 0 0 0 1px #3f7fd9 inset; }
.gc-r--epic { box-shadow: 0 0 0 1px #a65ad8 inset; }
.gc-r--legendary { box-shadow: 0 0 0 2px #f2a83b inset, 0 0 8px #f2a83b55; }

/* ---- cards & packs hub ---- */
.hub-bar { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 12px; }
.hub-stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; font-size: 13px; color: var(--ink-dim); }
.hub-stat b { color: var(--ink); font-size: 15px; margin-left: 4px; }
.hub-stat--gold b { color: #ffd66e; }
.hub-stat--dust b { color: #b8dcff; }
.hub-actions { align-items: center; }
.hub-odds { margin: 10px 0; font-size: 12px; color: var(--ink-dim); }
.hub-odds summary { cursor: pointer; color: var(--accent); }
.hub-card-actions { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.pack-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.pack-card { width: 132px; min-height: 92px; border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 4px; background: var(--panel-2); border: 2px solid #3a4160; animation: pack-pop 0.35s ease both; }
.pack-card--rare { border-color: #3f7fd9; }
.pack-card--epic { border-color: #a65ad8; }
.pack-card--legendary { border-color: #f2a83b; box-shadow: 0 0 12px #f2a83b66; }
.pack-rarity { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--ink-dim); }
.pack-name { font-weight: 700; font-size: 13px; }
.pack-tag { font-size: 11px; color: #7fe0a0; margin-top: auto; }
.pack-card--rare .pack-rarity { color: #a9d0ff; }
.pack-card--epic .pack-rarity { color: #e3bbff; }
.pack-card--legendary .pack-rarity { color: #ffd98a; }
@keyframes pack-pop { from { opacity: 0; transform: translateY(8px) scale(0.92); } to { opacity: 1; transform: none; } }
.quest-list { display: flex; flex-direction: column; gap: 6px; }
.quest { display: grid; grid-template-columns: 1fr 120px auto; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.quest--done { opacity: 0.6; }
.quest-bar { display: block; height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.quest-bar span { display: block; height: 100%; background: var(--accent-strong); }
.db-row--locked { opacity: 0.55; }
.db-locked { font-size: 10px; font-weight: 700; border-radius: 999px; padding: 1px 7px; background: #4a2222; color: #f0a29c; }

.copy-fallback { background: var(--panel-2); border: 1px solid var(--accent); border-radius: 8px; padding: 10px; margin: 0 0 10px; display: flex; flex-direction: column; gap: 8px; }
.copy-fallback p { margin: 0; font-size: 13px; }
.copy-fallback textarea { width: 100%; min-height: 140px; font: 12px/1.4 ui-monospace, monospace; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; box-sizing: border-box; }

/* ---- account ---- */
.account-bar { display: flex; align-items: center; justify-content: flex-end; gap: 10px; font-size: 13px; color: var(--ink-dim); margin: 0 0 10px; flex-wrap: wrap; }
.account-bar b { color: var(--ink); }

/* ---- best-practice features ---- */
.daily-strip { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 0 0 10px; font-size: 13px; color: var(--ink-dim); flex-wrap: wrap; }
.daily-strip--ready { border-color: #f2a83b; background: #2b2412; color: #ffe2a3; }
.threat { margin: 4px 0 10px; font-size: 13px; color: #ffb36b; }
.threat b { color: #ff7a6b; }
.btn-ready { background: #1f7a45; animation: ready-pulse 1.4s ease-in-out infinite; }
.btn-ready:hover { background: #28995a; }
@keyframes ready-pulse { 0%, 100% { box-shadow: 0 0 0 0 #4bd07a55; } 50% { box-shadow: 0 0 0 6px #4bd07a00; } }
.progress-list { display: flex; flex-direction: column; gap: 6px; }
.progress-row { display: grid; grid-template-columns: 110px 1fr 90px; gap: 10px; align-items: center; font-size: 12px; color: var(--ink-dim); }
.pack-card { animation: pack-flip 0.5s ease both; animation-delay: calc(var(--i, 0) * 0.45s); transform-origin: center; }
@keyframes pack-flip { 0% { opacity: 0; transform: perspective(500px) rotateY(90deg) scale(0.9); } 60% { opacity: 1; } 100% { opacity: 1; transform: perspective(500px) rotateY(0) scale(1); } }
.pack-card--epic { animation-name: pack-flip, glow-epic; animation-duration: 0.5s, 1.6s; animation-delay: calc(var(--i, 0) * 0.45s), calc(var(--i, 0) * 0.45s + 0.5s); animation-iteration-count: 1, 2; }
.pack-card--legendary { animation-name: pack-flip, glow-legend; animation-duration: 0.5s, 1.6s; animation-delay: calc(var(--i, 0) * 0.45s), calc(var(--i, 0) * 0.45s + 0.5s); animation-iteration-count: 1, 3; }
@keyframes glow-epic { 0%, 100% { box-shadow: 0 0 0 #a65ad800; } 50% { box-shadow: 0 0 14px #a65ad8aa; } }
@keyframes glow-legend { 0%, 100% { box-shadow: 0 0 6px #f2a83b66; } 50% { box-shadow: 0 0 22px #f2a83bdd; } }
.help-overlay { position: fixed; inset: 0; background: rgba(8, 10, 16, 0.78); display: grid; place-items: center; z-index: 50; padding: 16px; overflow-y: auto; }
.help-card { background: var(--panel); border: 1px solid var(--accent); border-radius: 14px; padding: 18px 22px; max-width: 560px; width: 100%; max-height: 92vh; overflow-y: auto; }
.help-card h2 { margin: 0 0 8px; }
.help-card ol { margin: 0 0 12px; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; line-height: 1.45; }
@media (prefers-reduced-motion: reduce) { .pack-card, .btn-ready { animation: none !important; } }

/* ---- guided first match ---- */
.tutorial-strip { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 0 0 10px; font-size: 13px; color: var(--ink-dim); flex-wrap: wrap; }
.tutorial-strip--new { border-color: #4aa3ff; background: #12233a; color: #cfe6ff; }
.coach { position: sticky; top: 0; z-index: 20; background: #12233a; border: 2px solid #4aa3ff; border-radius: 10px; padding: 10px 14px; margin: 0 0 10px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45); }
.coach-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: #8fc6ff; }
.coach-text { margin: 6px 0 8px; font-size: 15px; line-height: 1.45; color: #eaf4ff; }
.coach-hl { outline: 3px solid #ffd24a; outline-offset: 3px; border-radius: 8px; animation: coach-pulse 1.3s ease-in-out infinite; }
.coach-locked { opacity: 0.35; }
@keyframes coach-pulse { 0%, 100% { outline-color: #ffd24a; } 50% { outline-color: rgba(255, 210, 74, 0.25); } }
@media (prefers-reduced-motion: reduce) { .coach-hl { animation: none !important; } }

/* ---- mulligan ---- */
.mulligan h2 { margin: 6px 0; }
.mull-card { cursor: pointer; transition: transform 0.12s, opacity 0.12s; }
.mull-card--out { opacity: 0.45; transform: translateY(8px) rotate(-2deg); outline: 2px dashed #ff7a7a; outline-offset: 2px; }

/* ---- sound + animation ---- */
.sound-toggle { position: fixed; right: 10px; bottom: 10px; z-index: 60; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-size: 18px; cursor: pointer; opacity: 0.8; }
.sound-toggle:hover { opacity: 1; border-color: var(--accent); }
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 55; overflow: hidden; }
.fx-float { position: fixed; font-weight: 800; font-size: 26px; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8); white-space: nowrap; }
.fx-float--dmg { color: #ff6b6b; }
.fx-float--big { color: #ff3b3b; font-size: 38px; }
.fx-float--heal { color: #6ee79a; }
.fx-ghost { position: fixed; width: 118px; min-height: 76px; pointer-events: none; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6); display: flex; flex-direction: column; gap: 4px; padding: 8px; }
.pack-card { animation-delay: calc(var(--i, 0) * 0.22s); }
.pack-card--legendary { animation: pack-pop 0.35s ease both, legend-glow 1.6s ease-in-out 0.6s 2; animation-delay: calc(var(--i, 0) * 0.22s), calc(var(--i, 0) * 0.22s + 0.4s); }
@keyframes legend-glow { 0%, 100% { box-shadow: 0 0 12px #f2a83b66; } 50% { box-shadow: 0 0 30px 6px #f2a83bcc; } }

/* =============================================================================
   Mobile / touch pass
   ============================================================================= */
html { -webkit-text-size-adjust: 100%; }
body { overscroll-behavior-y: none; } /* a stray pull-down must not reload a match in progress */
button, .btn, .game-card, .type-pick, summary, label { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.game-card, .type-pick, .btn { -webkit-user-select: none; user-select: none; }
.screen { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
.sound-toggle { bottom: calc(10px + env(safe-area-inset-bottom)); right: calc(10px + env(safe-area-inset-right)); }

/* Touch screens: fingers need ~44px targets. */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn-small { min-height: 36px; padding: 6px 12px; }
  .db-stepper .btn { min-width: 40px; min-height: 40px; }
  input[type="checkbox"] { width: 20px; height: 20px; }
  .wheel-ref summary, .hub-odds summary { padding: 10px 0; }
  .perk-opt, .db-row, .type-pick { min-height: 44px; }
  .game-card:hover:not(:disabled), .type-pick:hover { border-color: inherit; } /* no sticky hover after a tap */
}

@media (max-width: 640px) {
  .screen { padding: 12px 10px calc(88px + env(safe-area-inset-bottom)); }
  h1 { font-size: 19px; }
  .phase { margin-bottom: 12px; font-size: 13px; }
  input, select, textarea { font-size: 16px !important; } /* stops iOS zooming in on focus */

  /* start screen: skip the essay, keep Start within reach */
  .start-intro { display: none; }
  .deck-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .deck-row .deck-blurb, .deck-row .bot-toggle { grid-column: 1 / -1; }
  .type-cols { gap: 8px; margin: 4px 0 12px; }
  .type-col { min-width: 0; flex-basis: 100%; }
  .account-bar, .daily-strip, .tutorial-strip { font-size: 12px; }

  /* battle: both heroes side by side, compact */
  .board { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
  .hero { padding: 8px; min-width: 0; border-radius: 10px; flex: none; }
  .hero-name { font-size: 14px; }
  .hero-head { flex-wrap: wrap; gap: 2px; }
  .hero-form { font-size: 11px; margin-bottom: 6px; }
  .hpbar { height: 20px; margin-bottom: 6px; }
  .hpbar-text { font-size: 11px; }
  .meters, .piles { gap: 2px 8px; font-size: 11px; }
  .chip-row { margin-top: 4px; gap: 3px; }
  .chip { font-size: 10px; padding: 1px 5px; }
  .rel { font-size: 10px; padding: 1px 5px; }
  .turn-timer { height: 22px; margin-bottom: 8px; }

  .controls { padding: 10px; margin-bottom: 10px; }
  .controls .handoff { margin-bottom: 6px; }
  .matchup, .threat { font-size: 12px; margin-bottom: 6px; }
  .controls > .hint { display: none; }
  .controls .btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .controls .btn { min-height: 46px; padding: 8px 10px; font-size: 14px; }
  #attack-btn, #move-btn { grid-column: 1 / -1; }

  /* hand: one swipeable row so the whole thing isn't a mile tall */
  .hand { padding: 8px 10px; margin-bottom: 10px; }
  .hand h3::after { content: "  swipe for more ›"; font-weight: 400; font-size: 11px; opacity: 0.7; }
  .hand .hand-row { flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
  .hand .game-card { flex: 0 0 142px; width: 142px; scroll-snap-align: start; }
  .mulligan .game-card { width: calc(50% - 5px); }
  .log { padding: 8px 10px; }
  .log ul { max-height: 260px; overflow-y: auto; }

  /* deck builder / collection / cards hub */
  .db-filters { position: static; }
  .db-filters input[type="search"] { min-width: 100%; }
  .db-filters select { flex: 1 1 45%; min-width: 0; }
  .db-row { gap: 8px; padding: 8px 10px; }
  .perk-list { grid-template-columns: 1fr; }
  .coll-grid { grid-template-columns: 1fr; }
  .quest { grid-template-columns: 1fr auto; }
  .quest-bar { grid-column: 1 / -1; order: 3; }
  .pack-card { width: calc(50% - 4px); }
  .hub-bar { gap: 6px; }
  .hub-stat { padding: 5px 9px; font-size: 12px; }
  .wheel-ref { overflow-x: auto; }
  .online-code { font-size: 36px; letter-spacing: 6px; }

  /* tutorial coach: keep it slim so the board stays visible */
  .coach { padding: 8px 10px; margin-bottom: 8px; }
  .coach-text { font-size: 13px; margin: 4px 0 6px; }
  .coach-head { font-size: 11px; }

  .help-card { padding: 14px 16px; }
  .sound-toggle { width: 38px; height: 38px; font-size: 16px; opacity: 0.7; }
}

/* perk pickers fold on phones */
.db-perk > summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 6px; }
.db-perk > summary::-webkit-details-marker { display: none; }
.db-perk-h { font-size: 14px; color: var(--ink-dim); font-weight: 700; }
.db-perk-cur { font-size: 13px; color: #d9c8ff; font-weight: 700; }
.db-perk:not([open]) > summary::after { content: "▸"; color: var(--ink-dim); }
.db-perk[open] > summary::after { content: "▾"; color: var(--ink-dim); }
input[type="checkbox"], input[type="radio"] { flex-shrink: 0; }
#db-more, #hub-more { margin-top: 8px; width: 100%; }
@media (max-width: 640px) {
  .db-total { position: sticky; top: 6px; z-index: 4; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5); }
  .db-row--hub { flex-direction: column; align-items: stretch; }
  .db-row--hub .hub-card-actions { flex-direction: row; }
  .db-row--hub .hub-card-actions .btn { flex: 1; }
}

/* ---- shop ---- */
.shop { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 0 0 14px; }
.shop h3 { margin: 0 0 8px; font-size: 14px; color: var(--ink-dim); }
.shop-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.shop-item { display: flex; flex-direction: column; gap: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.shop-item--founder { border-color: #f2a83b; background: #2b2412; }
.shop-blurb { font-size: 12px; color: var(--ink-dim); flex: 1; }
.shop-strip { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #2b2412; border: 1px solid #f2a83b; color: #ffe2a3; border-radius: 8px; padding: 8px 12px; margin: 0 0 10px; font-size: 13px; flex-wrap: wrap; }
.founder-badge { color: #ffd66e; font-weight: 700; margin-left: 4px; }

/* =============================================================================
   App shell: bottom tab bar, home (Battle), Social, Events
   ============================================================================= */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; justify-content: center; gap: 0; background: #10131a; border-top: 1px solid var(--line); padding: 4px max(6px, env(safe-area-inset-left)) calc(4px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-right)); }
.tab { flex: 1 1 0; max-width: 156px; display: flex; flex-direction: column; align-items: center; gap: 1px; background: transparent; border: none; border-top: 3px solid transparent; border-radius: 0 0 10px 10px; color: var(--ink-dim); font: inherit; font-size: 11px; font-weight: 700; padding: 6px 2px 4px; cursor: pointer; min-height: 54px; }
.tab-icon { font-size: 22px; line-height: 1.1; filter: grayscale(0.7); }
.tab--on { color: #fff; border-top-color: var(--accent); background: #1a2236; }
.tab--on .tab-icon { filter: none; }
.tab:hover { color: #fff; }
.screen:has(.tabbar) { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
body:has(.tabbar) .sound-toggle { bottom: calc(76px + env(safe-area-inset-bottom)); }

.subnav { display: inline-flex; gap: 4px; margin-left: 10px; vertical-align: middle; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; font-size: 13px; font-weight: 600; }
.subnav-btn { font: inherit; font-size: 13px; font-weight: 700; color: var(--ink-dim); background: transparent; border: none; border-radius: 999px; padding: 5px 14px; cursor: pointer; min-height: 30px; }
.subnav-btn--on { background: var(--accent-strong); color: #fff; }

/* home */
.hub-bar--home { margin: 0 0 10px; }
.home-h { margin: 14px 0 6px; font-size: 14px; color: var(--ink-dim); }
.deck-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 8px; margin-bottom: 8px; }
.home-detail { margin: 0 0 10px; font-size: 13px; }
.home-detail > summary { cursor: pointer; color: #7fa8e0; font-weight: 600; padding: 6px 0; }
.btn-battle { display: block; width: 100%; font-size: 20px; padding: 16px 22px; margin-top: 12px; background: linear-gradient(180deg, #3b82f6, #2563d8); box-shadow: 0 4px 0 #1b4aa8, 0 8px 18px rgba(0, 0, 0, 0.45); letter-spacing: 0.02em; }
.btn-battle:active { transform: translateY(2px); box-shadow: 0 2px 0 #1b4aa8; }
.home-sub { margin: 6px 0 12px; text-align: center; }
.home-modes { margin-bottom: 12px; }
.home-modes .btn { flex: 1 1 160px; }

/* social + events */
.profile-card { display: flex; gap: 14px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 0 0 14px; }
.avatar { width: 56px; height: 56px; flex: 0 0 56px; border-radius: 50%; background: linear-gradient(135deg, #3b82f6, #7a5cc0); display: grid; place-items: center; font-size: 24px; font-weight: 800; }
.profile-name { font-size: 18px; font-weight: 800; }
.profile-stats { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--ink-dim); }
.profile-stats b { color: var(--ink); }
.soon-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.soon-card { display: flex; flex-direction: column; gap: 4px; background: var(--panel); border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; opacity: 0.8; font-size: 13px; }
.soon-card span { color: var(--ink-dim); font-size: 12px; }
.arena-list { display: flex; flex-direction: column; gap: 6px; }
.arena { display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.arena b { display: block; }
.arena span { color: var(--ink-dim); }
.arena--now { border-color: #f2a83b; background: #2b2412; }
.arena--locked { opacity: 0.6; }
.arena-n { font-size: 18px; text-align: center; }
.arena-tr { font-size: 12px; font-weight: 700; }
#soc-deck { max-width: 100%; }

@media (max-width: 640px) {
  .tab { font-size: 10px; min-height: 52px; }
  .btn-battle { font-size: 18px; padding: 14px 18px; }
  .deck-strip { grid-template-columns: 1fr 1fr; }
  .subnav { margin-left: 4px; }
  .profile-card { padding: 10px; }
  body:has(.tabbar) .sound-toggle { bottom: calc(68px + env(safe-area-inset-bottom)); }
}

/* ---- tab order: Battle in the middle, raised ---- */
.tab[data-tab="battle"] { background: linear-gradient(180deg, #1d3a74, #172a52); color: #fff; border-radius: 12px; margin: -10px 4px 0; border-top-color: #6ea8fe; box-shadow: 0 -2px 10px rgba(59, 130, 246, 0.35); }
.tab[data-tab="battle"] .tab-icon { font-size: 26px; filter: none; }
.tab[data-tab="battle"].tab--on { background: linear-gradient(180deg, #2a55b0, #1d3a74); }
.tab { position: relative; }
.tab-badge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: #e2564d; color: #fff; font-size: 10px; font-weight: 800; line-height: 16px; text-align: center; font-style: normal; filter: none; }
.tab-badge[hidden] { display: none; }

/* ---- friends ---- */
.my-code { margin: 2px 0 6px; font-size: 13px; color: var(--ink-dim); }
.my-code b { color: #ffd66e; font-size: 16px; letter-spacing: 2px; margin: 0 4px; }
.profile-name .btn { margin-left: 6px; vertical-align: middle; }
.add-friend { display: flex; gap: 8px; margin: 0 0 6px; }
.add-friend input { flex: 1; min-width: 0; font: inherit; font-size: 15px; letter-spacing: 1px; text-transform: uppercase; color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
#soc-msg { min-height: 20px; margin: 0 0 8px; color: #ffd66e; }
.friend-list { display: flex; flex-direction: column; gap: 6px; }
.friend-h { margin: 10px 0 2px; font-size: 13px; color: var(--ink-dim); }
.friend { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.friend-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.friend-main .hint { font-size: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #555c73; flex: 0 0 10px; }
.dot--on { background: #4bd07a; box-shadow: 0 0 6px #4bd07a; }
.challenge-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; background: #2b2412; border: 1px solid #f2a83b; color: #ffe2a3; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; font-size: 14px; }

/* ---- ranked ---- */
.hub-stat--trophy b { color: #ffd66e; }
.arena-bar { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; margin: 0 0 10px; font-size: 12px; color: var(--ink-dim); }
.arena-bar .quest-bar { height: 10px; }
.arena-bar-n { grid-column: 1 / -1; }
.arena--done { opacity: 0.85; border-color: #2f6b45; }
.queue-card { padding: 28px 18px; }
.queue-clock { font-size: 44px; font-weight: 800; margin: 4px 0 10px; font-variant-numeric: tabular-nums; }
.queue-spinner { width: 34px; height: 34px; margin: 6px auto 14px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .queue-spinner { animation-duration: 3s; } }

/* phones: keep the Battle button on the first screen */
@media (max-width: 640px) {
  .deck-strip { display: flex; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 4px; gap: 8px; }
  .deck-strip .type-pick { flex: 0 0 150px; scroll-snap-align: start; }
  .deck-strip .type-pick-blurb, .deck-strip .type-pick-aff { display: none; }
  .home-detail .deck-strip .type-pick-blurb { display: block; }
  .daily-strip, .tutorial-strip, .shop-strip { flex-wrap: nowrap; gap: 8px; padding: 6px 10px; }
  .daily-strip > span, .tutorial-strip > span, .shop-strip > span { flex: 1; min-width: 0; }
  .daily-strip .btn, .tutorial-strip .btn, .shop-strip .btn { flex: 0 0 auto; }
  .home-h { margin-top: 8px; }
}

/* ---- teams ---- */
.team-badge { display: inline-block; font-size: 11px; font-weight: 700; color: var(--team, #ccc); border: 1px solid var(--team, #555); border-radius: 999px; padding: 1px 8px; margin-left: 4px; vertical-align: middle; background: rgba(0, 0, 0, 0.25); white-space: nowrap; }
.team-line { margin: -2px 0 8px; }
.team-strip { margin-bottom: 10px; }
.team-screen h1 { margin-bottom: 8px; }
.waykeeper { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid #d9c8ff; border-radius: 10px; padding: 10px 14px; margin: 0 0 10px; font-size: 14px; }
.waykeeper p { margin: 4px 0 0; font-style: italic; color: var(--ink-dim); line-height: 1.5; }
.waykeeper-name { font-weight: 800; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: #d9c8ff; }
.team-warning { background: #3a2f12; border: 1px solid #f2a83b; color: #ffe2a3; border-radius: 8px; padding: 8px 12px; margin: 0 0 12px; font-size: 14px; }
.team-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 12px; }
.team-card { background: var(--panel); border: 2px solid var(--team); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3) inset, 0 6px 22px rgba(0, 0, 0, 0.35); }
.team-card header { display: flex; align-items: center; gap: 10px; }
.team-card h2 { margin: 0; font-size: 18px; color: var(--team); }
.team-card p { margin: 0; font-size: 14px; line-height: 1.45; }
.team-emoji { font-size: 34px; }
.team-creed { font-style: italic; color: var(--ink-dim); font-size: 13px !important; }
.team-feel { color: var(--ink-dim); font-size: 13px !important; }
.team-classes { display: flex; flex-direction: column; gap: 4px; }
.team-classes-h { font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-dim); }
.team-class { display: flex; flex-direction: column; background: var(--panel-2); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.team-class span { color: var(--ink-dim); font-size: 12px; }
.team-dark summary { cursor: pointer; font-size: 13px; color: #f0a29c; padding: 4px 0; }
.team-dark p { font-size: 13px !important; color: var(--ink-dim); }
.team-pick { margin-top: auto; background: var(--team); color: #14161c; width: 100%; }
.team-pick:hover { background: var(--team); filter: brightness(1.12); }
.team-confirm { border-color: var(--team); }
.team-confirm h2 { color: var(--team); }
.team-err { color: #f0a29c; min-height: 18px; font-size: 14px; }

/* ---- tutorial envoys + relic cards ---- */
.coach-envoy { margin: 6px 0 2px; padding: 6px 10px; border-left: 3px solid var(--team, #d9c8ff); background: rgba(0, 0, 0, 0.22); border-radius: 0 8px 8px 0; font-size: 13px; font-style: italic; color: #d8e6fb; line-height: 1.4; }
.coach-envoy-who { font-style: normal; font-weight: 800; font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--team, #d9c8ff); margin-right: 4px; }
.game-card--relic { border-color: var(--team); border-left: 4px solid var(--team); background: linear-gradient(180deg, color-mix(in srgb, var(--team) 14%, var(--panel-2)), var(--panel-2)); }
.game-card--relic .game-card-kind { color: var(--team); }
.team-sampled { background: color-mix(in srgb, var(--team) 16%, transparent); border: 1px dashed var(--team); border-radius: 8px; padding: 6px 10px; font-size: 13px !important; }
@media (max-width: 640px) { .coach-envoy { font-size: 12px; padding: 4px 8px; } }

/* ---- class locking ---- */
.type-pick--locked { opacity: 0.55; cursor: not-allowed; border-style: dashed; }
.coll-tile--locked { opacity: 0.7; border-style: dashed; }
.coll-lock { color: #f0a29c; }

/* ---- story events ---- */
.event-card { display: flex; gap: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.event-card--done { border-color: #2f6b45; }
.event-art { font-size: 40px; width: 64px; height: 64px; flex: 0 0 64px; display: grid; place-items: center; border-radius: 12px; background: linear-gradient(135deg, #2b2412, #3a2f5c); }
.event-main { flex: 1; min-width: 0; }
.event-main h3 { margin: 0 0 4px; font-size: 17px; color: var(--ink); }
.event-main p { margin: 0 0 6px; font-size: 14px; }
.event-status { font-size: 12px !important; color: #ffd66e; font-weight: 700; }
.story-screen { max-width: 640px; }
.story-kicker { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-dim); margin: 0 0 8px; }
.story-dots { margin-left: 8px; }
.story-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #3a4160; margin-right: 4px; }
.story-dot--done { background: #4bd07a; }
.story-dot--now { background: #ffd66e; box-shadow: 0 0 6px #ffd66e; }
.story-art { height: 140px; border-radius: 14px; display: grid; place-items: center; font-size: 64px; margin-bottom: 12px; background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--team, #7a5cc0) 40%, #14161c), #14161c 70%); border: 1px solid var(--line); }
.story-art--win { background: radial-gradient(circle at 50% 40%, #3a2f12, #14161c 70%); border-color: #f2a83b; }
.story-art--lose { background: radial-gradient(circle at 50% 40%, #2a2740, #14161c 70%); }
.story-title { font-size: 24px; margin: 0 0 10px; }
.story-text p { font-size: 16px; line-height: 1.6; margin: 0 0 12px; color: #e3e6f0; }
.story-text p:first-child::first-letter { font-size: 1.6em; font-weight: 800; color: #d9c8ff; }
.story-fight { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid #e2564d; border-radius: 10px; padding: 10px 14px; margin: 6px 0 14px; }
.story-fight p { margin: 4px 0; font-size: 14px; color: var(--ink-dim); }
.story-rule { color: #ffd66e !important; font-weight: 700; }
.story-deck { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-dim); margin-top: 8px; }
.story-deck select { max-width: 100%; }
.story-rewards { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 6px; }
.story-rewards li { background: #1f2a1f; border: 1px solid #2f6b45; border-radius: 8px; padding: 6px 10px; font-size: 14px; color: #bff0c8; }
.rule-banner { margin: 0 0 8px; font-size: 13px; font-weight: 700; color: #ffd66e; background: #2b2412; border: 1px solid #f2a83b; border-radius: 8px; padding: 6px 10px; }
.cosmetic-badge { font-size: 16px; margin-left: 3px; vertical-align: middle; }
.profile-title { font-size: 12px; font-style: italic; color: #d9c8ff; margin: -2px 0 4px; }
@media (max-width: 640px) { .story-art { height: 110px; font-size: 52px; } .story-title { font-size: 21px; } .event-art { width: 52px; height: 52px; flex-basis: 52px; font-size: 32px; } }

.story-rewards--lose li { background: #2a2230; border-color: #6b4f8c; color: #d9c8ff; }

/* ---- card sets ---- */
.db-flavor { font-size: 11px; font-style: italic; color: #8f87b8; }
.db-set { font-size: 10px; font-weight: 700; border-radius: 999px; padding: 1px 7px; background: #3a2f5c; color: #d9c8ff; }

/* ---- team relic pack gift ---- */
.relic-gift { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: linear-gradient(120deg, color-mix(in srgb, var(--team) 22%, var(--panel)), var(--panel)); border: 2px solid var(--team); border-radius: 12px; padding: 12px 14px; margin: 0 0 12px; }
.relic-gift-art { font-size: 34px; }
.relic-gift > div { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 2px; }
.relic-gift span:not(.relic-gift-art) { font-size: 13px; color: var(--ink-dim); }
.relic-gift .btn-big { margin-top: 0; background: var(--team); color: #14161c; }
.relic-strip { border-color: #d9c8ff; background: #241f3a; color: #e6dcff; }

/* ---- turf war ---- */
.turf-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.turf-time { margin: 0 0 8px; font-size: 13px; color: var(--ink-dim); }
.turf-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.turf-row { display: grid; grid-template-columns: 150px 1fr; gap: 2px 10px; align-items: center; padding: 6px 8px; border-radius: 10px; border: 1px solid transparent; }
.turf-row--mine { border-color: var(--team); background: color-mix(in srgb, var(--team) 10%, transparent); }
.turf-name { font-weight: 700; font-size: 14px; color: var(--team); }
.turf-name i { font-style: normal; font-weight: 400; font-size: 11px; color: var(--ink-dim); }
.turf-bar { height: 12px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.turf-bar span { display: block; height: 100%; background: var(--team); border-radius: 999px; transition: width 0.4s ease-out; }
.turf-nums { grid-column: 1 / -1; font-size: 12px; color: var(--ink-dim); }
.turf-nums b { color: var(--ink); font-size: 14px; }
.turf-me { margin: 4px 0 8px; font-size: 14px; }
.turf-last { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 10px; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); font-size: 13px; }
.turf-last--claim { background: #2b2412; border: 1px solid #f2a83b; color: #ffe2a3; }
.turf-claim { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.turf-rules { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--ink-dim); display: flex; flex-direction: column; gap: 4px; }
@media (max-width: 640px) { .turf-row { grid-template-columns: 1fr; } }

/* ---- safety ---- */
.safety-card { max-width: 420px; }
.report-reasons { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.menu-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.post-match { align-items: center; margin-top: 10px; }

/* ---- clans ---- */
.clan-tag { color: #d9c8ff; font-weight: 700; font-size: 0.9em; }
.clan-head h2 { margin: 0 0 2px; font-size: 22px; }
.clan-form { display: flex; flex-direction: column; gap: 10px; }
.clan-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-dim); }
.clan-form input[type="text"] { font: inherit; font-size: 15px; color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.clan-form .bot-toggle { flex-direction: row; }
.clan-summary p { margin: 0 0 8px; }
.goal-bar { position: relative; height: 16px; background: var(--panel-2); border-radius: 999px; margin: 6px 0 26px; }
.goal-bar > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #4bd07a, #ffd66e); transition: width 0.4s ease-out; }
.goal-bar > i { position: absolute; top: -3px; width: 3px; height: 22px; background: #5a6180; transform: translateX(-2px); border-radius: 2px; }
.goal-bar > i.goal-tick--hit { background: #ffd66e; }
.goal-tiers { display: flex; justify-content: space-between; margin-top: -20px; margin-bottom: 8px; font-size: 11px; color: var(--ink-dim); text-align: right; gap: 4px; }
.goal-tiers span { flex: 1; text-align: right; }
.goal-tiers b { color: var(--ink); }
.goal-tier--hit { color: #ffd66e; }
.emote-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.emote-bar .btn span { font-size: 12px; }
.clan-feed { max-height: 180px; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.feed-row--you { color: #bfe0ff; }
@media (max-width: 640px) { .emote-bar .btn span { display: none; } }

/* ---- leaderboards ---- */
.lb-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 14px; }
.lb-row { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.lb-row--you { border-color: #ffd66e; background: color-mix(in srgb, #ffd66e 10%, var(--panel)); }
.lb-rank { min-width: 34px; font-weight: 700; color: var(--ink-dim); }
.lb-main { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lb-main b { overflow: hidden; text-overflow: ellipsis; }
.lb-score { font-weight: 700; white-space: nowrap; }

/* ---- weekly gauntlet ---- */
.gl-card { display: flex; flex-direction: column; gap: 8px; }
.gl-lineup { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.gl-step { display: flex; flex-direction: column; align-items: center; gap: 2px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 4px; font-size: 12px; text-align: center; }
.gl-step--done { border-color: #4bd07a; color: #4bd07a; }
.gl-step--next { border-color: #ffd66e; box-shadow: 0 0 0 1px #ffd66e inset; }
.gl-n { font-weight: 700; font-size: 14px; }
.gl-start { display: flex; flex-direction: column; gap: 8px; }
.gl-start select { font: inherit; color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }

/* ---- phone battle layout: the whole match fits one screen, no scrolling; actions sit in the thumb zone ---- */
.battle-top, .ticker, .piles-mini, .lbl-short { display: none; }
.log-sheet { max-height: 55vh; overflow-y: auto; margin: 8px 0; padding-left: 18px; font-size: 13px; }
.log-sheet li { margin-bottom: 4px; }
@media (max-width: 640px) {
  body:has(.battle-screen) .sound-toggle { display: none; }
  .battle-screen { display: flex; flex-direction: column; min-height: 100dvh; padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); gap: 6px; }
  .battle-screen > h1, .battle-screen > .online-banner { display: none; }
  .battle-screen > * { margin-top: 0; margin-bottom: 0; }
  .battle-top { display: flex; align-items: center; gap: 4px; }
  .battle-top-text { flex: 1; min-width: 0; font-size: 12px; font-weight: 700; color: #bfe0ff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .battle-top .btn { min-height: 34px; min-width: 38px; padding: 4px 8px; font-size: 15px; }
  .battle-screen .rule-banner { font-size: 11px; padding: 3px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .battle-screen .online-notice { margin: 0; padding: 4px 8px; font-size: 12px; }
  .battle-screen .turn-timer { height: 16px; margin: 0; }
  .battle-screen .turn-timer-text { font-size: 11px; }

  .battle-screen .board { gap: 6px; margin: 0; }
  .battle-screen .hero { padding: 6px 8px; }
  .battle-screen .hero-name { font-size: 13px; }
  .battle-screen .hero-form { margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .battle-screen .hpbar { height: 18px; margin-bottom: 4px; }
  .battle-screen .meters { font-size: 11px; }
  .battle-screen .piles { display: none; }
  .battle-screen .piles-mini { display: flex; gap: 8px; font-size: 11px; color: var(--ink-dim); margin-top: 2px; }
  .battle-screen .chip-row { max-height: 40px; overflow: hidden; }

  /* thumb zone: threat line, then the actions, then the hand — pushed to the bottom of the screen */
  .battle-screen .controls { margin-top: auto; padding: 8px; }
  .battle-screen .controls .handoff, .battle-screen .controls .matchup, .battle-screen .controls .wheel-ref, .battle-screen .controls > .hint { display: none; }
  .battle-screen .controls .threat { margin: 0 0 6px; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .battle-screen .controls .btn-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .battle-screen .controls #attack-btn { grid-column: span 3; min-height: 50px; font-size: 16px; }
  .battle-screen .controls #attack-btn:has(+ #move-btn) { grid-column: span 2; }
  .battle-screen .controls #move-btn { grid-column: span 1; min-height: 50px; padding: 4px 6px; font-size: 12px; }
  .battle-screen .controls .btn { min-height: 44px; padding: 6px 4px; font-size: 13px; }
  .battle-screen .controls #forfeit-btn { display: none; }
  .battle-screen .controls #brace-btn { grid-column: span 1; }
  .battle-screen .lbl-long { display: none; }
  .battle-screen .lbl-short { display: inline; }
  .battle-screen .controls .handoff:only-child { display: block; margin: 0; text-align: center; }

  .battle-screen .hand { margin: 0; padding: 4px 6px; }
  .battle-screen .hand h3 { display: none; }
  .battle-screen .hand .hand-row { gap: 6px; padding-bottom: 2px; }
  .battle-screen .hand .game-card { flex: 0 0 108px; width: 108px; min-height: 0; max-height: 128px; padding: 5px 6px; gap: 2px; overflow: hidden; }
  .battle-screen .hand .game-card-name { font-size: 12px; line-height: 1.15; }
  .battle-screen .hand .game-card-text { font-size: 10px; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
  .battle-screen .hand .game-card-kind { font-size: 9px; }
  .battle-screen .hand .game-card-cost { font-size: 11px; }

  .battle-screen .ticker { display: block; width: 100%; text-align: left; font: inherit; font-size: 12px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .battle-screen .log { display: none; }
  .battle-screen .coach { margin: 0; }
}
@media (max-width: 640px) and (min-height: 740px) {
  .battle-screen { gap: 10px; }
  .battle-screen .hero { padding: 10px; }
  .battle-screen .hero-name { font-size: 15px; }
  .battle-screen .hpbar { height: 22px; }
  .battle-screen .meters, .battle-screen .piles-mini { font-size: 12px; }
  .battle-screen .controls #attack-btn { min-height: 58px; font-size: 17px; }
  .battle-screen .controls .btn { min-height: 48px; font-size: 14px; }
  .battle-screen .hand .game-card { flex-basis: 128px; width: 128px; max-height: 190px; padding: 8px; gap: 3px; }
  .battle-screen .hand .game-card-name { font-size: 14px; }
  .battle-screen .hand .game-card-text { font-size: 11px; -webkit-line-clamp: 6; }
  .battle-screen .ticker { font-size: 13px; padding: 8px 10px; }
}

/* ---- phone home (Battle tab): one screen, Battle button under the thumb ---- */
.home-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.home-top h1 { margin: 0; }
.home-top-actions { display: flex; align-items: center; gap: 6px; }
.home-login-hint { margin: 2px 0 6px; }
@media (max-width: 640px) {
  .home { display: flex; flex-direction: column; min-height: 100dvh; padding-top: 8px; gap: 8px; }
  .home > * { margin-top: 0; margin-bottom: 0; }
  .home .hub-bar--home { flex-wrap: nowrap; }
  .home .hub-stat { flex: 1; justify-content: center; padding: 5px 6px; }
  .home .team-line { margin: 0; }
  .home .home-h { margin: 4px 0 0; }
  .home .online-notice { margin: 0; padding: 4px 8px; font-size: 12px; }
  .home .deck-strip { margin-bottom: 0; }
  .home .deck-strip .type-pick { flex-basis: 132px; padding: 8px 10px; }
  .home .deck-strip .type-pick-perks { display: none; }
  .home-actions { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
  .home-actions .btn-battle { margin-top: 0; padding: 20px 18px; font-size: 21px; }
  .home-actions .home-modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; margin: 0; }
  .home-actions .home-modes .btn { padding: 10px 4px; font-size: 13px; min-height: 46px; }
  .home-actions .home-detail { margin: 0; }
}
@media (max-width: 640px) {
  .battle-screen .controls #newgame-btn { width: 100%; min-height: 56px; font-size: 17px; }
  .battle-screen .gameover { margin: 0 0 8px; text-align: center; font-size: 22px; }
  .battle-screen .post-match { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
}

/* ---- sub-tabs inside hub screens ---- */
.subtabs { display: flex; gap: 6px; overflow-x: auto; margin: 4px 0 10px; padding-bottom: 2px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }
.subtab { flex: 1 0 auto; font: inherit; font-size: 14px; font-weight: 600; color: var(--ink-dim); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; min-height: 40px; white-space: nowrap; cursor: pointer; }
.subtab--on { color: #fff; background: #2a4f95; border-color: #4aa3ff; }
[data-pane][hidden] { display: none !important; }
@media (max-width: 640px) {
  .profile-card { padding: 8px 10px; gap: 10px; }
  .profile-stats { gap: 4px 10px; font-size: 11px; }
}
@media (max-width: 640px) {
  /* decks: two per row, perks and lock essay folded away, so four decks fit one screen */
  .coll-grid { grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 10px; }
  .coll-tile { padding: 10px; gap: 6px; }
  .coll-tile .coll-name { font-size: 15px; }
  .coll-tile .coll-meta:nth-of-type(2), .coll-tile .coll-lock { display: none; }
  .coll-tile .btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .coll-tile .btn-row .btn { min-height: 40px; padding: 6px 4px; font-size: 13px; }
}
.coll-progress > summary { cursor: pointer; padding: 8px 0; color: var(--ink); list-style: none; }
.coll-progress > summary::-webkit-details-marker { display: none; }
.coll-progress > summary::after { content: " ▸"; color: var(--ink-dim); }
.coll-progress[open] > summary::after { content: " ▾"; }
@media (max-width: 640px) {
  .hub-bar { flex-wrap: nowrap; }
  .hub-bar .hub-stat { flex: 1; justify-content: center; padding: 5px 4px; }
}
@media (max-width: 640px) and (max-height: 700px) {
  .battle-screen .coach { padding: 6px 8px; }
  .battle-screen .coach-envoy { display: none; }
  .battle-screen .coach-text { font-size: 12px; margin: 2px 0 4px; }
  .battle-screen .coach .btn { min-height: 34px; padding: 4px 12px; }
  .battle-screen .hand .game-card { max-height: 104px; }
  .battle-screen .hero { padding: 4px 8px; }
  .battle-screen .controls { padding: 6px; }
  .battle-screen .controls .btn { min-height: 40px; }
  .battle-screen .controls #attack-btn { min-height: 44px; }
}

/* ---- weekly track ---- */
.tr-bar { margin: 4px 0 8px; }
.tr-list { display: flex; flex-direction: column; gap: 6px; }
.tr-tier { display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.tr-tier--ready { border-color: #ffd66e; background: color-mix(in srgb, #ffd66e 10%, var(--panel-2)); }
.tr-tier--done { opacity: 0.6; }
.tr-pts { font-weight: 700; color: var(--ink-dim); }
.tr-prize { font-size: 14px; }
.tr-state { font-size: 16px; min-width: 34px; text-align: center; }
@media (max-width: 640px) {
  /* trims so the Events panes fit a phone screen */
  .arena > div > span { display: none; }
  .arena { padding: 8px 10px; }
  .gl-card { gap: 6px; padding: 10px; }
  .gl-step { padding: 6px 2px; }
  .gl-start select, .gl-start .btn { min-height: 44px; }
  [data-pane] .db-group { margin-bottom: 8px; }
}
@media (max-width: 640px) { .more-soon { display: none; } }

@media (max-width: 640px) {
  .home-actions .home-modes { gap: 6px; }
  .home-actions .home-modes .btn { padding: 10px 2px; font-size: 12px; white-space: nowrap; }
}
