/* ==========================================================================
   Blitz Grid — Minimal Single-Viewport Chess.com Layout (Zero Scroll)
   ========================================================================== */

.app-shell {
  --board-h: clamp(320px, calc(100vh - 216px), 740px);
  --board-h: clamp(320px, calc(100dvh - 216px), 740px);
  --board-w: min(calc(100vw - 340px), calc(var(--board-h) * 0.75));
  --actual-h: calc(var(--board-w) * 1.333333);

  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--bg-app);
  -webkit-tap-highlight-color: transparent;
}

/* Center Stage: Eval Bar + Board Column */
.stage-wrap {
  display: flex;
  align-items: stretch;
  gap: 8px;
  height: calc(var(--actual-h) + 186px);
  max-height: calc(100vh - 24px);
}

/* Slim Chess.com Vertical Eval Bar */
.eval-column {
  width: 16px;
  display: flex;
  flex-direction: column;
  padding-top: 44px;
  padding-bottom: 152px;
}

.eval-bar {
  position: relative;
  flex: 1;
  width: 16px;
  border-radius: 3px;
  overflow: hidden;
  background: #23211e;
  border: 1.5px solid #191816;
}

.eval-fill-white {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: #edeae0;
  transition: height 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

.eval-midline {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1.5px;
  background: rgba(120, 116, 108, 0.65);
  pointer-events: none;
}

/* Main Board Column — exact width lock */
.board-column {
  width: var(--board-w);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Player & Opponent Strips (flush with board edges) */
.player-strip {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px;
}

.player-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.avatar-box {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  background: var(--bg-rail);
  border: 1.5px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.identity-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.identity-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  line-height: 1;
}

.player-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-elo {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.captured-row {
  display: flex;
  align-items: center;
  gap: 1px;
  height: 13px;
}

.captured-mini {
  width: 12px;
  height: 12px;
  opacity: 0.85;
}

.material-adv {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-left: 3px;
}

/* Right side of strip: HP bar + Clock */
.strip-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.hp-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.hp-bar-track {
  width: 76px;
  height: 10px;
  border-radius: 3px;
  background: var(--bg-inset);
  border: 1.5px solid #1b1917;
  overflow: hidden;
  position: relative;
}

/* Fighting-game / Clash delayed damage-drain trail behind HP fill */
.hp-bar-trail {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: #f0e3c4;
  transition: width 460ms cubic-bezier(0.22, 1, 0.36, 1) 140ms;
}

.hp-bar-fill {
  position: relative;
  height: 100%;
  transition: width 160ms ease-out, background-color 180ms ease;
}

.hp-bar-fill.healthy {
  background: #81b64c;
}

.hp-bar-fill.cracked {
  background: #dda938;
}

.hp-bar-fill.critical {
  background: #cc3f3b;
}

.hp-bar-notch {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: rgba(0, 0, 0, 0.45);
}

.hp-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 28px;
  text-align: right;
}

.match-clock {
  min-width: 66px;
  height: 30px;
  padding: 0 9px;
  border-radius: var(--r-sm);
  background: var(--bg-rail);
  border: 1.5px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.match-clock.overtime {
  background: #3d3118;
  border-color: var(--gold);
  color: #f6d57c;
}

.match-clock.sudden-death,
.match-clock.low-time {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: #ffd0ce;
}

/* Board Frame & Canvas Stack */
.board-frame {
  position: relative;
  width: var(--board-w);
  height: var(--actual-h);
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 2px solid #1d1c1a;
  background: var(--bg-rail);
  touch-action: none;
}

.board-frame.overtime-border {
  border-color: var(--gold);
}

.board-svg {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.vfx-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Subtle Banner Toast over Center of Board (Overtime / Breach / Sudden Death) */
.board-banner {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 6px 16px;
  border-radius: var(--r-sm);
  background: rgba(29, 28, 26, 0.92);
  border: 2px solid var(--gold);
  color: var(--ink-paper);
  font-family: var(--font-sketch);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  pointer-events: none;
  z-index: 12;
  animation: bannerPop 1.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes bannerPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -44%) scale(0.92);
  }
  14% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  80% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -56%) scale(0.98);
  }
}

/* Quiet single-line bot quip inside the right rail (never covers board) */
.bot-quip-bar {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-inset);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-style: italic;
  line-height: 1.35;
}

/* Elixir Bar + Card Hand Dock */
.dock-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.elixir-row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 20px;
}

