:root {
  color-scheme: light;
  --ink: #291544;
  --ink-soft: #665b79;
  --ink-faint: #9289a1;
  --paper: #fbf9fe;
  --surface: #ffffff;
  --line: #ece6f3;
  --purple: #7046d9;
  --purple-dark: #5735b5;
  --purple-wash: #f0ebff;
  --mint: #4bb6a5;
  --pink: #ef7696;
  --yellow: #f4cf68;
  --blue: #68a8ee;
  --red: #d94d6b;
  --shadow: 0 12px 32px rgba(54, 30, 82, 0.09), 0 2px 8px rgba(54, 30, 82, 0.04);
  --rounded: ui-rounded, "SF Pro Rounded", "Nunito", "Avenir Next", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-family: var(--rounded);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-optical-sizing: auto;
}

* { box-sizing: border-box; }

html { min-width: 320px; min-height: 100%; background: var(--paper); }

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 8% 2%, rgba(142, 105, 246, 0.10), transparent 32rem),
    radial-gradient(ellipse at 93% 14%, rgba(75, 182, 165, 0.10), transparent 28rem),
    var(--paper);
  font-family: var(--rounded);
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(112, 70, 217, 0.45);
  outline-offset: 3px;
}

.app-shell {
  width: min(100%, 1560px);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) clamp(14px, 3.2vw, 42px) max(24px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand-lockup { display: inline-flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 15px;
  color: #fff;
  background: var(--ink);
  box-shadow: 0 5px 14px rgba(41, 21, 68, 0.18);
}
.brand-mark svg { width: 25px; height: 25px; }
.brand-text { min-width: 0; }
.brand-name { display: block; overflow: hidden; color: var(--ink); font-size: 14px; font-weight: 900; letter-spacing: .065em; text-overflow: ellipsis; white-space: nowrap; }
.brand-tagline { display: block; margin-top: 2px; color: var(--ink-faint); font-size: 11px; font-weight: 650; letter-spacing: .015em; }

.top-actions { display: flex; align-items: center; gap: 8px; }
.table-chip, .network-chip {
  display: inline-flex;
  min-height: 37px;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid rgba(112, 70, 217, 0.1);
  border-radius: 999px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, .76);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.table-chip .chip-dot, .network-chip .chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mint); }
.network-chip .chip-dot { background: var(--blue); }
.network-chip.offline .chip-dot { background: var(--yellow); }

