:root {
  --bg: #070b17;
  --bg-soft: #0d1733;
  --panel: rgba(18, 30, 61, 0.88);
  --panel-strong: rgba(20, 35, 72, 0.95);
  --panel-border: rgba(125, 176, 255, 0.22);
  --text: #e9f0ff;
  --muted: #a7b8dd;
  --accent: #4dc8ff;
  --accent-2: #76f5be;
  --danger: #ff7d96;
  --warning: #ffd27a;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  --radius-soft: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  background:
    radial-gradient(1200px 560px at 20% -12%, rgba(64, 112, 218, 0.35), transparent 65%),
    radial-gradient(900px 500px at 90% -20%, rgba(40, 95, 189, 0.35), transparent 68%),
    linear-gradient(180deg, #060a15 0%, #060d1e 40%, #081127 100%);
  background-attachment: fixed;
}

#app {
  max-width: 1680px;
  margin: 0 auto;
  padding: 22px 18px calc(26px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
}

.topbar h1 {
  margin: 8px 0 0;
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(1.3rem, 2.6vw, 2rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f2f7ff;
  text-shadow: 0 0 14px rgba(77, 200, 255, 0.25);
}

.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
}

.topbar-actions {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.music-widget {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: min(360px, calc(100vw - 24px));
  z-index: 1200;
  backdrop-filter: blur(10px);
  background: linear-gradient(180deg, rgba(20, 34, 70, 0.96), rgba(12, 22, 47, 0.96));
}

.music-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.music-track {
  margin: 0 0 10px;
  color: #d7e8ff;
  font-size: 13px;
  min-height: 34px;
}

.music-controls {
  margin-bottom: 10px;
}

.music-volume {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

#musicVolume {
  width: 100%;
  margin-top: 6px;
  padding: 0;
}

.stats-inline {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-actions {
  justify-content: flex-end;
}

.stat-chip {
  padding: 8px 10px;
  border: 1px solid rgba(132, 176, 255, 0.4);
  border-radius: 999px;
  background: rgba(10, 23, 50, 0.78);
  font-size: 12px;
  font-weight: 600;
  color: #d4e4ff;
  backdrop-filter: blur(6px);
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  overflow: auto;
  padding-bottom: 2px;
  scroll-snap-type: x mandatory;
}

.tabs button {
  border-radius: 999px;
  padding: 10px 16px;
  border: 1px solid rgba(103, 147, 230, 0.6);
  background: rgba(17, 35, 72, 0.9);
  color: #dbe8ff;
  font-weight: 700;
  white-space: nowrap;
  scroll-snap-align: start;
}

.tabs button.active {
  border-color: rgba(77, 200, 255, 0.7);
  background: linear-gradient(135deg, rgba(77, 200, 255, 0.22), rgba(118, 245, 190, 0.2));
  color: #eff8ff;
}

.button-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fade-in 180ms ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel {
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel-strong) 0%, var(--panel) 100%);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}

.panel h2,
.panel h3,
.panel h4 {
  margin: 0 0 10px;
  font-family: 'Orbitron', sans-serif;
  letter-spacing: 0.04em;
  font-weight: 700;
  color: #f2f7ff;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 160px 1fr;
  gap: 10px;
  align-items: end;
}

.field-row {
  display: grid;
  gap: 6px;
}

.field-row label,
label {
  font-size: 12px;
  color: var(--muted);
}

input,
select,
textarea,
button {
  font-family: inherit;
}

input,
select,
textarea {
  background: rgba(10, 23, 50, 0.86);
  border: 1px solid rgba(105, 150, 231, 0.45);
  border-radius: var(--radius-soft);
  padding: 8px 10px;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(77, 200, 255, 0.28);
  border-color: rgba(77, 200, 255, 0.7);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
}

button {
  border-radius: var(--radius-soft);
  border: 1px solid rgba(104, 149, 230, 0.5);
  background: rgba(20, 45, 92, 0.92);
  color: #e8f2ff;
  padding: 9px 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(123, 198, 255, 0.72);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
}

button.primary {
  background: linear-gradient(135deg, rgba(57, 188, 255, 0.9), rgba(94, 236, 187, 0.9));
  color: #04273b;
  border-color: rgba(164, 246, 224, 0.7);
}

button.danger {
  border-color: rgba(255, 125, 150, 0.7);
  color: #ffd5df;
  background: rgba(92, 28, 47, 0.4);
}

button.ghost {
  background: transparent;
}

button:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.pokemon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(106px, 1fr));
  gap: 10px;
  max-height: 70vh;
  overflow: auto;
  padding-right: 4px;
}

