:root {
  color-scheme: dark;
  --bg: #080a09;
  --surface: #111412;
  --surface-2: #181c19;
  --surface-3: #212622;
  --line: rgba(240, 244, 237, 0.12);
  --line-strong: rgba(240, 244, 237, 0.22);
  --text: #f4f6f1;
  --muted: #9ca49e;
  --acid: #ccff4a;
  --acid-ink: #12170a;
  --danger: #ff6868;
  --header-height: 78px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
}

body {
  min-height: 100dvh;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 2px;
}

.app-shell {
  width: 100%;
  min-width: 0;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: var(--header-height) minmax(0, 1fr);
  background:
    radial-gradient(circle at 50% 10%, rgba(204, 255, 74, 0.055), transparent 34%),
    var(--bg);
}

.topbar {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(280px, 1fr);
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: rgba(10, 12, 11, 0.94);
  z-index: 20;
}

.brand,
.turn-controls,
.game-clock,
.brand-copy {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  min-width: 0;
}

.brand-copy {
  flex-direction: column;
  align-items: flex-start;
  line-height: 0.9;
}

.brand-copy strong {
  font-size: 18px;
  letter-spacing: 0.08em;
}

.brand-copy small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.28em;
}

.game-clock {
  justify-content: center;
  gap: 12px;
  min-width: 248px;
}

.game-clock strong,
.turn-clock strong {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.game-clock strong {
  font-size: 21px;
}

.clock-label,
.round-label,
.turn-clock span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.round-label {
  padding: 6px 8px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
}

.round-label b {
  margin-left: 3px;
  color: var(--text);
}

.turn-controls {
  justify-content: flex-end;
  gap: 8px;
}

.turn-clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-right: 4px;
  line-height: 1;
}

.turn-clock strong {
  margin-top: 5px;
  font-size: 17px;
}

.icon-button,
.next-button,
.dialog-close,
.small-add-button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
}

.icon-button:hover,
.dialog-close:hover,
.secondary-button:hover {
  background: var(--surface-3);
  border-color: var(--line-strong);
}

.icon-button svg,
.next-button svg,
.search-input-wrap svg {
  width: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.icon-play {
  display: none;
  fill: currentColor !important;
  stroke: none !important;
}

.is-paused .icon-pause {
  display: none;
}

.is-paused .icon-play {
  display: block;
}

.next-button {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 15px;
  border: 0;
  border-radius: 7px;
  background: var(--acid);
  color: var(--acid-ink);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.next-button:hover,
.primary-button:hover {
  filter: brightness(1.08);
}

.next-button:active,
.primary-button:active,
.life-step:active {
  transform: translateY(1px);
}

.table-grid {
  width: 100%;
  min-height: 0;
  min-width: 0;
  display: grid;
  gap: 6px;
  padding: 6px;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
}

.count-4.layout-grid {
  grid-template: repeat(2, minmax(0, 1fr)) / repeat(2, minmax(0, 1fr));
}

.count-4.layout-bands {
  grid-template: repeat(4, minmax(0, 1fr)) / minmax(0, 1fr);
}

.count-3.layout-crown,
.count-3.layout-valley {
  grid-template: repeat(2, minmax(0, 1fr)) / repeat(2, minmax(0, 1fr));
}

.count-3.layout-crown .player-card:first-child,
.count-3.layout-valley .player-card:last-child {
  grid-column: 1 / -1;
}

.count-2.layout-horizontal {
  grid-template: minmax(0, 1fr) / repeat(2, minmax(0, 1fr));
}

.count-2.layout-vertical {
  grid-template: repeat(2, minmax(0, 1fr)) / minmax(0, 1fr);
}

.player-card {
  --player-accent: #62d5ff;
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  isolation: isolate;
  background: #111512;
  transition: border-color 180ms ease, box-shadow 180ms ease;
  touch-action: manipulation;
}

.player-card:nth-child(2) {
  --player-accent: #d890ff;
}

.player-card:nth-child(3) {
  --player-accent: #ffb86a;
}

.player-card:nth-child(4) {
  --player-accent: #70e0ae;
}

.player-card.is-active {
  border-color: color-mix(in srgb, var(--player-accent), white 12%);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--player-accent), transparent 40%);
}

.player-card.is-defeated {
  border-color: rgba(255, 104, 104, 0.7);
}

.commander-art,
.card-shade,
.card-grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.commander-art {
  z-index: -3;
  background-position: center 18%;
  background-size: cover;
  opacity: 0.52;
  filter: saturate(0.82) contrast(1.08);
  transform: scale(1.015);
}