.elixir-readout {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 34px;
  font-size: 13px;
  font-weight: 800;
  color: #e4c4f7;
}

.elixir-track {
  position: relative;
  flex: 1;
  height: 12px;
  border-radius: 3px;
  background: var(--bg-inset);
  border: 1.5px solid #1b1917;
  overflow: hidden;
}

.elixir-fill {
  height: 100%;
  background: var(--elixir);
  transition: width 60ms linear;
}

.elixir-fill.overtime {
  background: #b158e0;
}

.elixir-fill.pulse {
  animation: elixirFlash 420ms ease-out;
}

@keyframes elixirFlash {
  0% {
    filter: brightness(1.65);
  }
  100% {
    filter: brightness(1);
  }
}

.elixir-ticks {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  pointer-events: none;
}

.elixir-tick {
  border-right: 1px solid rgba(20, 18, 16, 0.55);
}

.elixir-tick:last-child {
  border-right: none;
}

.elixir-rate-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 24px;
  text-align: right;
}

.elixir-rate-tag.boosted {
  color: var(--gold);
}

/* 4-Card Hand + Next Slot */
.hand-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr) 54px;
  gap: 6px;
  height: 76px;
}

.card-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5px 4px 4px;
  border-radius: var(--r-md);
  background: #eae5d7;
  color: #1e1d1b;
  border: 2px solid #1c1b19;
  box-shadow: 0 2px 0 #181715;
  transition: transform 90ms ease, border-color 90ms ease, opacity 120ms ease;
  overflow: hidden;
  touch-action: none;
}

.card-tile.spell-card {
  background: #e1e6ec;
}

.card-tile:hover:not(:disabled) {
  transform: translateY(-2px);
}

.card-tile.selected {
  transform: translateY(-6px);
  border-color: var(--cta-green);
  box-shadow: 0 5px 0 #181715;
}

.card-tile.card-dealt {
  animation: cardDealGlide 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

.card-tile.card-unlock-pop {
  animation: cardUnlockPop 190ms ease-out;
}

@keyframes cardDealGlide {
  0% {
    opacity: 0.45;
    transform: translateX(-14px) scale(0.92);
  }
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes cardUnlockPop {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.06) translateY(-2px);
  }
  100% {
    transform: scale(1);
  }
}

.card-tile.unaffordable {
  opacity: 0.52;
  filter: saturate(0.45);
}

.card-charge-mask {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  background: rgba(24, 22, 20, 0.42);
  pointer-events: none;
}

.card-cost-pill {
  position: absolute;
  top: 3px;
  left: 4px;
  display: flex;
  align-items: center;
  gap: 1px;
  font-size: 11px;
  font-weight: 800;
  color: #5c2282;
  line-height: 1;
}

.card-hotkey {
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 9px;
  font-weight: 700;
  color: #6b675e;
}

.card-art {
  width: 34px;
  height: 34px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pair-art {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.pair-art svg:last-child {
  margin-left: -7px;
}

.card-label {
  margin-top: 2px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  color: #262421;
  letter-spacing: -0.01em;
}

.next-card-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: var(--r-md);
  background: var(--bg-rail);
  border: 1.5px dashed var(--border-strong);
  padding: 4px;
}

.next-tag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.next-art {
  width: 24px;
  height: 24px;
  opacity: 0.8;
}

.next-cost {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
}

/* ==========================================================================
   Slim Chess.com Right Rail
   ========================================================================== */
.right-rail {
  width: 280px;
  height: calc(var(--actual-h) + 186px);
  max-height: calc(100vh - 24px);
  background: var(--bg-rail);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.rail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 7px;
}

.brand-title {
  font-family: var(--font-sketch);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
  letter-spacing: 0.03em;
}

.rail-icon-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background-color 100ms ease, color 100ms ease;
}

.icon-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.icon-btn.active {
  background: var(--bg-surface);
  color: var(--cta-green);
}

/* Compact Rating & Streak Bar */
.rail-stats-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-rail-alt);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
}

.stat-pair {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-secondary);
  font-weight: 600;
}

.stat-pair strong {
  color: var(--text-primary);
  font-weight: 800;
}

/* Rail Body: Bot Selector OR Move Log */
.rail-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rail-section-label {
  padding: 8px 12px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Bot Selector List */
.bot-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bot-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: var(--r-sm);
  border: 1.5px solid transparent;
  background: transparent;
  text-align: left;
  transition: background-color 100ms ease, border-color 100ms ease;
}

.bot-item:hover {
  background: var(--bg-surface);
}