.pokemon-card {
  border: 1px solid rgba(102, 148, 230, 0.35);
  border-radius: 14px;
  background: rgba(13, 30, 64, 0.82);
  padding: 8px 6px;
  text-align: center;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.pokemon-card:hover {
  transform: translateY(-2px) scale(1.01);
  border-color: rgba(77, 200, 255, 0.75);
  box-shadow: 0 12px 26px rgba(7, 15, 31, 0.55);
}

.pokemon-card img {
  image-rendering: pixelated;
  width: 76px;
  height: 76px;
  object-fit: contain;
  filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.45));
}

.pokemon-card.unconfigured img {
  filter: grayscale(1) brightness(0.2) contrast(1.1);
}

.pokemon-card .name {
  font-size: 12px;
  color: #d4e4ff;
  line-height: 1.2;
  min-height: 29px;
}

.pokemon-card .id {
  font-size: 10px;
  color: #8eadde;
}

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

.participants-panel {
  max-height: 84vh;
  overflow: auto;
}

.count-pill {
  text-align: center;
  border-radius: 10px;
  border: 1px solid rgba(118, 245, 190, 0.4);
  padding: 8px;
  background: rgba(25, 63, 66, 0.35);
  font-weight: 700;
}

.participants-list {
  display: grid;
  gap: 8px;
  margin: 10px 0;
  max-height: 62vh;
  overflow: auto;
}

.selection-tools {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
}

.selection-tools label {
  font-size: 12px;
  color: var(--muted);
}

.selection-tools input {
  width: 100%;
}

.participant-row {
  display: grid;
  grid-template-columns: auto 36px 1fr;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(104, 149, 230, 0.35);
  border-radius: 10px;
  padding: 6px;
  background: rgba(12, 27, 58, 0.8);
}

.participant-row img {
  width: 34px;
  height: 34px;
  image-rendering: pixelated;
}

.tournament-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bracket-shell {
  margin-top: 12px;
  border-radius: 14px;
  border: 1px solid rgba(98, 145, 230, 0.35);
  background: radial-gradient(circle at 35% 0%, rgba(77, 200, 255, 0.12), transparent 42%), rgba(10, 20, 42, 0.9);
  position: relative;
  overflow: auto;
  min-height: 420px;
  max-height: 68vh;
  -webkit-overflow-scrolling: touch;
}

.bracket-toolbar {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.bracket-legend {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.legend-item {
  border-radius: 999px;
  border: 1px solid rgba(103, 149, 230, 0.42);
  background: rgba(11, 24, 50, 0.7);
  padding: 4px 10px;
  font-size: 11px;
  color: #bdd0f5;
  letter-spacing: 0.02em;
}

.legend-item.ready {
  border-color: rgba(77, 200, 255, 0.75);
  color: #98deff;
}

.legend-item.completed {
  border-color: rgba(118, 245, 190, 0.75);
  color: #abf8d9;
}

.legend-item.pending {
  border-color: rgba(148, 171, 220, 0.55);
  color: #ced9ef;
}

.legend-item.selected {
  border-color: rgba(118, 245, 190, 0.85);
  box-shadow: 0 0 0 1px rgba(118, 245, 190, 0.35) inset;
  color: #e8fff4;
}

.bracket-stage {
  position: relative;
  min-width: max-content;
  min-height: 100%;
  zoom: 1;
}

.bracket-tree {
  position: relative;
  display: flex;
  gap: 34px;
  padding: 20px;
  min-width: max-content;
}

.bracket-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.bracket-link {
  fill: none;
  stroke: rgba(119, 174, 255, 0.45);
  stroke-width: 2;
}

.bracket-link.completed {
  stroke: rgba(118, 245, 190, 0.65);
}

.round-column {
  display: flex;
  flex-direction: column;
  min-width: 228px;
}

.round-title {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #97b5e8;
}

.match-node {
  border-radius: 12px;
  border: 1px solid rgba(102, 148, 230, 0.4);
  background: rgba(15, 31, 64, 0.92);
  padding: 8px;
  display: grid;
  gap: 7px;
  min-height: 108px;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.match-node:hover {
  transform: translateY(-1px);
  border-color: rgba(124, 206, 255, 0.75);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.35);
}

.match-node.selected {
  border-color: rgba(118, 245, 190, 0.9);
  box-shadow: 0 0 0 1px rgba(118, 245, 190, 0.5) inset;
}

.match-node.ready {
  border-color: rgba(77, 200, 255, 0.75);
  animation: pulse-ready 1.8s ease-in-out infinite;
}

.match-node.completed,
.match-node.bye {
  border-color: rgba(118, 245, 190, 0.65);
}

@keyframes pulse-ready {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(77, 200, 255, 0);
  }
  50% {
    box-shadow: 0 0 0 2px rgba(77, 200, 255, 0.22);
  }
}

.match-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: #b6caef;
}

