:root {
  --bg: #15141a;
  --panel: #23222b;
  --panel-2: #2c2b36;
  --text: #ecebf1;
  --muted: #a4a2b3;
  --accent: #f0b35c;
  --hp: #d94f4f;
  --energy: #4f8fd9;
  --buff: #6cc46c;
  --debuff: #e0644f;
  --physical: #d9d9e0;
  --light: #7fc2ff;
  --dark: #c58bff;
  --group-martial_artists: #c0392b;
  --group-amazons: #27ae60;
  --group-villagers: #b9772a;
  --group-vampires: #8e44ad;
  --group-pirates: #2980b9;
  --group-knights: #d4ac0d;
  --group-robots: #16a085;
  --group-witches: #c2418c;
  --group-universal: #7f8c8d;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: var(--bg); }
body {
  background: radial-gradient(circle at 50% 0%, #26243a 0%, var(--bg) 60%) no-repeat;
  background-size: 100% 100vh;
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.35;
}
h1, h2, h3 { margin: 0.2em 0; font-weight: 600; }
button {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid #44424f;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.12s, transform 0.08s;
}
button:hover:not(:disabled) { background: #3a3946; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--accent); color: #211a0c; border-color: #d9a04e; font-weight: 600; }
button.primary:hover:not(:disabled) { background: #f6c576; }
button.big { padding: 12px 20px; font-size: 1.05em; }
button.tiny { padding: 3px 8px; font-size: 0.8em; }
button.active { outline: 2px solid var(--accent); }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], select {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid #44424f; border-radius: 6px; padding: 6px 8px; min-width: 0;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
[hidden] { display: none !important; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }
.error { color: #ff8a80; min-height: 1.2em; margin: 6px 0; }
.spacer { flex: 1; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.badge {
  position: absolute; top: 6px; right: 6px; font-size: 0.7em; padding: 2px 6px;
  border-radius: 10px; background: #5a3f2a; color: #ffd9b0;
}

.screen { max-width: 1180px; margin: 0 auto; padding: 16px; }
button.danger:hover:not(:disabled) { background: #5a2a2a; border-color: #8a3b3b; }
.button-row.centered { justify-content: center; }
.hint { color: var(--muted); font-size: 0.85em; font-weight: normal; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.field.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.field.grow { flex: 1; }
.field-head { display: flex; justify-content: space-between; gap: 8px; }
.notice { background: #2f3a4f; border: 1px solid #45587a; color: #dbe6ff; border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
code, .match-code { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }
.match-code { background: #0f0e14; color: var(--accent); padding: 1px 6px; border-radius: 5px; user-select: all; }

/* ----------------------------------------------------------------- login */
.login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  width: 100%; max-width: 400px; background: var(--panel); border: 1px solid #34333f; border-radius: 14px;
  padding: 28px 28px 22px; box-shadow: 0 18px 50px #0008; text-align: center;
}
.login-card h1 { font-size: 1.9em; color: var(--accent); letter-spacing: 0.02em; }
.login-tabs { justify-content: center; margin: 18px 0 14px; }
.login-tabs button { flex: 1; padding: 8px 10px; font-size: 0.95em; }
.login-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.login-form input { padding: 9px 10px; }
.login-form button[type="submit"] { width: 100%; }
.login-form .error { margin: 0; text-align: center; }
.login-alt { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 14px; }
a.button {
  display: inline-block; width: 100%; text-align: center; text-decoration: none; color: var(--text);
  background: var(--panel-2); border: 1px solid #44424f; border-radius: 8px; padding: 10px 14px;
}
a.button:hover { background: #3a3946; }
a.button.google { background: #f4f4f6; color: #1f1f24; border-color: #d5d5dc; font-weight: 600; }
a.button.google:hover { background: #ffffff; }

/* ----------------------------------------------------------------- lobby */
.lobby { max-width: 860px; }
.lobby-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 0 4px; }
.lobby-top h1 { font-size: 1.6em; color: var(--accent); }
.whoami { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.panel { background: var(--panel); border: 1px solid #302f3b; border-radius: 12px; padding: 14px 16px; margin: 12px 0; }
.panel h2 { font-size: 1.1em; margin: 0 0 10px; }
.options-row { display: flex; gap: 14px 22px; flex-wrap: wrap; align-items: flex-start; }
.options-row .field.check { align-self: center; }
.options-row select { align-self: flex-start; }
.lobby > .error:empty { min-height: 0; margin: 0; }
.play-buttons { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 10px; margin: 16px 0 12px; }
.join-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.join-row input { width: 100%; }
.join-row button { padding: 7px 14px; }
.lobby .panel > p.muted.small { margin: 12px 0 0; }
.match-list { display: flex; flex-direction: column; gap: 8px; }
.match-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--panel-2); border-radius: 10px; padding: 10px 12px;
}
.match-main { min-width: 0; flex: 1; }
.match-title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.match-status { margin-top: 3px; display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.match-buttons { display: flex; gap: 8px; }
.match-buttons button { padding: 5px 12px; font-size: 0.85em; }
.mode-tag { font-size: 0.72em; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 7px; border-radius: 6px; background: #3a3946; color: var(--muted); }
.mode-tag.mode-ranked { background: #4d3a1c; color: #ffd79a; }
.mode-tag.mode-private { background: #1f3b4d; color: #a9dcff; }
.outcome-win { color: #9fe09f; }
.outcome-loss { color: #ff9f8a; }
.outcome-draw { color: #d8d7e0; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.stat { background: var(--panel-2); border-radius: 10px; padding: 8px; text-align: center; display: flex; flex-direction: column; }
.stat b { font-size: 1.5em; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 0.8em; }
.results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.result { display: grid; grid-template-columns: 4em minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 6px 2px; border-bottom: 1px solid #302f3b; }
.result:last-child { border-bottom: none; }
.result-outcome { font-weight: 600; }
.result.outcome-win .result-opponent, .result.outcome-loss .result-opponent, .result.outcome-draw .result-opponent { color: var(--text); }
.result-opponent { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ----------------------------------------------------------------- admin */
.admin { max-width: 1100px; min-height: 100vh; }
.admin-top h1 { margin-right: auto; }
.admin-tools { display: flex; gap: 8px 16px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.admin-tools input[type="search"] { flex: 1 1 220px; max-width: 360px; padding: 7px 10px; }
.admin-count { margin: 0; font-size: 0.9em; }
.admin .panel > .error:empty { min-height: 0; margin: 4px 0; }
/* Wide table: it scrolls sideways inside the panel instead of stretching the page. */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.9em; }
.admin-table th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 0.78em; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 8px 10px; border-bottom: 1px solid #3a3946; white-space: nowrap;
}
.admin-table td { padding: 7px 10px; border-bottom: 1px solid #302f3b; white-space: nowrap; vertical-align: middle; }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover td { background: #ffffff06; }
.admin-table tr.is-you td { background: #f0b35c0f; }
.admin-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.admin-table .col-email { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.admin-table .col-action { text-align: right; }
.admin-table .col-action button { min-width: 7.5em; }
.admin-empty { text-align: center; margin: 14px 0 6px; }
.role-tag { font-size: 0.78em; letter-spacing: 0.03em; padding: 2px 8px; border-radius: 6px; background: #3a3946; color: var(--muted); }
.role-tag.role-admin { background: #4d3a1c; color: #ffd79a; }
button.load-more { display: block; margin: 12px auto 2px; }

/* ----------------------------------------------------------------- queue */
.queue-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.queue-card {
  width: 100%; max-width: 440px; background: var(--panel); border: 1px solid #34333f; border-radius: 14px;
  padding: 30px 26px; text-align: center; box-shadow: 0 18px 50px #0008;
}
.queue-card h2 { font-size: 1.35em; }
.queue-meta { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.queue-elapsed { color: var(--accent); font-weight: 600; }
.spinner {
  width: 54px; height: 54px; margin: 0 auto 14px; border-radius: 50%;
  border: 5px solid #3a3946; border-top-color: var(--accent); animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ------------------------------------------------------ private room code */
.waiting.room-code { font-style: normal; padding: 20px 10px; }
.room-code p { margin: 6px 0; }
.code-line { display: flex; justify-content: center; align-items: center; gap: 10px; margin: 10px 0; }
.big-code { font-size: 1.6em; padding: 4px 14px; letter-spacing: 0.06em; }
.waiting button { font-style: normal; }
/* A private room nobody has joined: the opponent's side is a placeholder, so
   hide it and put the match code above the arena. */
.battle-screen.in-lobby .side.enemy { display: none; }
.battle-screen.in-lobby .battle-header { order: -2; }
.battle-screen.in-lobby .battle-bottom { order: -1; }
.battle-screen.in-lobby .log { display: none; }
.battle-screen.in-lobby .battle-bottom { grid-template-columns: 1fr; }
.battle-screen.in-lobby .actions { min-height: 0; }
.battle-screen.in-lobby .side.you { max-width: 760px; }
/* No range yet: drop the centre (it wraps to its own row on narrow screens). */
.battle-screen.in-lobby .hdr-center { display: none; }
.battle-screen.in-lobby .hdr-right { margin-left: auto; }

/* ---------------------------------------------------------------- cards */
.art { position: relative; overflow: hidden; border-radius: 8px; background: #1b1a22; display: flex; align-items: center; justify-content: center; }
.art img { display: block; width: 100%; height: 100%; object-fit: contain; }
.art-fallback {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.6em; color: #fff3;
  background: linear-gradient(135deg, var(--group-color, #555) 0%, #1b1a22 100%);
}
.art-hidden { font-size: 2.4em; color: #fff4; background: repeating-linear-gradient(45deg, #2a2933 0 8px, #22212a 8px 16px); }
.group-martial_artists { --group-color: var(--group-martial_artists); }
.group-amazons { --group-color: var(--group-amazons); }
.group-villagers { --group-color: var(--group-villagers); }
.group-vampires { --group-color: var(--group-vampires); }
.group-pirates { --group-color: var(--group-pirates); }
.group-knights { --group-color: var(--group-knights); }
.group-robots { --group-color: var(--group-robots); }
.group-witches { --group-color: var(--group-witches); }
.group-universal { --group-color: var(--group-universal); }

.resists { display: flex; gap: 6px; font-size: 0.8em; color: var(--muted); }
.resist-physical { color: var(--physical); }
.resist-light { color: var(--light); }
.resist-dark { color: var(--dark); }
.orb { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; vertical-align: middle; }
.orb .art-fallback { font-size: 0.6em; }

/* ---------------------------------------------------------- deck builder */
.topbar { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.deck-note { margin: 0 0 4px; }
.deck-slots { display: flex; gap: 10px; margin: 10px 0 14px; }
.deck-slot {
  flex: 1; background: var(--panel); border: 2px solid #3a3946; border-radius: 10px; padding: 8px;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative;
  border-left: 6px solid var(--group-color, #3a3946);
}
.deck-slot.selected { border-color: var(--accent); border-left-color: var(--group-color, var(--accent)); box-shadow: 0 0 0 2px #f0b35c55; }
.deck-slot.empty { color: var(--muted); }
.slot-label { font-size: 0.75em; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.slot-art { width: 90px; height: 90px; }
.art-empty { width: 90px; height: 90px; font-size: 2em; color: #fff3; }
.slot-name { font-weight: 600; }
.slot-item { font-size: 0.85em; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.deck-panes { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
.pane { background: var(--panel); border-radius: 10px; padding: 10px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 10px; }
.tabs button { padding: 4px 10px; font-size: 0.85em; }
.tabs button.active { background: var(--accent); color: #211a0c; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.char-card {
  position: relative; background: var(--panel-2); border-radius: 8px; padding: 6px; cursor: pointer;
  border-top: 4px solid var(--group-color, #555); transition: transform 0.1s, box-shadow 0.1s;
}
.char-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px #0006; }
.char-card.unplayable { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.7); }
.char-card.in-deck { outline: 2px solid var(--accent); }
.char-art { width: 100%; aspect-ratio: 1; }
.char-name { font-weight: 600; margin-top: 4px; font-size: 0.95em; }
.char-hp { font-size: 0.8em; color: var(--muted); }
.item-list { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow: auto; }
.item-row {
  display: flex; gap: 8px; align-items: flex-start; background: var(--panel-2); border-radius: 8px; padding: 6px;
  cursor: pointer; position: relative; border-left: 4px solid var(--group-color, #555); font-size: 0.9em;
}
.item-row .orb { width: 30px; height: 30px; flex: none; }
.item-row.selected { outline: 2px solid var(--accent); }
.item-row.unplayable { opacity: 0.45; cursor: not-allowed; }
.item-text .muted { font-size: 0.85em; }

/* ---------------------------------------------------------------- battle */
.battle-screen { display: flex; flex-direction: column; gap: 10px; min-height: 100vh; }
.battle-header {
  display: flex; align-items: center; gap: 12px; background: var(--panel); border-radius: 10px; padding: 8px 12px;
}
.hdr-center { flex: 1; text-align: center; }
.hdr-right { display: flex; gap: 8px; align-items: center; }
.timer { font-variant-numeric: tabular-nums; color: var(--accent); min-width: 3.5em; text-align: right; }
.range-pill { padding: 3px 12px; border-radius: 14px; background: #3a3946; font-weight: 600; }
.range-pill.range-close { background: #6b2f2f; }
.range-pill.range-far { background: #2f4a6b; }

.arena {
  position: relative; display: flex; justify-content: space-between; gap: 20px;
  background: linear-gradient(180deg, #1c1b25 0%, #25242f 70%, #1a1922 100%);
  border-radius: 12px; padding: 14px; min-height: 380px;
}
.side { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.side-name { color: var(--muted); font-size: 0.9em; }
.side.enemy .side-name { text-align: right; }
.active-panel { position: relative; display: flex; gap: 8px; align-items: flex-end; }
.side.enemy .active-panel { flex-direction: row-reverse; }
/* The plate hugs the outer edge; the sprite slides across its stage toward
   the middle when the range is close. */
.sprite-wrap { flex: none; width: 220px; display: flex; justify-content: flex-start; }
.side.enemy .sprite-wrap { justify-content: flex-end; }
.sprite { width: 140px; height: 210px; background: transparent; transition: transform 0.45s ease; }
.arena.range-close .side.you .sprite { transform: translateX(80px); }
.arena.range-close .side.enemy .sprite { transform: translateX(-80px); }
.sprite img { object-fit: contain; object-position: bottom; }
.side.enemy .sprite img { transform: scaleX(-1); }
.active-panel.dead .sprite { filter: grayscale(1) brightness(0.4); }
.plate { flex: 1; background: #1f1e27cc; border-radius: 10px; padding: 8px 10px; border-left: 5px solid var(--group-color, #555); min-width: 0; }
.plate-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.item-orb.broken { opacity: 0.4; filter: grayscale(1); }
.bar { position: relative; height: 16px; border-radius: 8px; background: #0f0e14; overflow: hidden; margin: 4px 0; }
.bar-fill { height: 100%; transition: width 0.35s ease; }
.bar.hp .bar-fill { background: linear-gradient(90deg, #b83b3b, var(--hp)); }
.bar.energy .bar-fill { background: linear-gradient(90deg, #2f63a8, var(--energy)); }
.bar-text { position: absolute; inset: 0; font-size: 0.72em; text-align: center; line-height: 16px; color: #fff; text-shadow: 0 1px 2px #000; }
.bar.mini { height: 9px; margin: 2px 0; }
.bar.mini .bar-text { font-size: 0.55em; line-height: 9px; }
.statuses { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip { font-size: 0.72em; padding: 1px 6px; border-radius: 8px; background: #3a3946; border: 1px solid transparent; }
.chip.buff { border-color: var(--buff); color: #c9f3c9; }
.chip.debuff { border-color: var(--debuff); color: #ffd0c8; }
.innate { font-size: 0.74em; color: var(--muted); margin-top: 6px; line-height: 1.25; }
.innate b { color: #d8d7e0; font-weight: 600; }
.moves-list { margin-top: 5px; display: flex; flex-direction: column; gap: 2px; font-size: 0.76em; }
.move-row { display: flex; justify-content: space-between; gap: 8px; padding: 1px 6px; border-left: 3px solid var(--physical); background: #ffffff08; border-radius: 0 4px 4px 0; }
.move-row.type-light { border-left-color: var(--light); }
.move-row.type-dark { border-left-color: var(--dark); }
.move-row.blocked { opacity: 0.45; }
.move-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.move-stats { color: var(--muted); white-space: nowrap; }

.bench { display: flex; gap: 8px; flex-wrap: wrap; }
.side.enemy .bench { justify-content: flex-end; }
.bench-card {
  position: relative; width: 118px; background: #1f1e27cc; border-radius: 8px; padding: 5px; font-size: 0.85em;
  border: 2px solid transparent;
}
.bench-card.is-active { border-color: #ffffff33; }
.bench-card.dead { opacity: 0.45; filter: grayscale(1); }
.bench-card.pickable { border-color: var(--accent); cursor: pointer; box-shadow: 0 0 12px #f0b35c66; }
.bench-card.pickable:hover { transform: translateY(-2px); }
.bench-art { width: 100%; aspect-ratio: 1; }
.bench-name { display: flex; justify-content: space-between; align-items: center; font-weight: 600; margin: 3px 0; }
.bench-card .chip { font-size: 0.65em; }

.battle-bottom { display: grid; grid-template-columns: 3fr 2fr; gap: 10px; }
.actions { background: var(--panel); border-radius: 10px; padding: 10px; min-height: 180px; }
.prompt { color: var(--muted); margin-bottom: 8px; }
.waiting { color: var(--muted); padding: 30px 10px; text-align: center; font-style: italic; }
.attack-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.action { text-align: left; display: flex; flex-direction: column; gap: 2px; }
.action small { color: var(--muted); font-size: 0.75em; }
.action.big { flex: 1; align-items: center; }
.attack { border-left: 5px solid var(--physical); }
.attack.type-light { border-left-color: var(--light); }
.attack.type-dark { border-left-color: var(--dark); }
.attack.blocked { opacity: 0.5; }
.atk-name { font-weight: 600; }
.atk-stats { display: flex; gap: 8px; font-size: 0.8em; color: var(--muted); }
.atk-range { margin-left: auto; text-transform: uppercase; font-size: 0.9em; letter-spacing: 0.04em; }
.atk-text, .atk-reason { font-size: 0.78em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.atk-reason { color: #ff9f8a; text-transform: capitalize; }

.log { background: var(--panel); border-radius: 10px; padding: 10px; height: 260px; overflow: auto; font-size: 0.86em; }
.log-line { padding: 1px 0; color: #d8d7e0; }
.log-line.log-turn { color: var(--accent); font-weight: 600; margin-top: 6px; }
.log-line.log-death, .log-line.log-over { color: #ff9f8a; font-weight: 600; }
.log-line.log-error { color: #ff8a80; }
.log-line.log-heal { color: #9fe09f; }

.float {
  position: absolute; left: 50%; top: 30%; transform: translateX(-50%); pointer-events: none; z-index: 5;
  font-weight: 700; font-size: 1.3em; text-shadow: 0 2px 4px #000; animation: floatUp 1.3s ease-out forwards; white-space: nowrap;
}
.float.damage { color: #ff6b5b; }
.float.crit { color: #ffcd3c; font-size: 1.7em; }
.float.dot { font-size: 1em; color: #ff9e8f; }
.float.heal { color: #8ff08f; }
.float.buff-float { color: #b7f5b7; font-size: 0.95em; }
.float.debuff-float { color: #ffb7a8; font-size: 0.95em; }
.float.muted-float { color: #d7d6de; font-size: 1em; }
.float.move-name { color: #fff; font-size: 1em; top: 10%; background: #000a; padding: 2px 8px; border-radius: 6px; }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, 10px); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -50px); } }
.hurt { animation: shake 0.45s; }
@keyframes shake { 0%, 100% { translate: 0 0; } 25% { translate: -6px 0; } 50% { translate: 6px 0; } 75% { translate: -4px 0; } }
.attacking .sprite-wrap { animation: lunge 0.35s ease-out; }
.side.enemy .attacking .sprite-wrap { animation-name: lungeEnemy; }
@keyframes lunge { 30% { translate: 22px 0; } }
@keyframes lungeEnemy { 30% { translate: -22px 0; } }

.overlay { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; z-index: 20; }
.overlay.hidden { display: none; }
.overlay-box { background: var(--panel); padding: 30px 40px; border-radius: 14px; text-align: center; }

@media (max-width: 860px) {
  .play-buttons { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
  .topbar h2 { order: -1; flex-basis: 100%; font-size: 1.2em; }
  .deck-slots { overflow-x: auto; padding-bottom: 4px; }
  .deck-slot { min-width: 118px; }
  .battle-header { flex-wrap: wrap; }
  .hdr-center { order: 3; flex-basis: 100%; }
  .deck-panes { grid-template-columns: 1fr; }
  .battle-bottom { grid-template-columns: 1fr; }
  .sprite { width: 100px; height: 150px; }
  .sprite-wrap { width: 140px; }
  .arena.range-close .side.you .sprite { transform: translateX(40px); }
  .arena.range-close .side.enemy .sprite { transform: translateX(-40px); }
}

@media (max-width: 480px) {
  .screen { padding: 12px; }
  .table-wrap { margin: 0 -12px; padding: 0 12px; }
  .admin .panel { padding: 12px; }
  .admin-tools input[type="search"] { max-width: none; flex-basis: 100%; }
  .login-card, .queue-card { padding: 22px 18px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .result { grid-template-columns: 3.5em minmax(0, 1fr); }
  .result > .muted { grid-column: 2; }
  .match-buttons { width: 100%; justify-content: flex-end; }
  .topbar button { padding: 8px 10px; }
}

/* Phones: stack the two sides of the arena, enemy on top, and shrink the sprites. */
@media (max-width: 600px) {
  .arena { flex-direction: column; gap: 14px; padding: 10px; min-height: 0; }
  .side.enemy { order: -1; }
  .sprite-wrap { width: 96px; }
  .sprite { width: 90px; height: 135px; }
  .arena.range-close .side.you .sprite, .arena.range-close .side.enemy .sprite { transform: none; }
  .bench-card { width: calc(33.3% - 6px); min-width: 96px; }
  .attack-grid { grid-template-columns: 1fr; }
  .battle-header { padding: 8px; gap: 8px; }
  .overlay-box { margin: 0 12px; padding: 24px 18px; }
}