.card-shade {
  z-index: -2;
  background:
    linear-gradient(90deg, rgba(7, 10, 8, 0.76), transparent 27%, transparent 73%, rgba(7, 10, 8, 0.76)),
    linear-gradient(180deg, rgba(7, 10, 8, 0.84) 0%, rgba(7, 10, 8, 0.15) 38%, rgba(7, 10, 8, 0.86) 100%);
}

.card-grain {
  z-index: -1;
  opacity: 0.25;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.13'/%3E%3C/svg%3E");
}

.player-head {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 11px 0;
}

.player-identity {
  min-width: 0;
}

.player-name-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.player-name {
  overflow: hidden;
  font-size: clamp(12px, 1.5vw, 16px);
  font-weight: 850;
  letter-spacing: 0.015em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-dot {
  display: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--player-accent);
  box-shadow: 0 0 14px var(--player-accent);
}

.is-active .active-dot {
  display: inline-block;
}

.commander-name {
  display: block;
  max-width: 38vw;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: clamp(8px, 1vw, 10px);
  font-weight: 650;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.head-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.turn-badge,
.defeated-badge {
  padding: 5px 7px;
  border: 1px solid color-mix(in srgb, var(--player-accent), transparent 40%);
  border-radius: 999px;
  background: color-mix(in srgb, var(--player-accent), transparent 85%);
  color: color-mix(in srgb, var(--player-accent), white 20%);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.defeated-badge {
  border-color: rgba(255, 104, 104, 0.55);
  background: rgba(255, 104, 104, 0.14);
  color: #ffaaaa;
}

.edit-player-button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(13, 16, 14, 0.62);
  cursor: pointer;
}

.edit-player-button svg {
  width: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.life-control {
  min-height: 0;
  display: grid;
  grid-template-columns: clamp(42px, 8vw, 68px) minmax(0, 1fr) clamp(42px, 8vw, 68px);
  align-items: stretch;
  margin: 2px 5px;
}

.life-step {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: rgba(244, 246, 241, 0.74);
  cursor: pointer;
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 250;
  user-select: none;
}

.life-step:hover {
  color: var(--text);
}

.life-center {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.damage-overline {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 2px;
  color: rgba(244, 246, 241, 0.58);
  font-size: clamp(6px, 0.7vw, 8px);
  font-weight: 850;
  letter-spacing: 0.13em;
  white-space: nowrap;
}

.damage-overline::before,
.damage-overline::after {
  content: "";
  width: 13px;
  height: 1px;
  background: currentColor;
  opacity: 0.4;
}

.damage-chips {
  display: flex;
  justify-content: center;
  gap: 4px;
  min-height: 21px;
}

.damage-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 999px;
  background: rgba(8, 10, 9, 0.45);
  font-size: clamp(7px, 0.9vw, 9px);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.damage-chip.is-danger {
  border-color: rgba(255, 104, 104, 0.65);
  color: #ffb0b0;
}

.damage-source {
  max-width: 64px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.life-value {
  margin: -2px 0 -7px;
  color: var(--text);
  font-size: clamp(64px, 10vw, 118px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.085em;
  line-height: 0.91;
  text-shadow: 0 5px 30px rgba(0, 0, 0, 0.35);
}

.count-4.layout-bands .life-value {
  font-size: clamp(44px, 7vh, 70px);
}

.card-footer {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px 9px;
}

.counter-summary {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
}

.counter-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(10, 12, 11, 0.52);
  color: var(--muted);
  font-size: clamp(7px, 0.82vw, 9px);
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.counter-chip b {
  color: var(--text);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.counter-chip.is-danger b {
  color: var(--danger);
}

.info-button {
  flex: none;
  min-height: 29px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: rgba(10, 12, 11, 0.68);
  font-size: 8px;
  font-weight: 850;
  letter-spacing: 0.1em;
  cursor: pointer;
}

.info-button span:first-child {
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
}

.life-delta {
  position: absolute;
  z-index: 5;
  top: 50%;
  left: 50%;
  color: var(--acid);
  font-size: 24px;
  font-weight: 900;
  pointer-events: none;
  animation: delta-float 650ms ease-out forwards;
}

.life-delta.is-negative {
  color: #ff8c8c;
}

@keyframes delta-float {
  from { opacity: 0; transform: translate(-50%, 20px) scale(0.75); }
  30% { opacity: 1; }
  to { opacity: 0; transform: translate(-50%, -42px) scale(1); }
}

.toast-region {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(25, 29, 26, 0.96);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.38);
  font-size: 12px;
  animation: toast-in 180ms ease-out;
}

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

.app-dialog {
  width: min(620px, calc(100vw - 24px));
  max-height: min(820px, calc(100dvh - 24px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.62);
}

.app-dialog::backdrop {
  background: rgba(3, 5, 4, 0.76);
  backdrop-filter: blur(8px);
}

.settings-dialog.is-onboarding #settingsCloseButton,
.settings-dialog.is-onboarding #settingsCancelButton,
.settings-dialog.is-onboarding #resetSection {
  display: none;
}

.settings-dialog.is-onboarding .dialog-actions {
  justify-content: stretch;
}

.settings-dialog.is-onboarding #applySettingsButton {
  width: 100%;
}

.dialog-card {
  max-height: min(820px, calc(100dvh - 24px));
  overflow-x: hidden;
  overflow-y: auto;
  padding: 22px;
}

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

.eyebrow,
.field-label,
.text-field > span,
.life-start-field span {
  color: var(--acid);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.dialog-header h2 {
  margin: 5px 0 4px;
  font-size: clamp(23px, 5vw, 34px);
  letter-spacing: -0.045em;
  line-height: 1;
}

#settingsDialogTitle:focus {
  outline: none;
}

.dialog-header p,
.form-section p,
.stats-section p,
.scryfall-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.dialog-close {
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0 0 3px;
  border-radius: 50%;
  font-size: 24px;
  font-weight: 300;
}

.form-section + .form-section,
.stats-section + .stats-section {
  margin-top: 22px;
}

.duration-field {
  display: grid;
  gap: 9px;
}

.select-wrap {
  position: relative;
  display: block;
}

.select-wrap select {
  width: 100%;
  height: 46px;
  appearance: none;
  padding: 0 42px 0 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0b0e0c;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
}

.select-wrap svg {
  position: absolute;
  top: 50%;
  right: 14px;
  width: 17px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  pointer-events: none;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-top: 9px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0c0f0d;
}

.segmented-control button,
.layout-option {
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.segmented-control button {
  min-height: 40px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.segmented-control button.is-selected,
.layout-option.is-selected {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--line-strong);
}

.layout-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 9px;
}

.layout-option {
  min-height: 86px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px;
  color: var(--muted);
  text-align: left;
}

.layout-preview {
  flex: none;
  width: 54px;
  height: 54px;
  display: grid;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #0b0e0c;
}

.layout-preview i {
  display: block;
  border-radius: 2px;
  background: rgba(204, 255, 74, 0.45);
}

.preview-horizontal { grid-template-columns: repeat(2, 1fr); }
.preview-vertical { grid-template-rows: repeat(2, 1fr); }
.preview-crown,
.preview-valley,
.preview-grid { grid-template: repeat(2, 1fr) / repeat(2, 1fr); }
.preview-crown i:first-child,
.preview-valley i:last-child { grid-column: 1 / -1; }
.preview-bands { grid-template-rows: repeat(4, 1fr); }

.layout-option strong {
  display: block;
  color: currentColor;
  font-size: 12px;
}

.layout-option small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
}

.reset-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px auto;
  align-items: end;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(255, 104, 104, 0.22);
  border-radius: 10px;
  background: rgba(255, 104, 104, 0.045);
}

.reset-section .field-label {
  color: #ff9c9c;
}

.life-start-field,
.text-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.life-start-field input,
.text-field input,
.add-counter-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0b0e0c;
  color: var(--text);
}

.life-start-field input {
  height: 38px;
  padding: 0 8px;
  text-align: center;
  font-weight: 800;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.primary-button,
.secondary-button {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.primary-button {
  border: 1px solid var(--acid);
  background: var(--acid);
  color: var(--acid-ink);
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
}

.danger-button {
  border-color: rgba(255, 104, 104, 0.3);
  color: #ff9c9c;
}

.text-field input {
  height: 46px;
  padding: 0 13px;
}

.commander-field {
  margin-top: 18px;
}

.search-input-wrap {
  position: relative;
}

.search-input-wrap > svg {
  position: absolute;
  top: 50%;
  left: 13px;
  width: 17px;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-input-wrap input {
  padding-left: 40px;
  padding-right: 38px;
}

.search-spinner {
  position: absolute;
  top: 50%;
  right: 13px;
  width: 15px;
  height: 15px;
  display: none;
  border: 2px solid var(--line-strong);
  border-top-color: var(--acid);
  border-radius: 50%;
  transform: translateY(-50%);
  animation: spin 700ms linear infinite;
}

.search-spinner.is-visible {
  display: block;
}

@keyframes spin {
  to { transform: translateY(-50%) rotate(360deg); }
}

.selected-commander {
  margin-top: 10px;
}

.commander-selection {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 8px;
  border: 1px solid rgba(204, 255, 74, 0.24);
  border-radius: 9px;
  background: rgba(204, 255, 74, 0.045);
}

.commander-selection img,
.search-card img {
  width: 54px;
  height: 42px;
  object-fit: cover;
  border-radius: 5px;
  background: var(--surface-3);
}

.commander-selection strong,
.search-card strong {
  display: block;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.commander-selection small,
.search-card small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.clear-selection {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

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

.search-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d100e;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.search-card:hover {
  border-color: rgba(204, 255, 74, 0.45);
  background: #121611;
}

.search-message {
  grid-column: 1 / -1;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.scryfall-note {
  margin-top: 10px;
  font-size: 9px;
}

.scryfall-note a {
  color: var(--text);
}

.stats-dialog {
  width: min(680px, calc(100vw - 24px));
}

.stats-section {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.section-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.rule-chip {
  flex: none;
  padding: 5px 7px;
  border: 1px solid rgba(255, 104, 104, 0.28);
  border-radius: 4px;
  color: #ff9e9e;
  font-size: 8px;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.small-add-button {
  flex: none;
  min-height: 29px;
  padding: 0 9px;
  border-radius: 5px;
  color: var(--acid);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.stat-list {
  display: grid;
  gap: 6px;
}

.stat-row {
  min-height: 52px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c0f0d;
}

.stat-row.is-danger {
  border-color: rgba(255, 104, 104, 0.45);
  background: rgba(255, 104, 104, 0.055);
}

.stat-name {
  min-width: 0;
}

.stat-name strong {
  display: block;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-name small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.stepper {
  display: grid;
  grid-template-columns: 38px 50px 38px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.stepper button {
  height: 38px;
  border: 0;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
}

.stepper button:hover {
  background: var(--surface-3);
}

.stepper output {
  display: grid;
  place-items: center;
  height: 38px;
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  font-weight: 850;
}

.counter-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.delete-counter {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 17px;
}

.delete-counter:hover {
  color: var(--danger);
  background: rgba(255, 104, 104, 0.08);
}

.add-counter-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  margin: 0 0 8px;
}

.add-counter-form[hidden] {
  display: none;
}

.add-counter-form input {
  min-height: 40px;
  padding: 0 11px;
}

@media (max-width: 720px) {
  :root {
    --header-height: 68px;
  }

  .topbar {
    grid-template-columns: auto 1fr auto;
    gap: 7px;
    padding: 8px;
  }

  .brand-copy,
  .clock-label,
  .turn-clock span {
    display: none;
  }

  .game-clock {
    min-width: 0;
    justify-content: flex-start;
    gap: 7px;
  }

  .game-clock strong {
    font-size: 16px;
  }

  .round-label {
    padding: 4px 0 4px 7px;
    font-size: 7px;
  }

  .turn-controls {
    gap: 5px;
  }

  .turn-clock {
    margin-right: 1px;
  }

  .turn-clock strong {
    margin: 0;
    font-size: 14px;
  }

  .icon-button {
    width: 36px;
    height: 36px;
  }

  .next-button {
    min-height: 36px;
    padding: 0 10px;
  }

  .next-button .next-copy {
    display: none;
  }

  .next-button svg {
    width: 18px;
  }

  .table-grid {
    gap: 4px;
    padding: 4px;
  }

  .player-card {
    border-radius: 9px;
  }

  .player-head {
    padding: 7px 7px 0;
  }

  .edit-player-button {
    width: 28px;
    height: 28px;
  }

  .turn-badge {
    display: none;
  }

  .commander-name {
    max-width: 27vw;
  }

  .life-control {
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    margin: 0;
  }

  .life-value {
    font-size: clamp(55px, 16vw, 86px);
  }

  .damage-overline::before,
  .damage-overline::after {
    width: 5px;
  }

  .damage-source {
    max-width: 35px;
  }

  .card-footer {
    padding: 0 6px 6px;
  }

  .counter-chip {
    padding: 4px 5px;
  }

  .counter-summary .counter-chip:nth-child(n + 3) {
    display: none;
  }

  .info-button {
    min-height: 27px;
    padding: 0 6px;
  }

  .info-button .info-copy {
    display: none;
  }

  .dialog-card {
    padding: 18px;
  }

  .search-results {
    grid-template-columns: 1fr;
  }

  .reset-section {
    grid-template-columns: minmax(0, 1fr) 68px;
  }

  .reset-section .danger-button {
    grid-column: 1 / -1;
  }
}

@media (max-height: 650px) {
  :root {
    --header-height: 58px;
  }

  .icon-button,
  .next-button {
    width: 34px;
    height: 34px;
    min-height: 34px;
  }

  .life-value {
    font-size: clamp(44px, 12vh, 78px);
  }

  .damage-overline {
    display: none;
  }

  .player-head {
    padding-top: 5px;
  }

  .card-footer {
    padding-bottom: 4px;
  }
}

@media (max-width: 430px) and (max-height: 780px) {
  .damage-overline {
    display: none;
  }

  .damage-chips {
    min-height: 18px;
  }

  .damage-chip {
    padding: 2px 4px;
  }

  .counter-chip {
    font-size: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