.button, .icon-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 850;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.button:hover, .icon-button:hover { transform: translateY(-1px); }
.button:active, .icon-button:active { transform: scale(.97); }
.button-primary { color: #fff; background: var(--purple); box-shadow: 0 6px 15px rgba(112, 70, 217, .2); }
.button-primary:hover { background: var(--purple-dark); box-shadow: 0 8px 20px rgba(112, 70, 217, .27); }
.button-quiet { color: var(--ink-soft); background: #f1edf7; }
.button-quiet:hover { background: #e9e2f2; }
.button-soft { color: var(--purple-dark); background: var(--purple-wash); }
.button-soft:hover { background: #e6ddff; }
.icon-button { width: 42px; min-height: 42px; padding: 0; border-radius: 13px; color: var(--ink-soft); background: #f3eff8; font-size: 22px; line-height: 1; }
.button svg { width: 17px; height: 17px; }

.view-tabs {
  display: flex;
  width: fit-content;
  max-width: 100%;
  gap: 4px;
  margin: 24px auto 0;
  padding: 5px;
  border: 1px solid rgba(87, 53, 181, 0.07);
  border-radius: 17px;
  background: rgba(255, 255, 255, .76);
  box-shadow: 0 5px 20px rgba(54, 30, 82, 0.035);
}
.view-tab {
  display: inline-flex;
  min-width: 90px;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  color: var(--ink-faint);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 850;
  transition: color .16s ease, background .16s ease, box-shadow .16s ease;
  touch-action: manipulation;
}
.view-tab svg { width: 17px; height: 17px; }
.view-tab[aria-selected="true"] { color: var(--purple-dark); background: var(--purple-wash); box-shadow: inset 0 0 0 1px rgba(112, 70, 217, .06); }

.main-view { margin-top: clamp(22px, 4vh, 42px); animation: arrive .26s ease both; }
.page-heading, .section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}
.eyebrow { display: block; color: var(--purple); font-size: 10px; font-weight: 950; letter-spacing: .14em; }
.page-heading h1 { margin: 5px 0 0; font-size: clamp(25px, 4vw, 36px); font-weight: 950; letter-spacing: -.055em; line-height: 1.06; }
.page-heading p, .section-heading p { margin: 8px 0 0; color: var(--ink-soft); font-size: 14px; font-weight: 600; line-height: 1.4; }
.heading-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; }
.section-heading { align-items: center; margin-bottom: 14px; }
.section-heading h2 { margin: 0; font-size: 20px; font-weight: 950; letter-spacing: -.045em; }
.section-heading p { margin: 4px 0 0; font-size: 12px; }
.section-heading .button { min-height: 38px; padding: 0 12px; font-size: 12px; }

.player-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.player-grid[data-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.player-grid[data-count="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.player-card {
  --player: var(--purple);
  --player-surface: #9575cd;
  --player-active: #7e57c2;
  --player-ink: #1f1530;
  --player-active-ink: #fff;
  position: relative;
  min-width: 0;
  overflow: hidden;
  padding: clamp(15px, 2vw, 23px);
  border: 1px solid rgba(76, 48, 108, .075);
  border-radius: 24px;
  color: var(--player-ink);
  background: var(--player-surface);
  box-shadow: var(--shadow);
  transition: transform .17s ease, box-shadow .17s ease, border-color .17s ease;
}
.player-card::before { display: none; }
.player-card.player-1 { --player: #5e35b1; --player-surface: #9575cd; --player-active: #7e57c2; --player-ink: #1f1530; --player-active-ink: #fff; }
.player-card.player-2 { --player: #00796b; --player-surface: #4db6ac; --player-active: #26a69a; --player-ink: #042d28; --player-active-ink: #042d28; }
.player-card.player-3 { --player: #d81b60; --player-surface: #f06292; --player-active: #ec407a; --player-ink: #2d0a19; --player-active-ink: #2d0a19; }
.player-card.player-4 { --player: #f9a825; --player-surface: #ffd54f; --player-active: #ffca28; --player-ink: #3f3106; --player-active-ink: #3f3106; }
.player-card.is-out { border-color: rgba(217, 77, 107, .24); }
.player-card.is-out::before { display: none; }

.player-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 10px; }
.player-name { display: inline-flex; min-width: 0; align-items: center; gap: 9px; font-size: 13px; font-weight: 900; letter-spacing: .035em; text-transform: uppercase; }
.player-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-marker { width: 12px; height: 12px; flex: 0 0 auto; border: 3px solid var(--player-surface); border-radius: 50%; background: var(--player); box-shadow: 0 0 0 1px color-mix(in srgb, var(--player) 35%, transparent); }
.player-marker.swatch-1 { --player: #5e35b1; --player-surface: #9575cd; }
.player-marker.swatch-2 { --player: #00796b; --player-surface: #4db6ac; }
.player-marker.swatch-3 { --player: #d81b60; --player-surface: #f06292; }
.player-marker.swatch-4 { --player: #f9a825; --player-surface: #ffd54f; }
.player-status { min-height: 23px; padding: 4px 9px; border-radius: 999px; color: var(--ink-faint); background: #f5f2f8; font-size: 9px; font-weight: 900; letter-spacing: .06em; white-space: nowrap; }
.player-status.out { color: #a73852; background: #ffe4eb; }

.life-main { display: grid; grid-template-columns: 48px minmax(70px, 1fr) 48px; align-items: center; gap: 5px; }
.life-number { display: block; font-size: clamp(45px, 7vw, 67px); font-weight: 950; letter-spacing: -.085em; line-height: .95; font-variant-numeric: tabular-nums; text-align: center; }
.life-caption { display: block; margin-top: 7px; color: var(--ink-faint); font-size: 9px; font-weight: 900; letter-spacing: .15em; text-align: center; }
.life-step {
  display: grid;
  width: 46px;
  height: 50px;
  place-items: center;
  border: 0;
  border-radius: 16px;
  color: var(--player);
  background: var(--player-surface);
  cursor: pointer;
  font-size: 27px;
  font-weight: 750;
  line-height: 1;
  touch-action: manipulation;
  transition: transform .12s ease, filter .12s ease;
}
.life-step:hover { filter: saturate(1.2); transform: translateY(-1px); }
.life-step:active { transform: scale(.93); }
.quick-adjust { display: flex; justify-content: center; gap: 7px; margin: 12px 0 16px; }
.quick-adjust button {
  min-width: 54px;
  min-height: 32px;
  border: 1px solid #eee8f4;
  border-radius: 10px;
  color: var(--ink-soft);
  background: #fbf9fd;
  cursor: pointer;
  font-size: 11px;
  font-weight: 850;
  touch-action: manipulation;
}
.quick-adjust button:hover { border-color: rgba(112, 70, 217, .22); background: var(--purple-wash); }

.counter-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.counter-box {
  display: grid;
  min-width: 0;
  grid-template-columns: 32px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 3px;
  padding: 7px 6px;
  border: 1px solid #f0ebf5;
  border-radius: 14px;
  background: #fcfbfd;
}
.counter-box.poison { background: #fff8fb; }
.counter-box.energy { background: #f5fcfa; }
.counter-box-button {
  display: grid;
  width: 32px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 10px;
  color: var(--ink-soft);
  background: #f1edf6;
  cursor: pointer;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  touch-action: manipulation;
}
.counter-box-button:hover { color: var(--purple-dark); background: #eae3f6; }
.counter-box.energy .counter-box-button { color: #327e72; background: #e3f5f0; }
.counter-box.poison .counter-box-button { color: #b54e6d; background: #ffeaf0; }
.counter-value { min-width: 0; text-align: center; }
.counter-label { display: block; overflow: hidden; color: var(--ink-faint); font-size: 9px; font-weight: 850; letter-spacing: .08em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.counter-number { display: block; margin-top: 1px; font-size: 21px; font-weight: 950; line-height: 1.05; font-variant-numeric: tabular-nums; }
.counter-number small { font-size: .55em; font-weight: 800; }
.counter-threshold { color: #bb4968; }
.counter-caption { margin: 6px 2px 0; color: var(--ink-faint); font-size: 10px; font-weight: 650; text-align: center; }

.commander-details { margin-top: 12px; border-top: 1px solid #f0ebf5; }
.commander-details summary { display: flex; min-height: 42px; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; list-style: none; color: var(--ink-soft); font-size: 11px; font-weight: 850; }
.commander-details summary::-webkit-details-marker { display: none; }
.commander-summary { display: inline-flex; align-items: center; gap: 7px; }
.commander-summary svg { width: 15px; height: 15px; color: var(--purple); }
.commander-max { padding: 4px 8px; border-radius: 999px; color: var(--purple-dark); background: var(--purple-wash); font-size: 10px; font-weight: 900; }
.commander-rows { display: grid; gap: 7px; padding: 1px 0 3px; }
.commander-row { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 9px; padding: 6px 7px; border-radius: 12px; background: #faf8fc; }
.commander-from { display: inline-flex; min-width: 0; align-items: center; gap: 7px; color: var(--ink-soft); font-size: 11px; font-weight: 800; }
.commander-from .player-marker { width: 9px; height: 9px; border-width: 2px; }
.commander-from span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.commander-controls { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 6px; }
.commander-controls .counter-box-button { width: 28px; height: 29px; border-radius: 9px; font-size: 18px; }
.commander-value { min-width: 24px; font-size: 14px; font-weight: 950; font-variant-numeric: tabular-nums; text-align: center; }

.custom-counters { display: grid; gap: 7px; margin-top: 10px; }
.custom-counter { display: grid; grid-template-columns: minmax(0, 1fr) 30px auto 30px 30px; align-items: center; gap: 4px; min-height: 42px; padding: 4px 6px 4px 10px; border-radius: 12px; background: #f8f5fb; }
.custom-counter-name { overflow: hidden; font-size: 11px; font-weight: 850; text-overflow: ellipsis; white-space: nowrap; }
.custom-counter .counter-box-button { width: 28px; height: 29px; font-size: 17px; }
.custom-counter .counter-number { min-width: 23px; margin: 0; font-size: 14px; text-align: center; }
.remove-counter { width: 27px; height: 27px; border: 0; border-radius: 8px; color: #9b8ea7; background: transparent; cursor: pointer; font-size: 17px; line-height: 1; }
.remove-counter:hover { color: #a73852; background: #ffe9ef; }
.add-counter-button { display: inline-flex; min-height: 34px; align-items: center; gap: 6px; justify-self: start; margin-top: 9px; padding: 0 9px; border: 1px dashed #ded4ec; border-radius: 10px; color: var(--purple-dark); background: transparent; cursor: pointer; font-size: 10px; font-weight: 850; touch-action: manipulation; }
.add-counter-button:hover { border-color: var(--purple); background: var(--purple-wash); }

.clock-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.clock-card {
  --player: var(--purple);
  --player-surface: #9575cd;
  --player-active: #7e57c2;
  --player-ink: #1f1530;
  --player-active-ink: #fff;
  position: relative;
  display: flex;
  min-height: clamp(190px, 28vh, 290px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 22px 14px;
  border: 1px solid rgba(76, 48, 108, .07);
  border-radius: 28px;
  color: var(--player-ink);
  background: var(--player-surface);
  box-shadow: var(--shadow);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
  -webkit-tap-highlight-color: transparent;
}
.clock-card::before { display: none; }
.clock-card.player-1 { --player: #5e35b1; --player-surface: #9575cd; --player-active: #7e57c2; --player-ink: #1f1530; --player-active-ink: #fff; }
.clock-card.player-2 { --player: #00796b; --player-surface: #4db6ac; --player-active: #26a69a; --player-ink: #042d28; --player-active-ink: #042d28; }
.clock-card.player-3 { --player: #d81b60; --player-surface: #f06292; --player-active: #ec407a; --player-ink: #2d0a19; --player-active-ink: #2d0a19; }
.clock-card.player-4 { --player: #f9a825; --player-surface: #ffd54f; --player-active: #ffca28; --player-ink: #3f3106; --player-active-ink: #3f3106; }
.clock-card:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(54, 30, 82, .12); }
.clock-card:active { transform: scale(.99); }
.clock-card.is-active { border: 5px solid var(--player); color: var(--player-active-ink); background: var(--player-active); box-shadow: 0 16px 36px color-mix(in srgb, var(--player) 28%, transparent), inset 0 0 0 1px rgba(255, 255, 255, .25); }
.clock-card.is-active .clock-hint, .clock-card.is-active .clock-name, .clock-card.is-active .clock-time { color: var(--player-active-ink); }
.clock-card.is-active .clock-state { color: var(--player-ink); background: rgba(255, 255, 255, .82); }
.clock-card.is-active.is-low .clock-time { color: var(--player-active-ink); }
.clock-card.is-ended { color: var(--player-ink); background: var(--player-surface); cursor: default; }
.clock-card.is-out { cursor: not-allowed; }
.clock-card:disabled { cursor: not-allowed; }
.clock-topline { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.clock-name { color: var(--player-ink); font-size: 13px; font-weight: 900; letter-spacing: .05em; text-transform: uppercase; }
.clock-time { color: var(--player-ink); font-size: clamp(50px, 9vw, 86px); font-weight: 950; letter-spacing: -.085em; line-height: .96; font-variant-numeric: tabular-nums; }
.clock-hint { min-height: 18px; margin-top: 13px; color: var(--player-ink); font-size: 11px; font-weight: 750; }
.clock-state { position: absolute; top: 18px; right: 17px; padding: 5px 9px; border-radius: 999px; color: var(--ink-soft); background: #f4f0f8; font-size: 9px; font-weight: 950; letter-spacing: .08em; }
.clock-state.is-running { color: #18584f; background: #d8f5e9; }
.clock-state.is-finished { color: #aa3f5c; background: #ffe4ec; }
.clock-rule { display: flex; align-items: center; gap: 8px; margin: 16px 0 0; color: var(--ink-faint); font-size: 11px; font-weight: 700; }
.clock-rule::before { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); content: ""; }

.combined-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.combined-panel {
  min-width: 0;
  min-height: 380px;
  padding: 18px;
  border: 1px solid rgba(76, 48, 108, .075);
  border-radius: 25px;
  background: rgba(255, 255, 255, .63);
  box-shadow: 0 8px 22px rgba(54, 30, 82, .045);
}
.combined-panel .section-heading { margin-bottom: 12px; }
.combined-panel .section-heading h2 { font-size: 18px; }
.combined-panel .clock-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.combined-panel .clock-card { min-height: 170px; padding: 24px 8px 12px; border-radius: 20px; box-shadow: 0 6px 15px rgba(54, 30, 82, .065); }
.combined-panel .clock-card::before { height: 4px; }
.combined-panel .clock-topline { gap: 6px; margin-bottom: 11px; }
.combined-panel .clock-name { font-size: 10px; }
.combined-panel .clock-time { font-size: clamp(34px, 4vw, 54px); }
.combined-panel .clock-hint { margin-top: 9px; font-size: 9px; }
.combined-panel .clock-state { top: 11px; right: 10px; padding: 4px 7px; font-size: 8px; }
.combined-panel .player-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.combined-panel .player-grid[data-count="3"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.combined-panel .player-grid[data-count="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.combined-panel .player-card { padding: 14px 10px 12px; border-radius: 18px; }
.combined-panel .player-card::before { height: 4px; }
.combined-panel .player-card-head { gap: 4px; margin-bottom: 7px; }
.combined-panel .player-name { gap: 6px; font-size: 10px; }
.combined-panel .player-marker { width: 10px; height: 10px; border-width: 2px; }
.combined-panel .player-status { min-height: 18px; padding: 3px 6px; font-size: 7px; }
.combined-panel .life-main { grid-template-columns: 34px minmax(42px, 1fr) 34px; gap: 3px; }
.combined-panel .life-number { font-size: clamp(31px, 4vw, 43px); }
.combined-panel .life-caption { margin-top: 3px; font-size: 7px; }
.combined-panel .life-step { width: 33px; height: 37px; border-radius: 12px; font-size: 21px; }
.combined-panel .quick-adjust { gap: 4px; margin: 7px 0 9px; }
.combined-panel .quick-adjust button { min-width: 39px; min-height: 27px; border-radius: 8px; font-size: 9px; }
.combined-panel .counter-rows { gap: 4px; }
.combined-panel .counter-box { grid-template-columns: 24px minmax(0, 1fr) 24px; gap: 1px; padding: 4px 2px; border-radius: 10px; }
.combined-panel .counter-box-button { width: 24px; height: 28px; border-radius: 8px; font-size: 16px; }
.combined-panel .counter-label { font-size: 7px; }
.combined-panel .counter-number { font-size: 16px; }
.combined-panel .counter-caption { margin-top: 4px; font-size: 8px; }
.combined-panel .commander-details { margin-top: 7px; }
.combined-panel .commander-details summary { min-height: 34px; font-size: 9px; }
.combined-panel .commander-summary { gap: 4px; }
.combined-panel .commander-summary svg { width: 12px; height: 12px; }
.combined-panel .commander-max { padding: 3px 5px; font-size: 8px; }
.combined-panel .commander-row { padding: 4px; }
.combined-panel .commander-from { gap: 4px; font-size: 8px; }
.combined-panel .commander-controls { gap: 3px; }
.combined-panel .commander-controls .counter-box-button { width: 22px; height: 24px; font-size: 15px; }
.combined-panel .commander-value { min-width: 18px; font-size: 11px; }
.combined-panel .custom-counters { gap: 5px; margin-top: 6px; }
.combined-panel .custom-counter { grid-template-columns: minmax(0, 1fr) 22px auto 22px 24px; gap: 2px; min-height: 35px; padding: 3px 4px 3px 7px; }
.combined-panel .custom-counter-name { font-size: 9px; }
.combined-panel .custom-counter .counter-box-button { width: 21px; height: 23px; font-size: 14px; }
.combined-panel .custom-counter .counter-number { font-size: 11px; }
.combined-panel .remove-counter { width: 22px; height: 22px; font-size: 15px; }
.combined-panel .add-counter-button { min-height: 29px; margin-top: 6px; font-size: 9px; }

.footer-note { display: flex; align-items: center; justify-content: center; gap: 7px; margin: 20px 0 0; color: var(--ink-faint); font-size: 10px; font-weight: 700; text-align: center; }
.footer-note svg { width: 14px; height: 14px; color: var(--mint); }

.dialog-card {
  width: min(440px, calc(100vw - 28px));
  max-height: min(90vh, 760px);
  overflow: auto;
  padding: 23px;
  border: 1px solid rgba(76, 48, 108, .09);
  border-radius: 26px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(32, 14, 53, .25);
}
.dialog-card::backdrop { background: rgba(35, 20, 53, .43); backdrop-filter: blur(4px); }
.dialog-small { width: min(390px, calc(100vw - 28px)); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.dialog-heading h2 { margin: 5px 0 0; font-size: 24px; font-weight: 950; letter-spacing: -.05em; }
.dialog-copy { margin: 12px 0 18px; color: var(--ink-soft); font-size: 13px; font-weight: 600; line-height: 1.5; }
.setting-field { display: grid; min-width: 0; gap: 8px; margin: 18px 0 0; padding: 0; border: 0; color: var(--ink-soft); font-size: 12px; font-weight: 850; }
.setting-field legend { margin-bottom: 8px; color: var(--ink-soft); font-size: 12px; font-weight: 850; }
.choice-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choice-option { position: relative; cursor: pointer; }
.choice-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.choice-option span { display: grid; min-height: 46px; place-items: center; border: 1px solid var(--line); border-radius: 14px; color: var(--ink-soft); background: #fbf9fd; font-size: 16px; font-weight: 900; }
.choice-option input:checked + span { border-color: #aa94ed; color: var(--purple-dark); background: var(--purple-wash); box-shadow: inset 0 0 0 1px rgba(112, 70, 217, .1); }
.choice-option input:focus-visible + span { outline: 3px solid rgba(112, 70, 217, .4); outline-offset: 2px; }
.setting-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input-with-unit { display: flex; min-height: 46px; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--line); border-radius: 14px; background: #fbf9fd; }
.input-with-unit input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 18px; font-weight: 900; }
.input-with-unit input:focus-visible { outline: none; }
.input-with-unit span { color: var(--ink-faint); font-size: 10px; font-weight: 800; }
.text-input { min-height: 46px; padding: 0 13px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: #fbf9fd; font-size: 14px; font-weight: 700; }
.dialog-note { margin-top: 18px; padding: 12px 13px; border-radius: 13px; color: #6d5e80; background: #f7f4fb; font-size: 11px; font-weight: 650; line-height: 1.5; }
.dialog-actions { display: flex; justify-content: end; gap: 8px; margin-top: 22px; }
.install-instructions { margin-top: 18px; color: var(--ink-soft); font-size: 13px; font-weight: 600; line-height: 1.6; }
.install-instructions ol { display: grid; gap: 8px; margin: 10px 0 0; padding-left: 21px; }
.install-instructions strong { color: var(--ink); font-weight: 900; }

.toast { position: fixed; z-index: 10; right: max(16px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); max-width: min(390px, calc(100vw - 32px)); padding: 12px 16px; border: 1px solid rgba(255,255,255,.2); border-radius: 15px; color: #fff; background: var(--ink); box-shadow: 0 12px 30px rgba(41, 21, 68, .24); font-size: 12px; font-weight: 800; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .2s ease, transform .2s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

@keyframes arrive { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }

@media (min-width: 1180px) {
  .player-grid[data-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .clock-grid[data-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .clock-grid[data-count="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .app-shell { padding-right: max(14px, env(safe-area-inset-right)); padding-left: max(14px, env(safe-area-inset-left)); }
  .combined-layout { grid-template-columns: 1fr; gap: 12px; }
  .combined-panel { min-height: auto; }
  .combined-panel .clock-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .app-shell { padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .brand-mark { width: 38px; height: 38px; border-radius: 13px; }
  .brand-name { font-size: 12px; }
  .brand-tagline { font-size: 10px; }
  .top-actions { gap: 6px; }
  .top-actions .network-chip { width: 37px; min-width: 37px; justify-content: center; padding: 0; overflow: hidden; font-size: 0; }
  .top-actions .network-chip .chip-dot { width: 9px; height: 9px; }
  .top-actions .table-chip { display: none; }
  .top-actions .button { min-height: 39px; padding: 0 11px; font-size: 11px; }
  .top-actions .button svg { width: 15px; height: 15px; }
  .view-tabs { width: 100%; justify-content: space-between; margin-top: 17px; }
  .view-tab { min-width: 0; flex: 1 1 0; gap: 6px; padding: 0 8px; font-size: 11px; }
  .view-tab svg { width: 15px; height: 15px; }
  .main-view { margin-top: 22px; }
  .page-heading { align-items: center; margin-bottom: 15px; }
  .page-heading h1 { font-size: 27px; }
  .page-heading p { max-width: 34ch; font-size: 12px; }
  .heading-actions .button { min-height: 36px; padding: 0 10px; font-size: 10px; }
  .player-grid, .player-grid[data-count="3"], .player-grid[data-count="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .player-card { padding: 14px 10px 12px; border-radius: 19px; }
  .player-card::before { height: 4px; }
  .player-card-head { align-items: flex-start; gap: 4px; margin-bottom: 8px; }
  .player-name { gap: 6px; font-size: 10px; }
  .player-marker { width: 10px; height: 10px; border-width: 2px; }
  .player-status { min-height: 19px; padding: 3px 6px; font-size: 7px; }
  .life-main { grid-template-columns: 34px minmax(42px, 1fr) 34px; gap: 3px; }
  .life-number { font-size: clamp(34px, 10vw, 47px); }
  .life-caption { margin-top: 4px; font-size: 7px; }
  .life-step { width: 33px; height: 38px; border-radius: 12px; font-size: 21px; }
  .quick-adjust { gap: 4px; margin: 8px 0 10px; }
  .quick-adjust button { min-width: 39px; min-height: 27px; border-radius: 8px; font-size: 9px; }
  .counter-rows { gap: 4px; }
  .counter-box { grid-template-columns: 24px minmax(0, 1fr) 24px; gap: 1px; padding: 4px 2px; border-radius: 10px; }
  .counter-box-button { width: 24px; height: 28px; border-radius: 8px; font-size: 16px; }
  .counter-label { font-size: 7px; }
  .counter-number { font-size: 16px; }
  .counter-caption { margin-top: 4px; font-size: 8px; }
  .commander-details { margin-top: 7px; }
  .commander-details summary { min-height: 35px; font-size: 9px; }
  .commander-summary { gap: 4px; }
  .commander-summary svg { width: 12px; height: 12px; }
  .commander-max { padding: 3px 5px; font-size: 8px; }
  .commander-row { padding: 4px; }
  .commander-from { gap: 4px; font-size: 8px; }
  .commander-controls { gap: 3px; }
  .commander-controls .counter-box-button { width: 22px; height: 24px; font-size: 15px; }
  .commander-value { min-width: 18px; font-size: 11px; }
  .custom-counters { gap: 5px; margin-top: 6px; }
  .custom-counter { grid-template-columns: minmax(0, 1fr) 22px auto 22px 24px; gap: 2px; min-height: 35px; padding: 3px 4px 3px 7px; }
  .custom-counter-name { font-size: 9px; }
  .custom-counter .counter-box-button { width: 21px; height: 23px; font-size: 14px; }
  .custom-counter .counter-number { font-size: 11px; }
  .remove-counter { width: 22px; height: 22px; font-size: 15px; }
  .add-counter-button { min-height: 29px; margin-top: 6px; font-size: 9px; }
  .clock-grid, .clock-grid[data-count="3"], .clock-grid[data-count="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .clock-card { min-height: clamp(168px, 24vh, 218px); padding: 23px 8px 14px; border-radius: 21px; }
  .clock-card::before { height: 4px; }
  .clock-topline { gap: 6px; margin-bottom: 12px; }
  .clock-name { font-size: 10px; }
  .clock-time { font-size: clamp(38px, 11vw, 54px); }
  .clock-hint { margin-top: 9px; font-size: 9px; }
  .clock-state { top: 11px; right: 10px; padding: 4px 6px; font-size: 7px; }
  .combined-panel { padding: 13px 10px; border-radius: 20px; }
  .combined-panel .section-heading { align-items: center; }
  .combined-panel .section-heading h2 { font-size: 16px; }
  .combined-panel .section-heading p { font-size: 10px; }
  .combined-panel .section-heading .button { min-height: 34px; padding: 0 9px; font-size: 9px; }
  .combined-panel .clock-card { min-height: 143px; }
  .footer-note { margin-top: 15px; font-size: 9px; }
  .dialog-card { padding: 18px; border-radius: 22px; }
  .dialog-heading h2 { font-size: 21px; }
  .setting-pair { gap: 8px; }
  .dialog-actions .button { flex: 1 1 auto; padding: 0 10px; font-size: 11px; }
}

@media (max-width: 430px) {
  .top-actions { gap: 5px; }
  .top-actions .network-chip { display: none; }
  .top-actions [data-action="install"] { width: 39px; padding: 0; }
  .top-actions [data-action="install"] span { display: none; }
  .brand-name { font-size: 11px; letter-spacing: .035em; }
}

@media (max-width: 365px) {
  .brand-tagline { display: none; }
  .top-actions .button { padding: 0 9px; }
  .view-tab { gap: 4px; padding: 0 5px; font-size: 10px; }
  .player-card { padding-right: 8px; padding-left: 8px; }
  .counter-box { grid-template-columns: 21px minmax(0, 1fr) 21px; }
  .counter-box-button { width: 21px; }
}

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

/* Edge-to-edge game table. */
html, body {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: #211237;
}

.app-shell {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  max-width: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 10% 0%, rgba(142, 105, 246, .20), transparent 38%),
    radial-gradient(ellipse at 100% 100%, rgba(75, 182, 165, .13), transparent 40%),
    #f7f4fb;
}

.main-view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  animation: none;
}

.clock-view, .life-view {
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}

.clock-grid, .player-grid {
  width: 100%;
  height: 100%;
  min-height: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: clamp(48px, 7.5vmin, 88px);
  align-content: stretch;
}

.clock-grid:not(.compact-grid)[data-count="2"],
.player-grid:not(.compact-grid)[data-count="2"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
}

.clock-grid:not(.compact-grid)[data-count="3"],
.clock-grid:not(.compact-grid)[data-count="4"],
.player-grid:not(.compact-grid)[data-count="3"],
.player-grid:not(.compact-grid)[data-count="4"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.clock-grid:not(.compact-grid)[data-count="3"] > :nth-child(3),
.player-grid:not(.compact-grid)[data-count="3"] > :nth-child(3),
.combined-panel .clock-grid[data-count="3"] > :nth-child(3),
.combined-panel .player-grid[data-count="3"] > :nth-child(3) {
  grid-column: 1 / -1;
}

.clock-grid:not(.compact-grid)[data-count="2"],
.player-grid:not(.compact-grid)[data-count="2"] {
  grid-template-rows: 1fr;
}

.clock-card {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: clamp(12px, 3vmin, 28px);
  border-radius: clamp(16px, 3vmin, 30px);
}

.clock-card::before { height: 5px; }
.clock-topline { gap: 9px; margin-bottom: clamp(10px, 2.8vmin, 26px); }
.clock-name { font-size: clamp(10px, 2vmin, 18px); }
.clock-time { font-size: clamp(36px, 9vmin, 116px); }
.clock-hint { margin-top: clamp(8px, 2.2vmin, 20px); font-size: clamp(9px, 1.6vmin, 14px); }
.clock-state { top: clamp(10px, 2vmin, 22px); right: clamp(10px, 2vmin, 22px); padding: 5px 9px; font-size: clamp(8px, 1.2vmin, 11px); }
.clock-card .player-marker { width: clamp(9px, 1.7vmin, 15px); height: clamp(9px, 1.7vmin, 15px); }

.player-card {
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 0;
  flex-direction: column;
  justify-content: center;
  overflow: auto;
  padding: clamp(10px, 2.2vmin, 24px);
  border-radius: clamp(16px, 3vmin, 28px);
  scrollbar-width: none;
}

.player-card::-webkit-scrollbar { display: none; }
.player-card::before { height: 5px; }
.player-card-head { gap: 6px; margin: 0 0 clamp(5px, 1vmin, 12px); }
.player-name { gap: 8px; font-size: clamp(9px, 1.6vmin, 14px); }
.player-status { min-height: 20px; padding: 4px 8px; font-size: clamp(7px, 1vmin, 10px); }
.life-main { grid-template-columns: clamp(32px, 6vmin, 58px) minmax(48px, 1fr) clamp(32px, 6vmin, 58px); gap: 5px; }
.life-number { font-size: clamp(34px, 9vmin, 94px); }
.life-caption { margin-top: 4px; font-size: clamp(7px, 1.2vmin, 11px); }
.life-step { width: clamp(32px, 6vmin, 58px); height: clamp(38px, 7vmin, 64px); border-radius: clamp(10px, 2vmin, 18px); font-size: clamp(21px, 4vmin, 36px); }
.quick-adjust { gap: 7px; margin: clamp(6px, 1.4vmin, 14px) 0 clamp(8px, 1.8vmin, 18px); }
.quick-adjust button { min-width: clamp(42px, 7vmin, 60px); min-height: clamp(27px, 4.5vmin, 38px); font-size: clamp(9px, 1.4vmin, 12px); }
.counter-rows { gap: clamp(4px, 1vmin, 10px); }
.counter-box { grid-template-columns: clamp(24px, 4.5vmin, 40px) minmax(0, 1fr) clamp(24px, 4.5vmin, 40px); gap: 2px; padding: clamp(4px, .9vmin, 9px); border-radius: clamp(9px, 1.8vmin, 15px); }
.counter-box-button { width: clamp(24px, 4.5vmin, 40px); height: clamp(27px, 5vmin, 43px); font-size: clamp(16px, 3vmin, 25px); }
.counter-label { font-size: clamp(7px, 1.1vmin, 10px); }
.counter-number { font-size: clamp(15px, 3.3vmin, 28px); }
.counter-caption { margin-top: 5px; font-size: clamp(8px, 1.2vmin, 11px); }
.commander-details { margin-top: clamp(6px, 1.3vmin, 14px); }
.commander-details summary { min-height: clamp(32px, 5.5vmin, 48px); font-size: clamp(9px, 1.5vmin, 13px); }
.commander-summary { gap: 6px; }
.commander-summary svg { width: clamp(13px, 2vmin, 18px); height: clamp(13px, 2vmin, 18px); }
.commander-max { padding: 4px 8px; font-size: clamp(8px, 1.2vmin, 11px); }
.commander-rows { gap: 5px; padding-bottom: 4px; }
.commander-row { padding: 5px 7px; }
.commander-from { font-size: clamp(8px, 1.3vmin, 12px); }
.commander-controls .counter-box-button { width: clamp(23px, 4vmin, 36px); height: clamp(24px, 4.2vmin, 37px); }
.commander-value { font-size: clamp(11px, 2vmin, 17px); }
.custom-counters { gap: 5px; margin-top: 7px; }
.custom-counter { min-height: clamp(34px, 5.5vmin, 48px); }
.custom-counter-name { font-size: clamp(9px, 1.5vmin, 13px); }
.custom-counter .counter-box-button { width: clamp(23px, 4vmin, 36px); height: clamp(24px, 4.2vmin, 37px); }
.custom-counter .counter-number { font-size: clamp(11px, 2vmin, 17px); }
.add-counter-button { min-height: clamp(30px, 5vmin, 42px); margin-top: clamp(5px, 1vmin, 10px); font-size: clamp(9px, 1.4vmin, 12px); }

.combined-layout {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  align-items: stretch;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0;
  padding: max(7px, env(safe-area-inset-top)) max(7px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(7px, env(safe-area-inset-left));
}

.combined-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  padding: clamp(8px, 1.4vmin, 15px);
  border-radius: clamp(14px, 2.6vmin, 24px);
}

.combined-panel .section-heading { flex: 0 0 auto; gap: 8px; margin: 0 0 clamp(4px, .9vmin, 9px); }
.combined-panel .section-heading h2 { font-size: clamp(13px, 1.9vmin, 18px); }
.combined-panel .section-heading p { margin-top: 2px; font-size: clamp(8px, 1.1vmin, 11px); }
.combined-panel .clock-grid, .combined-panel .player-grid { flex: 1 1 auto; width: 100%; min-height: 0; gap: clamp(5px, 1vmin, 10px); }
.combined-panel .clock-grid[data-count="2"], .combined-panel .player-grid[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr); }
.combined-panel .clock-grid[data-count="3"], .combined-panel .clock-grid[data-count="4"],
.combined-panel .player-grid[data-count="3"], .combined-panel .player-grid[data-count="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); }
.combined-panel .clock-card { min-height: 0; padding: 20px 7px 8px; border-radius: clamp(11px, 2vmin, 18px); }
.combined-panel .clock-card::before { height: 4px; }
.combined-panel .clock-topline { gap: 5px; margin-bottom: 5px; }
.combined-panel .clock-name { font-size: clamp(8px, 1.1vmin, 11px); }
.combined-panel .clock-time { font-size: clamp(26px, 5vmin, 52px); }
.combined-panel .clock-hint { margin-top: 4px; font-size: clamp(7px, .9vmin, 9px); }
.combined-panel .clock-state { top: 6px; right: 6px; padding: 3px 5px; font-size: 7px; }
.combined-panel .clock-card .player-marker { width: 8px; height: 8px; }
.combined-panel .player-card { justify-content: center; padding: clamp(6px, 1vmin, 10px); border-radius: clamp(10px, 1.8vmin, 16px); }
.combined-panel .player-card::before { height: 3px; }
.combined-panel .player-card-head { gap: 3px; margin: 0 0 3px; }
.combined-panel .player-name { gap: 4px; font-size: clamp(7px, .95vmin, 9px); }
.combined-panel .player-marker { width: 8px; height: 8px; border-width: 2px; }
.combined-panel .player-status { min-height: 15px; padding: 2px 4px; font-size: 6px; }
.combined-panel .life-main { grid-template-columns: 22px minmax(24px, 1fr) 22px; gap: 1px; }
.combined-panel .life-number { font-size: clamp(23px, 4vmin, 40px); }
.combined-panel .life-caption { margin-top: 1px; font-size: 6px; }
.combined-panel .life-step { width: 22px; height: 25px; border-radius: 7px; font-size: 15px; }
.combined-panel .quick-adjust, .combined-panel .add-counter-button { display: none; }
.combined-panel .counter-rows { gap: 3px; margin-top: 3px; }
.combined-panel .counter-box { grid-template-columns: 19px minmax(0, 1fr) 19px; gap: 0; padding: 2px 1px; border-radius: 7px; }
.combined-panel .counter-box-button { width: 19px; height: 22px; border-radius: 6px; font-size: 14px; }
.combined-panel .counter-label { font-size: 6px; letter-spacing: .02em; }
.combined-panel .counter-number { font-size: clamp(12px, 2vmin, 17px); }
.combined-panel .counter-number small { font-size: .5em; }
.combined-panel .counter-caption { margin-top: 2px; font-size: 6px; }
.combined-panel .commander-details { margin-top: 2px; }
.combined-panel .commander-details summary { min-height: 22px; gap: 2px; font-size: clamp(7px, .9vmin, 9px); }
.combined-panel .commander-summary { gap: 2px; }
.combined-panel .commander-summary svg { width: 10px; height: 10px; }
.combined-panel .commander-max { padding: 2px 4px; font-size: 7px; }
.combined-panel .commander-rows { gap: 2px; padding-bottom: 1px; }
.combined-panel .commander-row { gap: 3px; padding: 2px 3px; }
.combined-panel .commander-from { gap: 3px; font-size: 7px; }
.combined-panel .commander-from .player-marker { width: 7px; height: 7px; }
.combined-panel .commander-controls { gap: 2px; }
.combined-panel .commander-controls .counter-box-button { width: 18px; height: 19px; font-size: 12px; }
.combined-panel .commander-value { min-width: 15px; font-size: 9px; }
.combined-panel .custom-counters { gap: 2px; margin-top: 2px; }
.combined-panel .custom-counter { grid-template-columns: minmax(0, 1fr) 18px auto 18px 18px; gap: 1px; min-height: 24px; padding: 1px 2px 1px 4px; }
.combined-panel .custom-counter-name { font-size: 7px; }
.combined-panel .custom-counter .counter-box-button { width: 17px; height: 18px; font-size: 11px; }
.combined-panel .custom-counter .counter-number { min-width: 13px; font-size: 9px; }
.combined-panel .remove-counter { width: 17px; height: 17px; font-size: 12px; }
.life-view .counter-box { grid-template-columns: clamp(20px, 4vmin, 36px) minmax(0, 1fr) clamp(20px, 4vmin, 36px); }
.life-view .counter-box-button { width: clamp(20px, 4vmin, 36px); }
.life-view .counter-label { font-size: clamp(5px, .9vmin, 9px); letter-spacing: .015em; }

.center-menu-button {
  position: fixed;
  z-index: 20;
  top: 50%;
  left: 50%;
  display: flex;
  width: clamp(60px, 8vmin, 78px);
  height: clamp(60px, 8vmin, 78px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0;
  border: 4px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: var(--purple);
  box-shadow: 0 6px 20px rgba(41, 21, 68, .25), 0 0 0 1px rgba(41, 21, 68, .07);
  cursor: pointer;
  transform: translate(-50%, -50%);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.center-menu-button:hover { background: var(--purple-dark); transform: translate(-50%, -50%) scale(1.04); }
.center-menu-button:active, .center-menu-button.is-pressing { background: var(--ink); box-shadow: 0 0 0 5px rgba(112, 70, 217, .2), 0 6px 20px rgba(41, 21, 68, .3); transform: translate(-50%, -50%) scale(.92); }
.center-menu-icon { display: block; width: clamp(21px, 3vmin, 28px); height: clamp(21px, 3vmin, 28px); }
.center-menu-icon svg { display: block; width: 100%; height: 100%; }
.center-menu-label { font-size: clamp(7px, .9vmin, 9px); font-weight: 950; letter-spacing: .08em; line-height: 1; }

.menu-view-field { margin-top: 12px; }
.menu-view-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.menu-view-button { min-height: 43px; padding: 0 7px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink-soft); background: #fbf9fd; cursor: pointer; font-size: 11px; font-weight: 850; }
.menu-view-button.is-selected { border-color: #aa94ed; color: var(--purple-dark); background: var(--purple-wash); box-shadow: inset 0 0 0 1px rgba(112, 70, 217, .1); }
.menu-quick-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 15px; }
.menu-quick-actions .button { min-height: 36px; padding: 0 10px; font-size: 10px; }

@media (orientation: portrait) {
  .clock-grid:not(.compact-grid)[data-count="2"],
  .player-grid:not(.compact-grid)[data-count="2"] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }
  .clock-grid:not(.compact-grid)[data-count="2"] .clock-time { font-size: clamp(64px, 15vw, 128px); }
}

@media (orientation: landscape) {
  .combined-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
}

@media (max-height: 500px) {
  .combined-layout { gap: 48px; }
  .combined-panel { padding: 5px 8px; }
  .combined-panel .section-heading { margin-bottom: 2px; }
  .combined-panel .section-heading h2 { font-size: 12px; }
  .combined-panel .section-heading p { font-size: 7px; }
  .combined-panel .clock-card { padding-top: 16px; }
  .combined-panel .clock-time { font-size: clamp(22px, 5vmin, 36px); }
  .combined-panel .player-card { padding: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .center-menu-button { transition: none; }
}

/* Life-first cards with gesture-only secondary counters. */
.life-player-card {
  position: relative;
  display: block;
  overflow: hidden;
  padding: 0;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.life-player-head {
  position: absolute;
  z-index: 4;
  top: clamp(13px, 2.7vmin, 27px);
  right: clamp(13px, 2.7vmin, 27px);
  left: clamp(13px, 2.7vmin, 27px);
  align-items: center;
  margin: 0;
  pointer-events: none;
}

.life-player-head .player-name { font-size: clamp(10px, 1.8vmin, 16px); }
.life-player-head .player-status { pointer-events: none; }

.life-mode-close {
  min-height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  color: var(--purple-dark);
  background: #eee8fb;
  cursor: pointer;
  font-size: clamp(8px, 1.2vmin, 11px);
  font-weight: 950;
  letter-spacing: .04em;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.life-main {
  position: absolute;
  inset: 0;
  display: block;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.life-readout {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.life-player-card .life-number {
  color: var(--player-ink);
  font-size: clamp(70px, 22vmin, 180px);
  font-weight: 950;
  letter-spacing: -.075em;
  line-height: .86;
  font-variant-numeric: tabular-nums;
}

.life-player-card.is-out .life-number { color: #aaa2b5; }

.life-player-card.is-life-hit { animation: life-card-hit .56s cubic-bezier(.2,.8,.25,1); }
.life-player-card.is-life-heal { animation: life-card-heal .72s ease-out; }
.life-player-card.is-life-hit .life-number { animation: life-number-hit .56s ease-out; }
.life-player-card.is-life-heal .life-number { animation: life-number-light .72s ease-out; }

@keyframes life-card-hit {
  0%, 100% { transform: translateX(0); box-shadow: var(--shadow); }
  18% { transform: translateX(-5px) scale(.996); background-color: #ffdce4; box-shadow: 0 0 0 4px rgba(223, 55, 87, .24), 0 0 28px rgba(223, 55, 87, .24); }
  38% { transform: translateX(4px) scale(.996); }
  57% { transform: translateX(-2px); }
  75% { transform: translateX(1px); }
}

@keyframes life-card-heal {
  0%, 100% { transform: scale(1); box-shadow: var(--shadow); }
  38% { transform: scale(1.012); box-shadow: 0 0 0 4px rgba(44, 190, 148, .26), 0 0 32px rgba(44, 190, 148, .3); }
  68% { transform: scale(1.004); box-shadow: 0 0 0 2px rgba(44, 190, 148, .16), 0 0 18px rgba(44, 190, 148, .17); }
}

@keyframes life-number-hit {
  20% { color: #bd3154; transform: scale(1.08); }
  58% { transform: scale(.97); }
}

@keyframes life-number-light {
  28% { color: #087c61; text-shadow: 0 0 10px rgba(77, 236, 181, .8), 0 0 34px rgba(77, 236, 181, .64); transform: scale(1.08); }
  68% { text-shadow: 0 0 16px rgba(77, 236, 181, .36); transform: scale(1.02); }
}

.player-elimination-overlay {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 1.1vmin, 10px);
  padding: 16px;
  border-radius: inherit;
  color: #fff;
  background: rgba(9, 8, 14, .84);
  text-align: center;
  pointer-events: auto;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: player-eliminated-in .3s ease-out both;
}

.player-elimination-skull {
  display: grid;
  width: clamp(36px, 8vmin, 78px);
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .17);
  border-radius: 50%;
  color: #fff3ff;
  background: radial-gradient(circle, rgba(181, 143, 255, .28), rgba(181, 143, 255, 0) 72%);
  animation: friendly-skull-pop .55s cubic-bezier(.2,1.4,.45,1) both;
}

.player-elimination-skull svg { display: block; width: 100%; height: 100%; padding: 5px; }
.player-elimination-overlay strong { font-size: clamp(11px, 2.1vmin, 19px); font-weight: 950; letter-spacing: .12em; }
.player-elimination-reason { max-width: 24ch; color: rgba(255, 255, 255, .76); font-size: clamp(8px, 1.3vmin, 12px); font-weight: 800; line-height: 1.25; }

@keyframes player-eliminated-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes friendly-skull-pop {
  0% { transform: scale(.55) rotate(-9deg); }
  68% { transform: scale(1.08) rotate(3deg); }
  100% { transform: scale(1) rotate(0); }
}

.life-tap-zone {
  position: absolute;
  z-index: 1;
  top: 0;
  bottom: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

.life-tap-zone { width: 50%; }
.life-tap-zone.is-left { left: 0; }
.life-tap-zone.is-right { right: 0; }
.life-tap-zone.is-left:active { background: rgba(239, 85, 119, .08); }
.life-tap-zone.is-right:active { background: rgba(41, 169, 137, .09); }
.life-tap-zone:focus-visible { outline: 3px solid var(--purple); outline-offset: -5px; }

.is-commander-source {
  border-color: rgba(112, 70, 217, .48);
  box-shadow: inset 0 0 0 2px rgba(112, 70, 217, .13), 0 10px 26px rgba(41, 21, 68, .09);
  cursor: pointer;
}
.is-commander-target { border-color: rgba(112, 70, 217, .52); }
.commander-target-view {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2vmin, 18px);
  padding: 54px 12px 14px;
  color: var(--purple-dark);
  background: linear-gradient(145deg, rgba(244, 234, 254, .9), rgba(238, 232, 251, .64));
  text-align: center;
}
.commander-target-title { font-size: clamp(16px, 3.5vmin, 30px); font-weight: 950; letter-spacing: .045em; line-height: 1.15; }
.commander-target-help { max-width: 18ch; color: var(--ink-soft); font-size: clamp(10px, 1.6vmin, 14px); font-weight: 800; line-height: 1.35; }
.commander-source-view {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: flex;
  width: 100%;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2.4vmin, 22px);
  padding: 58px 14px 14px;
  border: 0;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.commander-source-value { position: relative; z-index: 2; font-size: clamp(70px, 22vmin, 180px); font-weight: 950; letter-spacing: -.075em; line-height: .86; font-variant-numeric: tabular-nums; pointer-events: none; }
.commander-adjust-zone {
  position: absolute;
  z-index: 1;
  top: 0;
  bottom: 0;
  width: 50%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.commander-adjust-zone.is-left { left: 0; }
.commander-adjust-zone.is-right { right: 0; }
.commander-adjust-zone.is-left:active { background: rgba(239, 85, 119, .08); }
.commander-adjust-zone.is-right:active { background: rgba(41, 169, 137, .09); }
.commander-adjust-zone:focus-visible { outline: 3px solid var(--purple); outline-offset: -5px; }

.counter-touch-surface {
  position: absolute;
  z-index: 2;
  inset: clamp(51px, 8vmin, 74px) clamp(10px, 1.8vmin, 18px) clamp(10px, 1.8vmin, 18px);
  display: grid;
  min-height: 0;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: clamp(8px, 1.8vmin, 17px);
  touch-action: none;
}

.counter-touch-panel {
  position: relative;
  display: flex;
  min-height: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(66, 45, 92, .08);
  border-radius: clamp(14px, 2.4vmin, 24px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .72);
}

.counter-touch-panel.poison { color: #7540b0; background: linear-gradient(135deg, #f4eafe, #e7d8f9); }
.counter-touch-panel.energy { color: #0b856a; background: linear-gradient(135deg, #e2f6ee, #d1efe4); }
.counter-touch-label { z-index: 2; font-size: clamp(10px, 1.7vmin, 16px); font-weight: 950; letter-spacing: .13em; }
.counter-touch-value { z-index: 2; margin-top: clamp(2px, .7vmin, 7px); color: currentColor; font-size: clamp(44px, 12vmin, 104px); font-weight: 950; letter-spacing: -.065em; line-height: .9; font-variant-numeric: tabular-nums; pointer-events: none; }
.counter-touch-value.is-critical { color: #b32b4d; }

.counter-split-zone {
  position: absolute;
  z-index: 1;
  top: 0;
  bottom: 0;
  display: flex;
  width: 50%;
  align-items: center;
  padding: 0 clamp(10px, 2.4vmin, 25px);
  border: 0;
  color: currentColor;
  background: transparent;
  cursor: pointer;
  font-size: clamp(22px, 4vmin, 38px);
  font-weight: 850;
  opacity: .5;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.counter-split-zone.is-left { left: 0; justify-content: flex-start; }
.counter-split-zone.is-right { right: 0; justify-content: flex-end; }
.counter-split-zone:active { background: rgba(255, 255, 255, .35); opacity: 1; }
.counter-split-zone:focus-visible { outline: 3px solid currentColor; outline-offset: -6px; }

.combined-panel .life-player-head { top: 7px; right: 7px; left: 7px; }
.combined-panel .life-player-head .player-name { gap: 4px; font-size: clamp(7px, .95vmin, 10px); }
.combined-panel .life-player-head .player-status { min-height: 15px; padding: 2px 4px; font-size: 6px; }
.combined-panel .life-player-card .life-number { font-size: clamp(44px, 13vmin, 90px); }
.combined-panel .life-mode-close { min-height: 22px; padding: 0 6px; font-size: 6px; }
.combined-panel .commander-target-title { font-size: clamp(11px, 2vmin, 17px); }
.combined-panel .commander-target-help { font-size: clamp(7px, .9vmin, 9px); }
.combined-panel .commander-source-view { gap: 5px; padding: 28px 4px 4px; }
.combined-panel .commander-source-value { font-size: clamp(28px, 9vmin, 62px); }
.combined-panel .commander-adjust-zone { width: 50%; }
.combined-panel .counter-touch-surface { inset: 29px 4px 4px; gap: 4px; }
.combined-panel .counter-touch-panel { border-radius: 8px; }
.combined-panel .counter-touch-label { font-size: clamp(6px, .8vmin, 8px); }
.combined-panel .counter-touch-value { margin-top: 1px; font-size: clamp(18px, 5vmin, 34px); }
.combined-panel .counter-split-zone { padding: 0 5px; font-size: clamp(12px, 2vmin, 17px); }
.combined-panel .player-elimination-overlay { gap: 2px; padding: 5px; }
.combined-panel .player-elimination-skull { width: clamp(24px, 5vmin, 42px); }
.combined-panel .player-elimination-overlay strong { font-size: clamp(8px, 1.2vmin, 11px); }
.combined-panel .player-elimination-reason { font-size: clamp(6px, .8vmin, 8px); }

@media (prefers-reduced-motion: reduce) {
  .life-player-card.is-life-hit,
  .life-player-card.is-life-heal,
  .life-player-card.is-life-hit .life-number,
  .life-player-card.is-life-heal .life-number,
  .player-elimination-overlay,
  .player-elimination-skull { animation-duration: .01ms; }
}

@media (max-width: 500px) {
  .life-player-head { top: 11px; right: 11px; left: 11px; }
  .life-player-card .life-number { font-size: clamp(70px, 22vmin, 132px); }
  .counter-touch-surface { inset: 45px 8px 8px; gap: 7px; }
  .counter-touch-value { font-size: clamp(40px, 13vmin, 82px); }
  .commander-source-view { gap: 9px; padding: 52px 8px 10px; }
}