.badge {
  font-size: 10px;
  border-radius: 999px;
  padding: 2px 6px;
  border: 1px solid rgba(103, 148, 230, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge.ready {
  border-color: rgba(77, 200, 255, 0.7);
  color: #92ddff;
}

.badge.completed,
.badge.bye {
  border-color: rgba(118, 245, 190, 0.7);
  color: #9cf7d3;
}

.badge.pending {
  color: #c0cee8;
}

.player-row {
  display: grid;
  grid-template-columns: 22px 20px 1fr auto;
  gap: 6px;
  align-items: center;
  font-size: 11px;
}

.player-slot {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-size: 10px;
  border: 1px solid rgba(99, 147, 229, 0.5);
  color: #9eb5df;
}

.player-row img {
  width: 20px;
  height: 20px;
  image-rendering: pixelated;
}

.player-row.winner {
  color: #b8fbe0;
}

.player-win {
  font-size: 10px;
  color: #9ff7d7;
  letter-spacing: 0.04em;
}

.match-extra {
  font-size: 10px;
  color: #9ef7d8;
  padding-left: 2px;
}

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

.node-actions button {
  padding: 5px 8px;
  font-size: 11px;
}

.battle-viewer {
  position: relative;
}

.battle-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.speed-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(101, 149, 230, 0.5);
  border-radius: 10px;
  padding: 6px 10px;
  background: rgba(12, 26, 54, 0.65);
  color: #cfe3ff;
  font-size: 12px;
  font-weight: 700;
}

.speed-control input {
  width: 130px;
  padding: 0;
}

#battleCanvas {
  width: 100%;
  height: clamp(280px, 46vw, 430px);
  border-radius: 14px;
  border: 1px solid rgba(102, 148, 230, 0.55);
  background: radial-gradient(circle at 20% 0%, rgba(77, 200, 255, 0.15), transparent 45%), rgba(11, 21, 45, 0.95);
  margin-top: 10px;
  touch-action: manipulation;
}

.timeline-controls {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(103, 149, 230, 0.32);
  border-radius: 10px;
  background: rgba(10, 21, 44, 0.72);
  padding: 8px 10px;
}

.timeline-range-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.timeline-range-label input {
  width: min(52vw, 460px);
  padding: 0;
}

#timelineLabel {
  font-size: 12px;
  color: #bcd0f8;
  min-width: 72px;
  text-align: right;
}

.battle-log {
  margin-top: 10px;
  max-height: 250px;
  overflow: auto;
  border-radius: 12px;
  border: 1px solid rgba(103, 149, 230, 0.4);
  background: rgba(11, 23, 49, 0.75);
  padding: 8px;
  display: grid;
  gap: 6px;
}

.log-line {
  font-size: 12px;
  border-bottom: 1px solid rgba(98, 145, 230, 0.2);
  padding-bottom: 4px;
}

.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.summary-card {
  border-radius: 12px;
  border: 1px solid rgba(105, 151, 231, 0.4);
  background: rgba(11, 26, 53, 0.78);
  padding: 10px;
}

.summary-card .value {
  font-size: 28px;
  font-family: 'Orbitron', sans-serif;
  color: #9de9ff;
  margin-top: 4px;
}

.records-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.record-card {
  border-radius: 12px;
  border: 1px solid rgba(104, 149, 230, 0.35);
  background: rgba(11, 25, 50, 0.82);
  padding: 10px;
}

.record-card h4 {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 0.03em;
}

.record-list {
  display: grid;
  gap: 5px;
}