.bot-item.selected {
  background: var(--bg-surface);
  border-color: var(--cta-green);
}

.bot-item-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bot-item-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.bot-item-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.bot-item-elo {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.bot-item-tag {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Chess.com Live Move / Event List */
.move-log {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.move-row {
  display: grid;
  grid-template-columns: 38px 1fr 22px;
  align-items: center;
  padding: 5px 12px;
  font-size: 12px;
  gap: 6px;
}

.move-row:nth-child(even) {
  background: var(--bg-rail-alt);
}

.move-time {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}

.move-desc {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-primary);
  font-weight: 600;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid #161513;
}

.side-dot.white {
  background: #f4f1e6;
}

.side-dot.black {
  background: #3d3b37;
  border-color: #7c7972;
}

.move-log-empty {
  padding: 20px 14px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Compact Rail Tabs (Bots / 1v1 / Deck / History) */
.rail-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-inset);
}

.rail-tab {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: color 100ms ease, background-color 100ms ease;
}

.rail-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.rail-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--cta-green);
  background: var(--bg-rail);
}

/* Mode Segmented Switch inside Play tab */
.mode-segment {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px 8px 4px;
}

.mode-pill {
  height: 27px;
  border-radius: var(--r-sm);
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.mode-pill:hover {
  color: var(--text-primary);
}

.mode-pill.active {
  background: var(--bg-surface);
  border-color: var(--cta-green);
  color: var(--text-primary);
}

/* 1v1 Multiplayer Panel */
.mp-panel,
.deck-panel,
.history-panel {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.mp-card {
  padding: 10px;
  border-radius: var(--r-sm);
  background: var(--bg-rail-alt);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mp-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.mp-code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  background: var(--bg-inset);
  border: 1.5px dashed var(--border-strong);
}

.mp-code-val {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--gold);
}

.mp-join-row {
  display: flex;
  gap: 6px;
}

.mp-input {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 9px;
  border-radius: var(--r-sm);
  background: var(--bg-inset);
  border: 1.5px solid var(--border-strong);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  outline: none;
}

.mp-input:focus {
  border-color: var(--cta-green);
}

.mp-status {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.mp-error {
  font-size: 11.5px;
  color: #e67d79;
  font-weight: 600;
}

.mp-warn {
  padding: 6px 8px;
  border-radius: var(--r-sm);
  background: rgba(221, 169, 56, 0.16);
  border: 1px solid var(--gold);
  color: #f6d57c;
  font-size: 11.5px;
  font-weight: 700;
}

.mp-presence-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
}

.online-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cta-green);
  flex-shrink: 0;
}

.handle-input {
  width: 112px;
  height: 24px;
  padding: 0 7px;
  border-radius: 3px;
  background: var(--bg-rail);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 700;
  outline: none;
}

.handle-input:focus {
  border-color: var(--cta-green);
}

.stats-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.lb-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 8px;
  border-radius: var(--r-sm);
  background: var(--bg-rail-alt);
  border: 1px solid var(--border-subtle);
  font-size: 11.5px;
}

.lb-rank {
  width: 18px;
  font-weight: 800;
  color: var(--text-muted);
  flex-shrink: 0;
}

.lb-rank.top {
  color: var(--gold);
}

.lb-name {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-val {
  font-weight: 800;
  color: var(--cta-green);
  flex-shrink: 0;
}

/* Custom 8-Card Deck Editor */
.deck-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 700;
}

.deck-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  border-radius: var(--r-sm);
  background: var(--bg-rail-alt);
  border: 1px solid var(--border-subtle);
}

.deck-row-info {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.deck-row-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.deck-row-cost {
  font-size: 10.5px;
  font-weight: 700;
  color: #c28ce8;
}

.deck-stepper {
  display: flex;
  align-items: center;
  gap: 4px;
}

.step-btn {
  width: 22px;
  height: 22px;
  border-radius: 3px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
}

.step-btn:hover:not(:disabled) {
  background: var(--bg-surface-hover);
}

.step-btn:disabled {
  opacity: 0.35;
}

.deck-count {
  min-width: 16px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-primary);
}

/* Career Stats & History */
.career-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
}

.career-box {
  padding: 6px 8px;
  border-radius: var(--r-sm);
  background: var(--bg-rail-alt);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
}

.career-box strong {
  font-size: 13px;
  color: var(--text-primary);
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 8px;
  border-radius: var(--r-sm);
  background: var(--bg-rail-alt);
  border: 1px solid var(--border-subtle);
  font-size: 11.5px;
}

