/* Styles for the Workout Wizard power-user mobile client. */
:root {
  color-scheme: dark;
  --bg: #10141f;
  --panel: #171d2b;
  --panel-2: #202837;
  --line: #344054;
  --text: #f6f7f2;
  --muted: #aab3c2;
  --gold: #f2c14e;
  --red: #e05263;
  --green: #42b883;
  --blue: #4aa8ff;
  --ink: #0b0f18;
}

* { box-sizing: border-box; }

html { overflow-x: hidden; }

/* Game UI: nothing selectable or tap-highlighted — stray text selection was
   hijacking rapid rep taps. Typing fields opt back in below. */
* { -webkit-tap-highlight-color: transparent; }
body {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
input, textarea {
  user-select: text;
  -webkit-user-select: text;
}
button { touch-action: manipulation; }

body {
  overflow-x: hidden;
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(242, 193, 78, 0.10), transparent 240px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button, input, select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  min-height: 44px;
  padding: 10px 12px;
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c111b;
  color: var(--text);
  min-height: 46px;
  padding: 10px 12px;
  font-weight: 700;
}

.app {
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 12px;
}

button { transition: transform 90ms ease, filter 120ms ease; }
button:not(:disabled):active { transform: translateY(1px) scale(0.985); }
button:disabled { opacity: 0.45; }

.topbar, .panel, .card, .player, .exercise, .toast {
  background-image: linear-gradient(180deg, rgba(246, 247, 242, 0.03), transparent 42%);
  border: 1px solid var(--line);
  background: rgba(23, 29, 43, 0.94);
  border-radius: 8px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  backdrop-filter: blur(10px);
}

.brand {
  font-size: 18px;
  font-weight: 950;
  line-height: 1.05;
}

.meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.stack { display: grid; gap: 12px; margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.panel { padding: 12px; }

.start {
  min-height: calc(100vh - 24px);
  display: grid;
  align-content: center;
  gap: 12px;
}

.title {
  font-size: clamp(42px, 11vw, 86px);
  line-height: 0.92;
  margin: 0;
  max-width: 760px;
}

.form {
  display: grid;
  gap: 8px;
  max-width: 520px;
}

/* Pass-and-play setup: two stacked seat cards, scrollable on short phones. */
.solo-setup { align-content: start; padding-top: 16px; gap: 10px; }
.solo-setup .title { font-size: clamp(34px, 9vw, 64px); }
.solo-player { gap: 8px; }
.solo-name {
  font-weight: 900;
  font-size: 18px;
}
.solo-pass { text-align: center; }
.solo-pass .exercise-name { margin-bottom: 4px; }

.tagline {
  margin: 4px 0 0;
  max-width: 520px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

.rules-link {
  color: var(--gold);
  font-weight: 900;
  font-size: 14px;
  text-decoration: none;
}

.primary {
  background: linear-gradient(180deg, #ffd97a, var(--gold) 55%, #d9a83a);
  box-shadow: 0 2px 10px rgba(242, 193, 78, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  color: var(--ink);
  border-color: #ffd66f;
}

.danger { background: #4a1721; border-color: #8c2b3a; }
.good { background: #163927; border-color: #2e8a5d; }
.blue { background: #122b46; border-color: #246399; }

.code {
  font-size: clamp(46px, 16vw, 112px);
  font-weight: 950;
  line-height: 0.9;
  letter-spacing: 0;
}

.qr {
  width: 220px;
  height: 220px;
  background: #f6f7f2;
  border-radius: 8px;
  padding: 8px;
}

.tiers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.tiers.collapsed { display: none; }

.option-toggle {
  display: block;
  width: 100%;
  min-height: 40px;
  padding-block: 8px;
  background: #111827;
  color: var(--muted);
  border-style: dashed;
}

.option-toggle[aria-expanded="true"] {
  color: var(--text);
  border-style: solid;
}

.character-select {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.character-option {
  min-height: 148px;
  padding: 0 0 7px;
  overflow: hidden;
  display: grid;
  grid-template-rows: 108px auto auto;
  align-items: end;
  gap: 3px;
  border-radius: 10px;
  background: #0c111b;
}

.character-option img {
  display: block;
  width: 100%;
  height: 108px;
  object-fit: cover;
  object-position: center top;
  border-bottom: 1px solid rgba(242, 193, 78, 0.18);
}

.character-name {
  display: block;
  width: 100%;
  min-width: 0;
  color: var(--text);
  padding-inline: 3px;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
}

.character-bonus {
  display: block;
  width: 100%;
  min-width: 0;
  color: var(--gold);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.tiers button[aria-pressed="true"] {
  background: var(--gold);
  color: var(--ink);
  border-color: #ffd66f;
}

.character-option[aria-pressed="true"] {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(242, 193, 78, 0.6);
}

.players {
  display: grid;
  gap: 8px;
}

/* The battle screen is full-bleed: no side padding on the app shell, and the
   top margin shrinks so the names get the same air above as below (4px) */
.app:has(.battle) { padding-inline: 0; padding-top: 0; }
.app:has(.battle) .game-stack { margin-top: 4px; }

/* Portraits sit side by side with a slim gutter, outlined, flush to the screen
   edges; the round counter + End Turn float on top of the art at the seam. */
.duel-status {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  align-items: start;
}

/* Anchored so the chip's bottom sits flush with the bottom of the (square)
   stages: 24px = fixed nameplate row (20px) + player grid gap (4px), and the
   stage height equals its column width. */
.duel-center {
  position: absolute;
  left: 50%;
  top: calc(24px + (min(100vw, 1040px) - 6px) / 2);
  transform: translate(-50%, -100%);
  z-index: 3;
  display: grid;
  justify-items: center;
  pointer-events: none;
}
.duel-center .end-turn { pointer-events: auto; }
.round-chip {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 8px;
  border-radius: 0;
  background: rgba(6, 9, 16, 0.72);
  border: 1px solid color-mix(in srgb, var(--gold) 40%, var(--line));
  backdrop-filter: blur(2px);
}
.round-label {
  color: var(--muted);
  font-size: 9px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.round-num {
  font-size: 22px;
  font-weight: 950;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-shadow: 0 0 12px rgba(242, 193, 78, 0.35);
}

.player {
  padding: 10px;
  display: grid;
  gap: 7px;
  align-content: start;
  min-width: 0;
}

/* Both players read the same way: HP left, AP circle right. No mirroring. */

.stat-row {
  display: grid;
  gap: 7px;
}

.character-stage {
  height: clamp(132px, 24vw, 220px);
  display: grid;
  place-items: end center;
  overflow: hidden;
  border-radius: 8px;
  background:
    radial-gradient(ellipse at 50% 78%, color-mix(in srgb, var(--pa, var(--gold)) 22%, transparent), transparent 52%),
    linear-gradient(180deg, rgba(246, 247, 242, 0.04), transparent 55%),
    #0c111b;
}

.character-img {
  display: block;
  width: auto;
  max-width: 100%;
  height: clamp(132px, 24vw, 220px);
  max-height: 100%;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.62));
}

.character-img.rival {
  transform: scaleX(-1);
}

.hpblock {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 6px;
  align-items: center;
}

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

.hpnum {
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  font-size: 12px;
  min-width: 1.5em;
  color: var(--green);
}

.stat-label {
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  font-weight: 950;
  text-transform: uppercase;
  white-space: nowrap;
}

.player.hit { animation: hp-hit 850ms ease-out; }
.player.heal { animation: hp-heal 850ms ease-out; }
@keyframes hp-hit {
  0% { box-shadow: inset 0 0 0 2px rgba(224, 82, 99, 0.9), 0 0 26px rgba(224, 82, 99, 0.55); }
  20% { transform: translateX(-3px); }
  40% { transform: translateX(3px); }
  60% { transform: translateX(-2px); }
  100% { box-shadow: none; transform: none; }
}
@keyframes hp-heal {
  0% { box-shadow: inset 0 0 0 2px rgba(66, 184, 131, 0.9), 0 0 26px rgba(66, 184, 131, 0.5); }
  100% { box-shadow: none; }
}

.name {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 900;
}

/* HP: black tray, white border, one green cell per hit point */
.hpcells {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 1px;
  height: 14px;
  padding: 2px;
  box-sizing: border-box;
  background: #000;
  border: 1px solid #fff;
  border-radius: 3px;
}
.hpcell {
  flex: 1;
  min-width: 0;
  background: transparent;
}
.hpcell.on { background: var(--green); }

/* HP tiers: number + cells shift gold below half, red below a quarter */
.hpblock.mid .hpcell.on { background: var(--gold); }
.hpblock.mid .hpnum { color: var(--gold); }
.hpblock.low .hpcell.on { background: var(--red); }
.hpblock.low .hpnum { color: var(--red); }
.hpblock.low .hpcells { animation: hp-critical 1.6s ease-in-out infinite; }
@keyframes hp-critical {
  50% { box-shadow: 0 0 10px rgba(224, 82, 99, 0.7); }
}

/* AP: one blue-ringed circle, black fill, count inside */
.ap-circle {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--blue);
  background: #000;
  color: var(--blue);
  font-size: 14px;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
  display: grid;
  place-items: center;
  box-shadow: 0 0 8px rgba(74, 168, 255, 0.35);
}
.ap-circle.pop { animation: pip-pop 200ms ease-out; }
.ap-circle.empty {
  border-color: color-mix(in srgb, var(--muted) 55%, transparent);
  color: color-mix(in srgb, var(--muted) 65%, transparent);
  box-shadow: none;
}
@keyframes pip-pop { from { transform: scale(0.4); } to { transform: none; } }

.status-tray {
  min-height: 26px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-content: flex-start;
  align-items: center;
}

.status-chip {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 6px;
  background: #0c111b;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.1;
  font-weight: 950;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.status-chip.defense {
  border-color: #246399;
  color: #cbe5ff;
}

.status-chip.buff {
  border-color: #2e8a5d;
  color: #c9f4dc;
}

.status-chip.debuff {
  border-color: #8c2b3a;
  color: #ffd2d8;
}

.connection-state {
  justify-self: start;
}

.duel-status .player.rival .connection-state {
  justify-self: end;
}

.reconnecting { color: var(--red); animation: urgent-blink 1.2s steps(2) infinite; }
.connection-state.away { color: var(--red); }

.hand {
  --thumb-w: 132px;
  --overlap: 72px;
  display: flex;
  align-items: end;
  min-height: 218px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 14px 12px 24px;
  scrollbar-width: thin;
}

.card-thumb {
  --fan-transform: rotate(7deg) translateY(20px);
  flex: 0 0 var(--thumb-w);
  width: var(--thumb-w);
  aspect-ratio: 2 / 3;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  margin-left: calc(-1 * var(--overlap));
  position: relative;
  z-index: calc(var(--i) + 1);
  transform-origin: 50% 100%;
  transform: var(--fan-transform);
  transition: transform 150ms ease, filter 150ms ease;
}

.card-thumb:first-child { margin-left: 0; }
.card-thumb:nth-child(1) { --fan-transform: rotate(-7deg) translateY(18px); }
.card-thumb:nth-child(2) { --fan-transform: rotate(-4deg) translateY(8px); }
.card-thumb:nth-child(3) { --fan-transform: rotate(-1deg); }
.card-thumb:nth-child(4) { --fan-transform: rotate(2deg) translateY(6px); }
.card-thumb:nth-child(5) { --fan-transform: rotate(5deg) translateY(16px); }
.card-thumb:nth-child(n + 6) { --fan-transform: rotate(7deg) translateY(20px); }

.card-thumb.drawn {
  animation: card-draw-in 620ms cubic-bezier(0.18, 0.82, 0.24, 1) both;
  animation-delay: calc(var(--draw-delay, 0) * 160ms);
}

@keyframes card-draw-in {
  0% {
    opacity: 0;
    transform: translateY(88px) scale(0.82) rotate(0deg);
    filter: drop-shadow(0 0 0 rgba(242, 193, 78, 0));
  }
  58% {
    opacity: 1;
    transform: translateY(-18px) scale(1.04) rotate(0deg);
    filter: drop-shadow(0 18px 24px rgba(242, 193, 78, 0.26));
  }
  100% {
    opacity: 1;
    transform: var(--fan-transform);
  }
}

.card-thumb.selected {
  z-index: 2;
  transform: rotate(0deg) translateY(-20px) scale(1.04);
  filter: drop-shadow(0 16px 22px rgba(0, 0, 0, 0.55));
}

.card-thumb-inner {
  width: 1024px;
  height: 1536px;
  transform-origin: top left;
  transform: scale(0.12890625); /* 132/1024 */
  pointer-events: none;
}
@media (max-width: 640px) {
  .card-thumb-inner {
    transform: scale(0.11328125); /* 116/1024 */
  }
}

.card-thumb-overlay {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  border: 1px solid rgba(246, 247, 242, 0.22);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.42);
  pointer-events: none;
}

.hidden-card {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: repeating-linear-gradient(135deg, #171d2b, #171d2b 8px, #202837 8px, #202837 16px);
  color: var(--muted);
}

.selected-card-panel {
  display: grid;
  grid-template-columns: minmax(190px, 340px) 1fr;
  gap: 12px;
  align-items: end;
}

.selected-card-img {
  display: block;
  width: min(100%, 340px);
  max-height: min(70vh, 560px);
  object-fit: contain;
  border-radius: 14px;
  border: 1px solid rgba(246, 247, 242, 0.22);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.52);
}

.selected-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.empty-hand {
  min-height: 44px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.script {
  color: #d4dae5;
  font-size: 13px;
  line-height: 1.25;
  margin: 8px 0 0;
}

.arena {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.exercise {
  padding: 14px;
  display: grid;
  gap: 10px;
  min-height: 230px;
}

.exercise-name {
  font-size: clamp(28px, 9vw, 66px);
  line-height: 0.95;
  font-weight: 950;
}

.timer {
  font-variant-numeric: tabular-nums;
  font-size: clamp(54px, 20vw, 148px);
  line-height: 0.88;
  font-weight: 950;
}

.counter {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: stretch;
}

.tap {
  min-height: min(42vh, 310px);
  font-size: clamp(58px, 18vw, 150px);
  line-height: 0.9;
}

.subactions {
  display: grid;
  gap: 8px;
}

.toast {
  border-color: #8c2b3a;
  background: #30141c;
  padding: 10px;
  color: #ffd2d8;
  font-weight: 800;
}

.discard {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid var(--line);
  background: #0c111b;
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.prepared-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.defense-chip {
  border-color: #246399;
  color: #cbe5ff;
}

@media (max-width: 720px) {
  .split { grid-template-columns: 1fr; }
  .topbar { grid-template-columns: 1fr auto; }
  .counter { grid-template-columns: 1fr; }
  .hand {
    --thumb-w: 116px;
    --overlap: 64px;
    min-height: 194px;
    padding-inline: 8px;
  }
  .selected-card-panel {
    grid-template-columns: 1fr;
  }
  .selected-card-img {
    width: min(100%, 330px);
    max-height: 62vh;
    margin: 0 auto;
  }
  .selected-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .script { font-size: 12px; }
  .character-select { gap: 6px; }
  .character-option { min-height: 118px; padding: 0 0 5px; grid-template-rows: 78px auto auto; }
  .character-option img { height: 78px; }
  .character-name { font-size: 10px; }
  .character-bonus { font-size: 9px; }
  .stat-row { display: grid; gap: 6px; }
  .hpcells { height: 12px; }
  .ap-circle { width: 22px; height: 22px; font-size: 12px; }
  .hpnum { font-size: 12px; }
  .stage-name { font-size: 13px; }
  .round-num { font-size: 18px; }
  .status-chip { font-size: 9px; padding-inline: 5px; }
}

/* ---------------- card modal (selected card leaves the hand) ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(6, 9, 16, 0.72);
  display: grid; place-items: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.card-modal {
  display: grid; gap: 10px; justify-items: center;
  max-width: min(92vw, 360px);
  animation: modal-pop 140ms ease-out;
}
.card-modal.no-pop { animation: none; }
@keyframes modal-pop {
  from { transform: scale(0.92) translateY(10px); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}
.card-modal-img {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
}

.card-modal-render {
  width: 320px;
  height: 480px;
  overflow: hidden;
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
}

.card-modal-render-inner {
  width: 1024px;
  height: 1536px;
  transform: scale(0.3125);
  transform-origin: top left;
}

.card-modal-actions { display: flex; gap: 10px; }
.card-modal-actions button { min-width: 120px; }
.card-modal.confirm {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  text-align: center;
}
.card-gap { visibility: hidden; }

@media (max-width: 720px) {
  .card-modal-render {
    width: 280px;
    height: 420px;
  }

  .card-modal-render-inner {
    transform: scale(0.2734375);
  }
}

/* ---------------- passive mode (rival's turn) ---------------- */
.passive .dimmed { opacity: 0.55; } /* hand stays browsable for planning; Play is disabled */
.passive-banner {
  text-align: center;
  border-color: var(--blue);
  background: linear-gradient(180deg, rgba(74, 168, 255, 0.10), transparent);
  animation: passive-pulse 2.4s ease-in-out infinite;
}
@keyframes passive-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 168, 255, 0); }
  50% { box-shadow: 0 0 18px 0 rgba(74, 168, 255, 0.25); }
}

/* Clipped scale box for the announced card (1024x1536 face scaled down; without
   the clip the unscaled layout box caused page-wide horizontal overflow). */
.announce-render {
  width: 264px;
  height: 396px;
  overflow: hidden;
  border-radius: 12px;
  margin: 0 auto;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
}
.announce-render-inner {
  width: 1024px;
  height: 1536px;
  transform: scale(0.2578125); /* 264/1024 */
  transform-origin: top left;
  pointer-events: none;
}

/* ---------------- announcing / incoming ---------------- */
.announce-card {
  width: min(52vw, 220px);
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.exercise.incoming { border-color: var(--red); }
.incoming-label {
  color: var(--red);
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  animation: passive-pulse 1s ease-in-out infinite;
}

/* ---------------- damage floats + rep tap juice ---------------- */
.character-stage { position: relative; }
.dmg-float {
  position: absolute;
  top: 32%;
  left: 50%;
  font-size: 34px;
  font-weight: 950;
  pointer-events: none;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
  animation: dmg-rise 1150ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.dmg-float.hit { color: var(--red); }
.dmg-float.heal { color: var(--green); }
@keyframes dmg-rise {
  0% { transform: translate(-50%, 10px) scale(0.6); opacity: 0; }
  18% { transform: translate(-50%, 0) scale(1.25); opacity: 1; }
  100% { transform: translate(-50%, -52px) scale(1); opacity: 0; }
}

.tap-count { display: inline-block; }
.tap-count.pop { animation: count-pop 200ms ease-out; }
@keyframes count-pop { from { transform: scale(1.5); } to { transform: none; } }

.start-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}
.start-divider::before, .start-divider::after {
  content: '';
  height: 1px;
  background: var(--line);
}

/* ---------------- timer urgency + tap target ---------------- */
.timer.urgent { color: var(--red); animation: urgent-blink 1s steps(2) infinite; }
@keyframes urgent-blink { 50% { opacity: 0.45; } }
.tap-target { font-size: 16px; color: var(--ink); opacity: 0.65; margin-left: 6px; }

/* Plank has no reps — the referee taps this big FAIL button the instant the plank drops. */
.fail-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.tap-fail-word { font-size: clamp(52px, 16vw, 128px); line-height: 0.9; letter-spacing: 2px; }
.tap-fail-hint {
  font-size: clamp(14px, 4.2vw, 22px);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: 0;
  opacity: 0.72;
  text-transform: uppercase;
}
.tap.fail-btn:disabled .tap-fail-hint { opacity: 0.85; }

/* ---------------- deck editor ---------------- */
.deck-editor { max-height: 60vh; overflow-y: auto; }
.deck-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px; align-items: center;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
}
.deck-thumb { width: 44px; border-radius: 6px; }
.deck-info { display: grid; gap: 2px; min-width: 0; }
.deck-info .meta { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stepper { display: flex; gap: 6px; align-items: center; }
.stepper button { width: 38px; height: 38px; padding: 0; font-size: 18px; }
.deck-count { min-width: 20px; text-align: center; font-weight: 700; }
.warn { color: var(--red); }

/* ---------------- misc ---------------- */
button.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

/* ---------- HTML CARD COMPONENT ---------- */
.card-container {
  width: 1024px;
  height: 1536px;
  position: relative;
  border-radius: 48px;
  background-color: #111621;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  transform-origin: top left;
  /* by default assume it's scaled by JS if needed, or by parent container */
}

.card-border {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border: 26px solid #151922;
  border-radius: 48px;
  box-sizing: border-box;
  box-shadow: inset 2px 2px 0 0 #4a5568, inset -3px -3px 0 0 #07090f;
  pointer-events: none;
  z-index: 100;
}

.card-container.attack .metallic-line { border-color: #d3483f; }
.card-container.attack .art-panel { border-color: #d3483f; }
.card-container.defense .metallic-line { border-color: #246399; }
.card-container.defense .art-panel { border-color: #246399; }
.card-container.powerup .metallic-line { border-color: #42b883; }
.card-container.powerup .art-panel { border-color: #42b883; }

.metallic-line {
  position: absolute;
  top: 31px; left: 31px; right: 31px; bottom: 31px;
  border: 3px solid #d3483f;
  border-radius: 20px;
  pointer-events: none;
  z-index: 90;
}

.top-band {
  position: absolute;
  left: 82px;
  top: 82px;
  width: 860px;
  height: 154px;
  border-radius: 18px;
  background-color: #18202c;
  box-shadow: inset 0 0 0 1px #394457;
  z-index: 10;
}

.energy-medallion {
  position: absolute;
  left: 100px;
  top: 101px;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  background-color: #f2c14e;
  border: 6px solid #17110a;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 2px 2px 0 0 rgba(255,255,255,0.3);
  z-index: 20;
}

.energy-text {
  font-family: 'Inter', sans-serif;
  font-weight: 900;
  font-size: 78px;
  color: #0b0f18;
  line-height: 1;
  margin-top: 5px;
}

.title-block {
  position: absolute;
  left: 242px;
  top: 105px;
  width: 610px;
  height: 74px;
  display: flex;
  align-items: center;
  z-index: 20;
}

.title-text {
  font-family: 'Anton', sans-serif;
  font-size: 58px;
  color: #f6f7f2;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.type-label {
  position: absolute;
  left: 246px;
  top: 182px;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 25px;
  color: #f2c14e;
  text-transform: uppercase;
  letter-spacing: 1px;
  z-index: 20;
}

.art-panel {
  position: absolute;
  left: 82px;
  top: 258px;
  width: 860px;
  height: 750px;
  border-radius: 24px;
  box-sizing: border-box;
  border: 4px solid #d3483f;
  box-shadow: inset 0 0 0 1px #f2c14e;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #222;
  z-index: 10;
}

.rules-panel {
  position: absolute;
  left: 82px;
  top: 1030px;
  width: 860px;
  height: 326px;
  border-radius: 20px;
  background-color: #efe5c8;
  border: 2px solid #463622;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-left: 60px;
  padding-top: 5px;
  z-index: 10;
}

.rule-row {
  display: flex;
  align-items: center;
  height: 88px;
}

.rule-icon {
  width: 44px;
  height: 44px;
  background-color: #151922;
  mask-size: contain;
  -webkit-mask-size: contain;
  mask-repeat: no-repeat;
  -webkit-mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-position: center;
  margin-right: 24px;
}

.icon-reps {
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 14H9v-2h2v2zm0-4H9V7h2v5zm4 4h-2v-2h2v2zm0-4h-2V7h2v5z"/></svg>');
}
.icon-time {
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/><path d="M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"/></svg>');
}
.icon-dmg {
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg>');
}

.rule-text {
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  font-size: 42px;
  color: #151922;
}

.footer-strip {
  position: absolute;
  left: 82px;
  top: 1380px;
  width: 860px;
  height: 74px;
  border-radius: 16px;
  background-color: #151922;
  box-shadow: inset 0 0 0 1px #f2c14e;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.flavor-text {
  font-family: 'Inter', sans-serif;
  font-style: italic;
  font-weight: 700;
  font-size: 26px;
  color: #f2c14e;
}

/* ================= GAME-MODE LOOK (scoped to .battle; lobby stays plain) ================= */

body {
  background:
    radial-gradient(1100px 500px at 15% -8%, rgba(242, 193, 78, 0.07), transparent 60%),
    radial-gradient(900px 520px at 92% 0%, rgba(74, 168, 255, 0.06), transparent 55%),
    radial-gradient(1200px 700px at 50% 115%, rgba(139, 92, 246, 0.08), transparent 60%),
    var(--bg);
}

.battle { display: grid; gap: 8px; }
.battle .panel { padding: 8px 10px; }
.battle section { margin: 0; }

/* Player column: name above the art, vitals + statuses floating below it.
   Only the character stage keeps a framed border; the rest is chromeless. */
.battle .player {
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  overflow: visible;
  display: grid;
  gap: 4px;
  align-content: start;
}
/* Square stage matches the square art exactly, so the full character fits.
   Borders only face the gutter and the bottom — screen edges stay clean. */
.battle .character-stage {
  aspect-ratio: 1;
  height: auto;
  border-radius: 0;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--pa, var(--gold)) 40%, var(--line));
  box-shadow: none;
}
.battle .player.you .character-stage {
  border-right: 1px solid color-mix(in srgb, var(--pa, var(--gold)) 40%, var(--line));
}
.battle .player.rival .character-stage {
  border-left: 1px solid color-mix(in srgb, var(--pa, var(--gold)) 40%, var(--line));
}
.battle .character-img { height: 100%; }

.nameplate {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 0 2px;
  min-width: 0;
}
.stage-name {
  font-family: 'Anton', sans-serif;
  font-weight: 400;
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #000;
  text-shadow: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stage-tier {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
}
/* Text rows keep breathing room even though the stages are full-bleed.
   The nameplate height is fixed: the duel-center overlay's anchor math
   depends on it. */
.battle .nameplate {
  height: 20px;
  align-items: center;
  background: var(--pa, var(--gold));
}
/* Each player column is separated by a 6px stage gutter. Extend both halves
   three pixels into it so only the top banners meet at a clean center seam. */
.battle .player.you .nameplate { width: calc(100% + 3px); }
.battle .player.rival .nameplate {
  width: calc(100% + 3px);
  margin-left: -3px;
}
.battle .nameplate, .battle .status-tray { padding: 0 12px; }
.battle .vitals { padding: 0 8px; }
.battle .hpnum { font-size: 12px; }
.connection-state.away {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  font-weight: 950;
  letter-spacing: 2px;
  color: var(--red);
  text-shadow: 0 0 12px rgba(224, 82, 99, 0.8);
  animation: urgent-blink 1.2s steps(2) infinite;
}

.battle .player.active { border: 0; box-shadow: none; }

/* Turn banner: slim, stylized */
.battle .passive-banner { padding: 8px 10px; }
.battle .passive-banner .exercise-name { font-size: 20px; }

/* Hand: felt table, no boxy chrome */
.battle .hand-panel {
  background:
    radial-gradient(120% 90% at 50% 110%, rgba(242, 193, 78, 0.08), transparent 55%),
    linear-gradient(180deg, rgba(246, 247, 242, 0.02), transparent),
    var(--panel);
  border: 1px solid rgba(242, 193, 78, 0.14);
  box-shadow: inset 0 8px 22px rgba(0, 0, 0, 0.35), 0 6px 20px rgba(0, 0, 0, 0.4);
}
.battle .hand {
  min-height: 236px;
  padding: 8px 10px 26px;
  justify-content: safe center;
}
.battle .hand-panel > .name { padding: 2px 4px 0; }

/* Exercise stage drama */
.battle .exercise {
  border: 1px solid rgba(242, 193, 78, 0.22);
  background:
    radial-gradient(90% 120% at 50% -20%, rgba(242, 193, 78, 0.10), transparent 55%),
    var(--panel);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.battle .timer {
  text-shadow: 0 0 18px rgba(242, 193, 78, 0.45);
}
.battle .timer.urgent { text-shadow: 0 0 22px rgba(224, 82, 99, 0.7); }

/* Discard + shields rows: quiet chips, no heavy panels */
.battle .discard .chip, .battle .prepared-row .chip {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
/* Empty trays keep their height so the layout doesn't jump when statuses appear */

/* ---------------- in-game bottom bar + new modals ---------------- */
.game-stack { margin-top: 8px; }
.bottombar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(242, 193, 78, 0.10);
}
.bottombar .ghost { padding: 6px 12px; font-size: 13px; }

.deck-editor.card-modal {
  width: min(92vw, 420px);
  max-height: 76vh;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 12px;
}
.deck-thumb-btn { padding: 0; border: 0; background: none; }
.deck-thumb-btn .deck-thumb { display: block; }

button.status-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
button.status-chip.buff { background: #163927; border-color: #2e8a5d; color: #9fe8c4; }
button.status-chip.debuff { background: #4a1721; border-color: #8c2b3a; color: #ffb3bd; }
button.status-chip.defense { background: #122b46; border-color: #246399; color: #a8d4ff; }

.tier-sub { display: block; font-size: 10px; font-weight: 800; color: var(--muted); text-transform: uppercase; }
.tiers button[aria-pressed="true"] .tier-sub { color: var(--ink); }

/* ---------------- sprite icons + status tray ---------------- */
.sprite {
  background-image: url('art/icons.png');
  background-size: 400% 400%;
  background-position: calc(var(--sx) * 100% / 3) calc(var(--sy) * 100% / 3);
  background-repeat: no-repeat;
}
button.status-icon {
  position: relative;
  flex: 0 0 auto;        /* never let the flex row squish the square sprite out of ratio */
  width: 22px;
  height: 22px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  box-shadow: none;
}
button.status-icon.buff,
button.status-icon.debuff,
button.status-icon.defense { box-shadow: none; }
.status-badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  min-width: 13px;
  height: 13px;
  border-radius: 7px;
  background: var(--gold);
  color: var(--ink);
  font-size: 9px;
  font-weight: 950;
  line-height: 13px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.55);
}

/* ---------------- end turn + rival strip + hand zone + piles ---------------- */
/* Quiet stacked button living inside the round chip, styled like the pile buttons */
.end-turn {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 1px;
  line-height: 1.05;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-radius: 0;
  border: 1px solid rgba(242, 193, 78, 0.25);
  background:
    radial-gradient(120% 120% at 30% 20%, rgba(246, 247, 242, 0.08), transparent 55%),
    linear-gradient(180deg, #1c2433, #10151f);
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.rival-turn-strip {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 6px;
  animation: passive-pulse 2.4s ease-in-out infinite;
  border-radius: 8px;
}
.hand-zone { display: grid; gap: 2px; }
.pile-row { display: flex; justify-content: center; gap: 10px; }
.pile-row .ghost { font-size: 12px; padding: 5px 12px; }
.pile-modal {
  max-height: min(82vh, 720px);
  overflow-y: auto;
  width: min(94vw, 720px);
  max-width: min(94vw, 720px);
}
.pile-section { display: grid; gap: 6px; margin: 8px 0; text-align: left; }
.library-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}
.pile-card-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  justify-items: center;
}
.pile-card-grid.empty {
  min-height: 92px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
}
.pile-card {
  position: relative;
  width: 96px;
  aspect-ratio: 2 / 3;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 10px;
  overflow: hidden;
  background: transparent;
}
.pile-card-inner {
  width: 1024px;
  height: 1536px;
  transform: scale(0.09375);
  transform-origin: top left;
  pointer-events: none;
}
.pile-card-badge {
  position: absolute;
  right: 5px;
  bottom: 5px;
  min-width: 24px;
  height: 24px;
  padding: 0 5px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #ffd97a, var(--gold));
  border: 1px solid #17110a;
  color: var(--ink);
  font-size: 12px;
  font-weight: 950;
}

/* ---------------- card face: kind icon + edge light + rule alignment ---------------- */
.card-kind-icon {
  position: absolute;
  top: 52px;
  right: 56px;
  width: 110px;
  height: 110px;
  z-index: 60;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.6));
}
/* ---- card face rework: one deliberate edge, clean rows, floating icons ---- */
.card-container { --card-accent: #f2c14e; }
.card-container.attack { --card-accent: #d3483f; }
.card-container.defense { --card-accent: #4aa8ff; }
.card-container.powerup { --card-accent: #42b883; }

/* Frame: brighter metal with a single light-reflection ring inside its inner edge */
.card-border {
  border-color: #232c3e;
  box-shadow:
    inset 3px 3px 0 0 #66779a,
    inset -3px -3px 0 0 #07090f;
}
.card-border::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 46px;
  border: 5px solid transparent;
  background:
    linear-gradient(155deg,
      rgba(255, 255, 255, 0.85) 0%, rgba(150, 168, 200, 0.28) 18%,
      rgba(120, 132, 158, 0.10) 42%, color-mix(in srgb, var(--card-accent) 55%, transparent) 78%,
      rgba(255, 255, 255, 0.4) 100%) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

/* One accent voice: the inner hairline dies, the art panel carries the color */
.metallic-line { display: none; }
.art-panel {
  border-width: 5px;
  border-color: var(--card-accent) !important;
  box-shadow:
    inset 0 0 60px rgba(0, 0, 0, 0.55),
    0 0 44px color-mix(in srgb, var(--card-accent) 22%, transparent);
}

.top-band {
  background: linear-gradient(180deg, #202a3a, #151c29);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.10),
    inset 0 0 0 1px #394457,
    inset 0 -3px 0 color-mix(in srgb, var(--card-accent) 55%, #394457);
}
.title-text { text-shadow: 0 3px 0 rgba(0, 0, 0, 0.55), 0 0 22px rgba(0, 0, 0, 0.4); }
.energy-medallion {
  background: radial-gradient(circle at 34% 28%, #ffe6a3, #f2c14e 55%, #c9962f);
  box-shadow: inset 2px 2px 0 0 rgba(255,255,255,0.35), 0 4px 10px rgba(0,0,0,0.5);
}

/* Kind icon floats (sprite bg is keyed out) inside the top band, clear of the title */
.card-kind-icon {
  top: 96px;
  right: 104px;
  width: 118px;
  height: 118px;
  filter: drop-shadow(0 5px 9px rgba(0, 0, 0, 0.65));
}

/* Rules parchment: sunken paper, even padding, hairline dividers, centered rows */
.rules-panel {
  padding: 24px 52px 20px;
  background:
    radial-gradient(140% 90% at 50% 0%, rgba(255, 252, 240, 0.5), transparent 60%),
    linear-gradient(180deg, #f2ead2, #e4d7b3);
  border: 2px solid #4a3a26;
  box-shadow:
    inset 0 8px 18px rgba(70, 54, 34, 0.30),
    inset 0 -4px 10px rgba(70, 54, 34, 0.16),
    inset 0 0 0 3px rgba(255, 252, 240, 0.5);
}
.rule-row {
  align-items: center;
  height: auto;
  min-height: 84px;
  padding: 8px 0;
}
.rule-row + .rule-row { border-top: 2px solid rgba(74, 58, 38, 0.18); }
.rule-icon { flex: 0 0 44px; margin-top: 0; }
.rule-icon-sprite {
  flex: 0 0 92px;
  width: 92px;
  height: 92px;
  margin-right: 30px;
  filter: drop-shadow(0 3px 4px rgba(70, 54, 34, 0.35));
}
.rule-text { flex: 1; min-width: 0; }

/* ---------------- character picker ---------------- */
.character-option { overflow: hidden; }

/* ---------------- pile buttons (graveyard / deck) ---------------- */
.pile-btn {
  position: relative;
  width: 58px;
  height: 58px;
  padding: 0;
  border-radius: 14px;
  border: 1px solid rgba(242, 193, 78, 0.25);
  background:
    radial-gradient(120% 120% at 30% 20%, rgba(246, 247, 242, 0.08), transparent 55%),
    linear-gradient(180deg, #1c2433, #10151f);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.pile-icon {
  position: absolute;
  inset: 7px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}
.pile-count {
  position: absolute;
  right: -7px;
  bottom: -7px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 11px;
  background: linear-gradient(180deg, #ffd97a, var(--gold));
  border: 1px solid #17110a;
  color: var(--ink);
  font-size: 12px;
  font-weight: 950;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.6);
}
.pile-row { padding-bottom: 6px; }