.record-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.record-row .left {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.record-row img {
  width: 18px;
  height: 18px;
  image-rendering: pixelated;
}

.table-wrap {
  overflow: auto;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.field-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 940px;
}

.stats-table th,
.stats-table td {
  border-bottom: 1px solid rgba(98, 146, 229, 0.25);
  padding: 8px;
  text-align: left;
  font-size: 12px;
}

.stats-table th {
  color: #a7bde7;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
}

.stats-cell-pokemon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.stats-cell-pokemon img {
  width: 22px;
  height: 22px;
  image-rendering: pixelated;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-row {
  border: 1px solid rgba(103, 149, 230, 0.3);
  background: rgba(13, 30, 62, 0.7);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

dialog {
  width: min(1020px, calc(100vw - 24px));
  border: 1px solid rgba(110, 157, 234, 0.45);
  border-radius: 18px;
  background: rgba(11, 23, 50, 0.97);
  color: var(--text);
  padding: 0;
}

dialog::backdrop {
  background: rgba(1, 4, 11, 0.72);
}

#setForm > header,
#setForm > footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(104, 150, 231, 0.32);
}

#setForm > footer {
  border-top: 1px solid rgba(104, 150, 231, 0.32);
  border-bottom: none;
}

.set-layout {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 14px;
  padding: 14px;
}

.sprite-box {
  border-radius: 12px;
  border: 1px solid rgba(101, 149, 230, 0.35);
  background: rgba(12, 27, 56, 0.82);
  text-align: center;
  padding: 10px;
}

.sprite-box img {
  width: 126px;
  height: 126px;
  image-rendering: pixelated;
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.moves-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.moves-grid label {
  display: grid;
  gap: 5px;
  font-size: 12px;
}

.stats-editor {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.stats-grid label {
  display: grid;
  gap: 4px;
  font-size: 11px;
}

.toast-stack {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 9999;
  display: grid;
  gap: 8px;
}

.toast {
  border-radius: 10px;
  padding: 9px 10px;
  border: 1px solid rgba(107, 151, 230, 0.65);
  background: rgba(10, 24, 49, 0.9);
  color: #eaf2ff;
  font-size: 12px;
  min-width: 220px;
  animation: toast-in 180ms ease;
}

.toast.ok {
  border-color: rgba(118, 245, 190, 0.7);
}

.toast.error {
  border-color: rgba(255, 125, 150, 0.8);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1160px) {
  .layout-columns {
    grid-template-columns: 1fr;
  }

  .participants-panel {
    max-height: none;
  }

  .admin-actions {
    justify-content: flex-start;
  }

  .participants-list {
    max-height: 44vh;
  }
}

@media (max-width: 920px) {
  #app {
    padding: 16px 12px calc(18px + env(safe-area-inset-bottom));
  }

  .topbar {
    flex-direction: column;
    gap: 14px;
  }

  .topbar h1 {
    font-size: clamp(1.15rem, 7vw, 1.7rem);
    line-height: 1.2;
  }

  .topbar-actions {
    width: 100%;
    justify-items: start;
  }

  .stats-inline {
    justify-content: flex-start;
  }

  .tabs {
    position: sticky;
    top: 0;
    z-index: 40;
    background: linear-gradient(180deg, rgba(8, 15, 34, 0.97), rgba(8, 15, 34, 0.82));
    backdrop-filter: blur(8px);
    margin: 0 -12px 12px;
    padding: 8px 12px 8px;
  }

  .panel {
    padding: 12px;
    border-radius: 14px;
  }

  .filters,
  .set-layout,
  .grid-two,
  .moves-grid,
  .stats-editor {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .selection-tools {
    grid-template-columns: 1fr;
  }

  .music-widget {
    position: static;
    width: 100%;
    margin-top: 12px;
    border-radius: 14px;
    box-shadow: var(--shadow);
  }

  .music-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .music-controls button {
    width: 100%;
  }

  .bracket-shell {
    min-height: 340px;
    max-height: 58vh;
  }

  .round-column {
    min-width: 208px;
  }

  .battle-header {
    flex-direction: column;
    align-items: stretch;
  }

  .battle-header .button-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .battle-header .button-row button,
  .battle-header .button-row .speed-control {
    width: 100%;
    justify-content: center;
  }

  .speed-control {
    justify-content: space-between;
  }

  .speed-control input {
    width: 100%;
    min-width: 0;
  }

  .timeline-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .timeline-range-label {
    width: 100%;
    justify-content: space-between;
  }

  .timeline-range-label input {
    width: 100%;
  }

  #timelineLabel {
    text-align: left;
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .tabs button {
    padding: 9px 12px;
    font-size: 13px;
  }

  .pokemon-grid {
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 8px;
  }

  .pokemon-card img {
    width: 66px;
    height: 66px;
  }

  .round-column {
    min-width: 188px;
  }

  .match-node {
    min-height: 118px;
  }

  .player-row {
    grid-template-columns: 18px 18px 1fr auto;
    font-size: 10px;
  }

  .battle-header .button-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #battleCanvas {
    height: clamp(250px, 58vw, 360px);
  }

  .battle-log {
    max-height: 190px;
  }

  .history-row {
    flex-direction: column;
    align-items: flex-start;
  }

  dialog {
    width: calc(100vw - 8px);
    border-radius: 14px;
  }
}

@media (max-width: 460px) {
  #app {
    padding: 14px 8px calc(16px + env(safe-area-inset-bottom));
  }

  .subtitle {
    font-size: 13px;
  }

  .stat-chip {
    padding: 7px 9px;
    font-size: 11px;
  }

  .music-track {
    font-size: 12px;
    min-height: 30px;
  }
}