.outcome-tag {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  flex-shrink: 0;
}

.outcome-tag.W {
  background: rgba(129, 182, 76, 0.22);
  color: var(--cta-green);
}

.outcome-tag.L {
  background: rgba(204, 63, 59, 0.22);
  color: #e4716d;
}

.outcome-tag.D {
  background: rgba(221, 169, 56, 0.22);
  color: var(--gold);
}

/* Post-Match Replay Scrubber in Rail Footer */
.replay-bar {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.replay-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.replay-slider {
  flex: 1;
  accent-color: var(--cta-green);
  cursor: pointer;
}

/* Pause Overlay */
.pause-box {
  padding: 16px 20px;
  border-radius: var(--r-md);
  background: var(--bg-rail);
  border: 2px solid #191816;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 190px;
}

.pause-title {
  font-family: var(--font-sketch);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Desktop defaults for wrappers introduced for mobile Clash layout */
.arena-center {
  display: contents;
}

.bottom-dock {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mobile-eval-bar,
.mobile-only-btn,
.mobile-pause-inline,
.mobile-idle-dock,
.sheet-handle-wrap {
  display: none;
}

.drawer-backdrop {
  display: none;
}

/* Hide desktop keyboard hotkeys on touch devices */
@media (pointer: coarse) {
  .card-hotkey {
    display: none;
  }
}

/* Rail Footer Controls */
.rail-footer {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-primary {
  width: 100%;
  height: 40px;
  border-radius: var(--r-md);
  background: var(--cta-green);
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1.5px solid #243613;
  box-shadow: 0 3px 0 var(--cta-green-lip);
  transition: background-color 100ms ease, transform 70ms ease;
}

.btn-primary:hover:not(:disabled) {
  background: var(--cta-green-hover);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--cta-green-lip);
}

.footer-secondary-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-secondary {
  flex: 1;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color 100ms ease, color 100ms ease, opacity 100ms ease;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-surface-hover);
  color: #ffffff;
}

.btn-secondary:disabled {
  opacity: 0.36;
  color: var(--text-muted);
}

/* ==========================================================================
   Compact Board-Centered Modals (Game Review & Rules)
   ========================================================================== */
.board-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 19, 17, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}

.board-modal {
  width: 100%;
  max-width: 312px;
  background: var(--bg-rail);
  border: 2px solid #191816;
  border-radius: var(--r-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
}

.modal-result-title {
  font-family: var(--font-sketch);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

.modal-result-title.win {
  color: var(--cta-green);
}

.modal-result-title.loss {
  color: var(--danger);
}

.modal-result-title.draw {
  color: var(--gold);
}

.modal-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.elo-delta-pill {
  padding: 4px 8px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 800;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
}

.elo-delta-pill.pos {
  color: var(--cta-green);
}

.elo-delta-pill.neg {
  color: var(--danger);
}

.review-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.review-cell {
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--bg-rail-alt);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.review-cell-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.review-cell-val {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
}

/* Global Rules Modal */
.global-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 17, 15, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.rules-modal {
  width: 100%;
  max-width: 400px;
  background: var(--bg-rail);
  border: 2px solid #191816;
  border-radius: var(--r-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rules-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rules-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.rules-item strong {
  color: var(--text-primary);
}

.rules-icon-slot {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

/* Custom subtle scrollbars */
.bot-list::-webkit-scrollbar,
.move-log::-webkit-scrollbar {
  width: 5px;
}

.bot-list::-webkit-scrollbar-thumb,
.move-log::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

/* ==========================================================================
   Native Clash Royale x Chess.com Mobile Layout (<= 820px)
   Full-bleed arena + bottom-anchored Battle Dock + Slide-up Bottom Sheet
   ========================================================================== */
@media (max-width: 820px) {
  .app-shell {
    --board-h: clamp(260px, calc(100vh - 224px), 600px);
    --board-h: clamp(260px, calc(100dvh - 224px), 600px);
    --board-w: min(calc(100vw - 22px), calc(var(--board-h) * 0.75));
    --actual-h: calc(var(--board-w) * 1.333333);

    flex-direction: column;
    justify-content: stretch;
    align-items: stretch;
    gap: 0;
    padding: 0;
  }

  .stage-wrap {
    width: 100%;
    height: 100%;
    max-height: none;
    gap: 0;
  }

  /* Desktop outer eval bar hidden; replaced by flush arena eval bar */
  .eval-column {
    display: none;
  }

  .board-column {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0;
  }

  /* 1. Single Clean Full-Bleed Top Opponent Strip */
  .opp-strip {
    width: 100%;
    height: auto;
    min-height: 44px;
    padding: max(6px, env(safe-area-inset-top)) 10px 6px;
    background: var(--bg-rail);
    border-bottom: 1.5px solid #1b1917;
    flex-shrink: 0;
  }

  .mobile-only-btn {
    display: flex;
  }

  .mobile-pause-inline {
    display: flex;
  }

  /* 2. Centered Maximized Arena (slim 8px eval bar + full-width 6x8 board) */
  .arena-center {
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 4px 6px;
  }

  .mobile-eval-bar {
    display: block;
    position: relative;
    width: 8px;
    height: var(--actual-h);
    border-radius: 3px;
    overflow: hidden;
    background: #23211e;
    border: 1.5px solid #191816;
    flex-shrink: 0;
  }

  /* 3. Full-Bleed Clash Battle Dock anchored firmly to bottom edge! */
  .bottom-dock {
    width: 100%;
    flex-shrink: 0;
    background: var(--bg-rail);
    border-top: 2px solid #1a1917;
    padding: 6px 10px max(10px, env(safe-area-inset-bottom));
    gap: 6px;
  }

  .you-strip {
    height: 30px;
    padding: 0;
  }

  .avatar-box {
    width: 28px;
    height: 28px;
  }

  .match-clock {
    min-width: 56px;
    height: 28px;
    padding: 0 7px;
    font-size: 14px;
  }

  /* Clash-style Elixir bar & tall 84px Card Hand with NEXT on left! */
  .elixir-row {
    height: 22px;
    gap: 7px;
  }

  .elixir-track {
    height: 15px;
    border-radius: 4px;
  }

  .elixir-readout {
    font-size: 14px;
    min-width: 32px;
  }

  .hand-row {
    height: 84px;
    grid-template-columns: 50px repeat(4, 1fr);
    gap: 6px;
  }

  .next-card-slot {
    order: -1;
    border-radius: var(--r-md);
    background: var(--bg-inset);
  }

  .card-tile {
    border-radius: 7px;
    box-shadow: 0 3px 0 #161513;
  }

  .card-tile.selected {
    transform: translateY(-8px);
    box-shadow: 0 7px 0 #161513;
  }

  .card-art {
    width: 36px;
    height: 36px;
  }

  .card-hotkey {
    display: none;
  }

  /* Idle State on Mobile: Replace greyed-out cards with thumb-zone Battle Launch Pad! */
  .app-shell[data-phase='idle'] #battle-hand-dock {
    display: none;
  }

  .app-shell[data-phase='idle'] .mobile-idle-dock {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 2px;
  }

  .mobile-quick-row {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr 1fr;
    gap: 6px;
  }

  .mobile-chip {
    height: 32px;
    padding: 0 8px;
    border-radius: var(--r-sm);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-size: 11.5px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-chip:active {
    background: var(--bg-surface-hover);
  }

  .mobile-play-btn {
    height: 46px;
    font-size: 15px;
  }

  /* Desktop Right Rail hidden until opened as a native Slide-Up Bottom Sheet */
  .right-rail {
    display: none;
  }

  .right-rail.drawer-open {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: auto;
    max-height: 76dvh;
    border-radius: 14px 14px 0 0;
    border: 1.5px solid var(--border-strong);
    border-bottom: none;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 45;
    box-shadow: 0 -10px 32px rgba(0, 0, 0, 0.58);
    animation: sheetSlideUp 210ms cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes sheetSlideUp {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }

  .sheet-handle-wrap {
    display: flex;
    justify-content: center;
    padding: 7px 0 2px;
  }

  .sheet-handle {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--border-strong);
  }

  .right-rail.drawer-open .bot-item-tag {
    white-space: normal;
    line-height: 1.3;
  }

  .drawer-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 14, 12, 0.65);
    z-index: 40;
  }
}

/* Compact Phone Widths (iPhone SE / 360px-430px) */
@media (max-width: 430px) {
  .player-elo {
    display: none;
  }

  .hp-bar-track {
    width: 54px;
  }

  .hp-value {
    font-size: 11px;
    min-width: 24px;
  }

  .hand-row {
    height: 78px;
    grid-template-columns: 46px repeat(4, 1fr);
  }

  .card-art {
    width: 31px;
    height: 31px;
  }

  .card-label {
    font-size: 10.5px;
  }
}
