:root {
  --bg: #09101f;
  --panel: rgba(10, 18, 37, 0.78);
  --panel-strong: rgba(14, 24, 48, 0.92);
  --stroke: rgba(255, 255, 255, 0.1);
  --text: #eef2ff;
  --muted: #b6c3e1;
  --accent: #ff8f3d;
  --accent-strong: #ff6f32;
  --accent-cool: #4cb5ff;
  --danger: #ff6c75;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.35);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --font-display: "Avenir Next Condensed", "Avenir Next", "Trebuchet MS",
    sans-serif;
  --font-body: "Avenir Next", "Segoe UI", sans-serif;
  --safe-top: max(12px, env(safe-area-inset-top));
  --safe-bottom: max(12px, env(safe-area-inset-bottom));
  --safe-left: max(10px, env(safe-area-inset-left));
  --safe-right: max(10px, env(safe-area-inset-right));
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  color: var(--text);
  background: radial-gradient(circle at top, #102247 0%, var(--bg) 45%);
}

body[data-screen="live"] {
  overflow: hidden;
}

body[data-screen="setup"] {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

input,
select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  min-height: 54px;
  padding: 0.9rem 1rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  transition: border-color 180ms ease, background 180ms ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(255, 143, 61, 0.9);
  background: rgba(255, 255, 255, 0.1);
}

.app-background {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.app-background__mesh {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(
      rgba(255, 255, 255, 0.03) 1px,
      transparent 1px
    ),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.65), transparent 80%);
}

.app-background__glow {
  position: absolute;
  border-radius: 999px;
  filter: blur(80px);
  opacity: 0.42;
}

.app-background__glow--left {
  width: 340px;
  height: 340px;
  background: rgba(255, 143, 61, 0.36);
  top: 6%;
  left: -6%;
}

.app-background__glow--right {
  width: 380px;
  height: 380px;
  background: rgba(76, 181, 255, 0.3);
  top: 18%;
  right: -10%;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1200px, calc(100% - 1rem));
  margin: 0 auto;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  min-height: 100dvh;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
}

.screen--setup.is-active {
  display: grid;
  height: calc(100svh - var(--safe-top) - var(--safe-bottom));
  overflow: hidden;
}

.screen--live.is-active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.7rem;
  height: calc(100svh - var(--safe-top) - var(--safe-bottom));
  overflow: hidden;
}

.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-xl);
  padding: 1.2rem;
  background: linear-gradient(180deg, var(--panel), var(--panel-strong));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.08),
    transparent 42%
  );
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: #9fd8ff;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.section-heading h2,
.setup-hero h1,
.live-header h2,
.live-team-card h2,
.summary-hero h2 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}

.section-heading h2 {
  font-size: 1.6rem;
}

.button,
.play-button {
  border: 1px solid transparent;
  border-radius: 999px;
  min-height: 46px;
  padding: 0.8rem 1rem;
  font-weight: 700;
  color: var(--text);
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  transition: transform 180ms ease, opacity 180ms ease, filter 180ms ease,
    border-color 180ms ease;
}

.button:hover,
.play-button:hover {
  transform: translateY(-1px);
  filter: saturate(1.08);
}

.button:disabled,
.play-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
  filter: none;
}

.button--ghost {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
}

.button--accent {
  background: linear-gradient(135deg, #4cb5ff, #267cff);
}

.button--small {
  min-height: 38px;
  padding: 0.55rem 0.75rem;
  font-size: 0.86rem;
}

.setup-layout,
.screen--summary.is-active {
  display: grid;
  gap: 1rem;
}

.setup-layout {
  max-width: 760px;
  margin: 0 auto;
  min-height: 0;
  width: 100%;
}

.setup-hero {
  display: grid;
  gap: 1rem;
  align-content: start;
  padding: 1.5rem;
}

.setup-hero__content {
  display: grid;
  gap: 0.5rem;
}

.setup-hero h1 {
  font-size: clamp(3.3rem, 11vw, 6rem);
  line-height: 0.88;
}

.setup-hero__title {
  position: relative;
  display: inline-flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.12em;
  width: fit-content;
  padding: 0 0 0.52rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.setup-hero__title-core,
.setup-hero__title-accent {
  position: relative;
  display: inline-block;
  line-height: 0.9;
}

.setup-hero__title-core {
  color: #f8fbff;
  text-shadow:
    0 12px 30px rgba(0, 0, 0, 0.24),
    0 0 24px rgba(76, 181, 255, 0.1);
}

.setup-hero__title-accent {
  padding: 0.08em 0.26em 0.14em;
  border-radius: 0.32em;
  color: #081122;
  background: linear-gradient(135deg, #ffb36a 0%, #ff8f3d 58%, #ff6b3d 100%);
  box-shadow:
    0 12px 24px rgba(255, 143, 61, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.36);
  transform: translateY(-0.02em) skewX(-8deg);
}

.setup-hero__title-accent::before {
  content: "";
  position: absolute;
  left: 0.18em;
  right: 0.18em;
  top: -0.16em;
  height: 0.12em;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  filter: blur(0.4px);
}

.setup-hero__title::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: min(100%, 17rem);
  height: 0.28rem;
  border-radius: 999px;
  background: linear-gradient(90deg, #4cb5ff 0%, #8fd7ff 28%, #ff8f3d 78%, #ffb36a 100%);
  box-shadow: 0 8px 22px rgba(76, 181, 255, 0.22);
}

.setup-hero__text {
  margin: 0;
  max-width: 34rem;
  color: var(--muted);
  line-height: 1.55;
}

.setup-hero__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.setup-chip {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0.58rem 0.82rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.setup-start-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  text-align: center;
}

.setup-start-button--hero {
  display: none;
}

.setup-panel {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.setup-fields {
  display: grid;
  gap: 0.9rem;
}

.field {
  display: grid;
  gap: 0.45rem;
}

.field__label {
  color: var(--muted);
  font-size: 0.9rem;
}

.setup-option-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.setup-option-chip {
  min-height: 48px;
  padding: 0.7rem 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.86);
  font-weight: 700;
  text-align: center;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease,
    box-shadow 180ms ease;
}

.setup-option-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.18);
}

.setup-option-chip.is-active {
  color: #081122;
  border-color: rgba(255, 179, 106, 0.65);
  background: linear-gradient(135deg, #ffb36a 0%, #ff8f3d 65%, #ff6b3d 100%);
  box-shadow:
    0 10px 24px rgba(255, 143, 61, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.34);
}

.setup-option-chip:focus-visible {
  outline: 2px solid rgba(76, 181, 255, 0.72);
  outline-offset: 2px;
}

.setup-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.preview-card,
.summary-card,
.set-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.04);
}

.preview-card {
  padding: 1.05rem 1.15rem;
}

.preview-card span,
.team-card__sets span,
.summary-card__label,
.set-card__label,
.metric-table__cell--label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.preview-card strong {
  display: block;
  margin-top: 0.3rem;
  font-size: 1.15rem;
}

.live-header {
  display: grid;
  gap: 0.9rem;
  padding: 1rem 1.05rem;
}

.live-header__top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.live-header__copy {
  min-width: 0;
  padding: 0.18rem 0.3rem 0.02rem 0.24rem;
}

.live-header h2 {
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-header__actions {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  grid-template-rows: repeat(2, minmax(0, 1fr));
  grid-template-areas:
    "swap undo"
    "finish undo";
  gap: 0.55rem;
  flex-shrink: 0;
  width: min(calc(100% - 0.3rem), 404px);
  justify-self: start;
}

.live-header__actions > * {
  width: 100%;
}

.live-header__actions .button {
  min-height: 50px;
  padding: 0.5rem 0.7rem;
  border-radius: 14px;
  display: grid;
  place-items: center;
  min-width: 0;
  max-width: 100%;
  text-align: center;
  line-height: 1.05;
  overflow-wrap: anywhere;
  text-wrap: balance;
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.live-header__actions [data-action="swap-sides"] {
  grid-area: swap;
}

.live-header__actions [data-action="finish-match"] {
  grid-area: finish;
}

.live-header__actions [data-action="undo"] {
  grid-area: undo;
  height: 100%;
  margin-left: 0.18rem;
  border-radius: 12px;
}

.point-sequence-panel {
  display: none;
  min-height: 0;
}

.point-sequence-panel__teams {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  position: relative;
  z-index: 2;
}

.point-sequence-panel__teams span {
  display: block;
  text-align: center;
  color: var(--text);
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.55rem 0.7rem;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(23, 34, 63, 0.98), rgba(14, 22, 41, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  opacity: 1;
}

.point-sequence {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.22rem;
  align-content: start;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.08rem 0.12rem 0.12rem;
  border-radius: 18px;
  background: rgba(8, 15, 30, 0.26);
}

.point-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.22rem;
}

.point-row--current {
  position: sticky;
  bottom: 0;
  z-index: 1;
  padding-top: 0.18rem;
  background: linear-gradient(180deg, rgba(9, 16, 31, 0), rgba(9, 16, 31, 0.92) 35%);
}

.point-cell {
  min-height: 50px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  padding: 0.35rem;
  font-family: var(--font-display);
  font-size: 1.45rem;
  line-height: 1;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.point-cell--filled {
  grid-template-rows: auto auto;
  align-content: center;
  justify-items: center;
  gap: 0.1rem;
}

.point-cell__play {
  display: block;
  max-width: 100%;
  font-family: var(--font-ui);
  font-size: 0.52rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}

.point-cell__score {
  display: block;
  font-size: 1.45rem;
  line-height: 0.95;
}

.point-cell__score--current {
  font-size: 1.62rem;
}

.point-cell:not(.point-cell--filled) {
  color: transparent;
  background: rgba(255, 255, 255, 0.045);
}

.point-cell--team-0,
.point-cell--team-1 {
  background: linear-gradient(180deg, rgba(255, 143, 61, 0.24), rgba(255, 255, 255, 0.08));
  border-color: rgba(255, 143, 61, 0.26);
}

.point-cell--current {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.live-team-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.live-team-card {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: 0.6rem;
  padding: 0.95rem;
  align-content: start;
  overflow: hidden;
}

.live-team-card--a {
  --team-tint: rgba(255, 143, 61, 0.16);
}

.live-team-card--b {
  --team-tint: rgba(76, 181, 255, 0.14);
}

.live-team-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top left, var(--team-tint), transparent 55%);
  pointer-events: none;
}

.live-team-card.is-leading {
  border-color: rgba(255, 255, 255, 0.22);
}

.team-card__header {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.16rem 0.2rem 0.04rem;
}

.team-card__header h2 {
  font-size: clamp(1.05rem, 2.8vw, 1.6rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.team-card__sets {
  display: grid;
  gap: 0.12rem;
  justify-items: end;
}

.team-card__sets strong {
  font-size: 1.35rem;
}

.score-badge {
  min-width: 0;
  padding: 0.9rem 1.05rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.12),
    rgba(255, 255, 255, 0.04)
  );
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.score-badge__value {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 8vw, 4.6rem);
  line-height: 0.9;
  text-align: center;
}

.button-row,
.summary-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.button-row--compact > * {
  flex: 1 1 0;
}

.play-grid,
.resource-grid,
.summary-meta-grid,
.sets-timeline {
  display: grid;
  gap: 0.55rem;
}

.play-grid,
.resource-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
}

.play-button {
  min-height: 48px;
  padding: 0.8rem 0.72rem;
  border-radius: 20px;
  font-size: 0.92rem;
}

.play-button,
.resource-box__button {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 0.15rem;
  min-width: 0;
  max-width: 100%;
  text-align: center;
  overflow: hidden;
}

.play-button--warning {
  background: linear-gradient(135deg, #ff7b7b, #ef4d68);
}

.action-button__label {
  display: block;
  max-width: 100%;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.03em;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.action-button__value {
  display: block;
  max-width: 100%;
  font-family: var(--font-display);
  font-size: 1.5rem;
  line-height: 1;
}

.resource-box__button {
  width: 100%;
  min-height: 56px;
  padding: 0.65rem 0.72rem;
  border-radius: 20px;
}

.resource-box__button .action-button__value {
  font-size: 1.35rem;
}

.summary-hero {
  display: grid;
  gap: 1rem;
}

.summary-hero__copy h2 {
  font-size: clamp(1.8rem, 4.8vw, 2.9rem);
  line-height: 1.02;
  text-wrap: balance;
}

.summary-hero__copy p:last-child {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.summary-meta-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.summary-card {
  padding: 1rem;
}

.summary-card__value {
  display: block;
  margin-top: 0.35rem;
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  font-family: var(--font-display);
}

.totals-table {
  display: grid;
  gap: 0.6rem;
}

.metric-table__row {
  display: grid;
  grid-template-columns: minmax(72px, 0.76fr) minmax(0, 1.2fr) minmax(72px, 0.76fr);
  align-items: center;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.metric-table__row--header {
  background: rgba(255, 255, 255, 0.02);
  border-style: dashed;
}

.metric-table__cell {
  min-width: 0;
  text-align: center;
  font-weight: 700;
}

.metric-table__cell--team {
  font-size: 0.88rem;
}

.metric-table__cell--label {
  text-align: center;
}

.sets-timeline {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.set-card {
  display: grid;
  gap: 0.9rem;
  padding: 1rem;
}

.set-card__heading {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.set-card__title {
  font-size: 1.22rem;
  font-family: var(--font-display);
}

.set-card__scoreboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  padding: 0.95rem 1rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.set-card__team {
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.2;
}

.set-card__team--left {
  text-align: left;
}

.set-card__team--right {
  text-align: right;
}

.set-card__result {
  font-size: 1.95rem;
  font-family: var(--font-display);
  line-height: 0.95;
  white-space: nowrap;
}

.set-card__metrics {
  display: grid;
  gap: 0.45rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(92vw, 520px);
  z-index: 10;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 0.95rem 1.2rem;
  text-align: center;
  color: var(--text);
  background: rgba(7, 11, 22, 0.92);
  box-shadow: var(--shadow);
}

@media (max-width: 860px) {
  .summary-meta-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  .app-shell {
    width: min(100%, calc(100% - 0.75rem));
  }

  .panel {
    padding: 1.05rem;
    border-radius: 24px;
  }

  .live-header__top {
    flex-direction: column;
  }

  .live-header__actions {
    width: 100%;
  }

  .summary-hero__actions {
    grid-template-columns: 1fr;
  }

  .metric-table__row,
  .set-card__scoreboard {
    align-items: center;
  }

  .set-card__scoreboard {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .set-card__team--left,
  .set-card__team--right {
    text-align: center;
  }
}

@media (max-width: 460px) {
  .live-team-grid {
    gap: 0.55rem;
  }

  .live-team-card {
    padding: 0.7rem;
  }

  .play-button {
    min-height: 44px;
    font-size: 0.83rem;
  }

  .button--small {
    font-size: 0.8rem;
  }

  .action-button__value {
    font-size: 1.28rem;
  }
}

@media (max-height: 820px) {
  .setup-hero {
    padding: 1.2rem;
  }

  .setup-hero h1 {
    font-size: clamp(2.8rem, 8vw, 4.9rem);
  }

  .setup-hero__text {
    margin-top: 0.55rem;
    line-height: 1.45;
  }

  .setup-chip {
    min-height: 34px;
    padding: 0.5rem 0.72rem;
    font-size: 0.75rem;
  }

  .setup-panel {
    gap: 0.8rem;
  }

  .setup-fields {
    gap: 0.75rem;
  }

  .field {
    gap: 0.35rem;
  }

  .setup-option-chip {
    min-height: 44px;
    padding: 0.62rem 0.45rem;
  }

  input,
  select {
    min-height: 48px;
    padding: 0.75rem 0.85rem;
  }

  .live-header {
    gap: 0.6rem;
    padding: 0.85rem 0.95rem;
  }

  .live-team-card {
    gap: 0.5rem;
    padding: 0.75rem;
  }

  .score-badge {
    padding: 0.7rem 0.8rem;
  }

  .play-button {
    min-height: 42px;
    padding: 0.55rem 0.45rem;
  }

  .resource-box__button {
    min-height: 50px;
  }
}

@media (max-height: 720px) {
  .setup-hero {
    padding: 1.05rem 1.1rem;
  }

  .setup-hero h1 {
    font-size: clamp(2.3rem, 6.8vw, 3.9rem);
  }

  .setup-hero__text {
    margin-top: 0.45rem;
    font-size: 0.9rem;
    line-height: 1.35;
  }

  .setup-chip {
    min-height: 32px;
    padding: 0.42rem 0.64rem;
    font-size: 0.71rem;
  }

  .section-heading {
    margin-bottom: 0.75rem;
  }

  .section-heading h2 {
    font-size: 1.35rem;
  }

  .setup-panel {
    gap: 0.65rem;
  }

  .setup-fields {
    gap: 0.6rem;
  }

  .field__label {
    font-size: 0.82rem;
  }

  .setup-option-row {
    gap: 0.4rem;
  }

  .setup-option-chip {
    min-height: 40px;
    padding: 0.55rem 0.4rem;
    font-size: 0.82rem;
  }

  input,
  select {
    min-height: 44px;
    padding: 0.68rem 0.8rem;
  }

  .live-header h2 {
    font-size: 1.2rem;
  }

  .team-card__sets span,
  .action-button__label {
    font-size: 0.74rem;
  }

  .team-card__header h2 {
    font-size: 0.98rem;
  }

  .team-card__sets strong {
    font-size: 1.15rem;
  }

  .score-badge__value {
    font-size: clamp(2.2rem, 7vw, 3.4rem);
  }

  .button,
  .play-button {
    min-height: 38px;
    padding-block: 0.5rem;
  }

  .button--small {
    min-height: 34px;
    padding: 0.45rem 0.6rem;
  }

  .action-button__value {
    font-size: 1.1rem;
  }
}

@media (orientation: portrait) {
  .setup-layout {
    grid-template-rows: auto minmax(0, 1fr);
    align-content: start;
    gap: 0.7rem;
  }

  .setup-hero,
  .setup-panel {
    min-height: 0;
  }

  .setup-hero {
    padding: 1.15rem;
  }

  .setup-start-button--panel {
    display: inline-flex;
  }

  .screen--live.is-active {
    grid-template-areas:
      "header"
      "teams";
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .live-header {
    grid-area: header;
  }

  .live-team-grid {
    grid-area: teams;
    grid-template-columns: 1fr;
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
    min-height: 0;
  }

  .live-header {
    padding: 0.95rem 1rem;
  }

  .live-header__top {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .live-header__actions {
    width: 100%;
  }

  .live-team-card {
    grid-template-rows: auto auto auto auto;
    height: 100%;
    align-content: stretch;
  }

  .play-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

  .point-sequence-panel {
    display: none;
  }
}

@media (orientation: landscape) {
  .screen--setup.is-active {
    align-items: stretch;
  }

  .setup-layout {
    grid-template-columns: minmax(250px, 0.88fr) minmax(0, 1.12fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 0.6rem;
    align-items: stretch;
  }

  .setup-hero,
  .setup-panel {
    height: 100%;
  }

  .setup-hero {
    display: grid;
    grid-template-rows: auto auto auto;
    align-content: stretch;
    padding: 1.2rem 1.25rem;
  }

  .setup-hero h1 {
    font-size: clamp(2.9rem, 5vw, 5rem);
  }

  .setup-hero__text {
    max-width: 24rem;
    font-size: 0.94rem;
    line-height: 1.4;
  }

  .setup-hero__chips {
    align-self: start;
  }

  .setup-start-button--hero {
    display: inline-flex;
    align-self: end;
  }

  .setup-panel {
    grid-template-rows: auto auto;
    padding: 1.1rem 1.15rem;
  }

  .setup-start-button--panel {
    display: none;
  }

  .app-shell {
    width: min(1400px, calc(100% - 0.5rem));
    padding-left: max(18px, env(safe-area-inset-left) + 10px);
    padding-right: max(18px, env(safe-area-inset-right) + 10px);
  }

  .screen--live.is-active {
    grid-template-areas: "header teams";
    grid-template-columns: minmax(250px, 0.82fr) minmax(0, 1.18fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 0.45rem;
    height: calc(100svh - var(--safe-top) - var(--safe-bottom));
  }

  .live-header {
    grid-area: header;
  }

  .live-header {
    height: 100%;
    grid-template-rows: auto minmax(0, 1fr);
    padding: 0.78rem 0.9rem;
  }

  .live-header__top {
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.7rem;
  }

  .live-header h2 {
    white-space: normal;
    text-wrap: balance;
    font-size: clamp(1.05rem, 2.3vw, 1.45rem);
    line-height: 0.98;
  }

  .live-header__actions {
    align-items: stretch;
    gap: 0.4rem;
    width: 100%;
  }

  .live-header__actions .button {
    min-height: 46px;
    padding: 0.46rem 0.62rem;
  }

  .point-sequence-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
  }

  .live-team-grid {
    grid-area: teams;
    min-height: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
    justify-content: center;
  }

  .live-team-card {
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: 0.4rem;
    padding: 0.6rem;
    align-content: stretch;
    width: min(100%, 390px);
    justify-self: center;
  }

  .team-card__header h2 {
    font-size: 0.96rem;
  }

  .team-card__sets span,
  .action-button__label {
    font-size: 0.68rem;
  }

  .team-card__sets strong {
    font-size: 1.02rem;
  }

  .score-badge {
    padding: 0.42rem 0.58rem;
  }

  .score-badge__value {
    font-size: clamp(2rem, 5.4vw, 3rem);
  }

  .play-grid,
  .resource-grid {
    gap: 0.38rem;
  }

  .play-button {
    min-height: 42px;
    padding: 0.42rem 0.45rem;
    border-radius: 16px;
  }

  .resource-box__button {
    min-height: 42px;
    padding: 0.38rem 0.45rem;
    border-radius: 16px;
  }

  .action-button__value {
    font-size: 1rem;
  }

  .point-cell__play {
    font-size: 0.48rem;
  }

  .point-cell__score {
    font-size: 1.24rem;
  }

  .point-cell__score--current {
    font-size: 1.42rem;
  }
}

@media (orientation: portrait) and (max-height: 860px) {
  .screen--live.is-active {
    gap: 0.45rem;
  }

  .live-header {
    gap: 0.48rem;
    padding: 0.72rem 0.8rem;
  }

  .live-header__copy {
    padding: 0.08rem 0.14rem 0;
  }

  .live-header h2 {
    font-size: clamp(1rem, 4vw, 1.24rem);
  }

  .live-header__actions {
    gap: 0.34rem;
  }

  .live-header__actions .button {
    min-height: 38px;
    padding: 0.34rem 0.45rem;
    font-size: 0.8rem;
  }

  .live-team-grid {
    gap: 0.42rem;
  }

  .live-team-card {
    gap: 0.3rem;
    padding: 0.56rem;
  }

  .play-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

  .team-card__header {
    padding: 0.06rem 0.08rem 0;
  }

  .team-card__header h2 {
    font-size: 0.9rem;
  }

  .team-card__sets span,
  .action-button__label {
    font-size: 0.62rem;
  }

  .team-card__sets strong {
    font-size: 0.94rem;
  }

  .score-badge {
    padding: 0.32rem 0.48rem;
  }

  .score-badge__value {
    font-size: clamp(1.58rem, 7vw, 2.16rem);
  }

  .play-grid,
  .resource-grid {
    gap: 0.3rem;
  }

  .play-button {
    min-height: 32px;
    padding: 0.26rem 0.28rem;
    border-radius: 14px;
  }

  .resource-box__button {
    min-height: 34px;
    padding: 0.24rem 0.28rem;
    border-radius: 14px;
  }

  .action-button__value {
    font-size: 0.86rem;
  }

  .resource-box__button .action-button__value {
    font-size: 0.96rem;
  }
}

@media (orientation: portrait) and (max-height: 740px) {
  .screen--live.is-active {
    gap: 0.34rem;
  }

  .eyebrow {
    font-size: 0.66rem;
    margin-bottom: 0.22rem;
  }

  .live-header {
    gap: 0.4rem;
    padding: 0.6rem 0.68rem;
  }

  .live-header h2 {
    font-size: clamp(0.92rem, 3.8vw, 1.1rem);
  }

  .live-header__actions .button {
    min-height: 34px;
    padding: 0.28rem 0.34rem;
    font-size: 0.74rem;
  }

  .live-team-grid {
    gap: 0.34rem;
  }

  .live-team-card {
    gap: 0.24rem;
    padding: 0.46rem;
  }

  .play-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

  .team-card__header h2 {
    font-size: 0.84rem;
  }

  .team-card__sets span,
  .action-button__label {
    font-size: 0.56rem;
  }

  .team-card__sets strong {
    font-size: 0.88rem;
  }

  .score-badge {
    padding: 0.26rem 0.42rem;
  }

  .score-badge__value {
    font-size: clamp(1.36rem, 6vw, 1.8rem);
  }

  .play-grid,
  .resource-grid {
    gap: 0.24rem;
  }

  .play-button {
    min-height: 28px;
    padding: 0.2rem 0.22rem;
  }

  .resource-box__button {
    min-height: 30px;
    padding: 0.18rem 0.22rem;
  }

  .action-button__value {
    font-size: 0.78rem;
  }

  .resource-box__button .action-button__value {
    font-size: 0.88rem;
  }
}

@media (orientation: landscape) and (min-width: 1180px) {
  .live-team-grid {
    grid-template-columns: repeat(2, minmax(300px, 390px));
    justify-content: center;
    gap: 0.6rem;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  .setup-layout {
    gap: 0.45rem;
  }

  .setup-hero {
    padding: 0.95rem 1rem;
  }

  .setup-hero h1 {
    font-size: clamp(2.35rem, 4vw, 3.7rem);
  }

  .setup-hero__text {
    font-size: 0.84rem;
    line-height: 1.28;
  }

  .setup-hero__chips {
    gap: 0.4rem;
  }

  .setup-panel {
    gap: 0.55rem;
    padding: 0.95rem 1rem;
  }

  .setup-fields {
    gap: 0.5rem;
  }

  .setup-chip {
    min-height: 30px;
    padding: 0.38rem 0.56rem;
    font-size: 0.68rem;
  }

  .screen--live.is-active {
    gap: 0.4rem;
    height: calc(100svh - var(--safe-top) - var(--safe-bottom));
  }

  .live-header {
    gap: 0.45rem;
    padding: 0.58rem 0.68rem;
  }

  .live-header h2 {
    font-size: clamp(0.98rem, 1.9vw, 1.24rem);
  }

  .live-team-grid {
    gap: 0.4rem;
  }

  .live-team-card {
    gap: 0.35rem;
    padding: 0.55rem;
  }

  .team-card__sets span,
  .action-button__label {
    font-size: 0.66rem;
  }

  .score-badge {
    padding: 0.4rem 0.55rem;
  }

  .score-badge__value {
    font-size: clamp(1.9rem, 5vw, 2.8rem);
  }

  .play-grid,
  .resource-grid {
    gap: 0.35rem;
  }

  .button,
  .play-button {
    min-height: 36px;
    padding: 0.42rem 0.5rem;
  }

  .live-header__actions .button {
    min-height: 40px;
    padding: 0.4rem 0.5rem;
  }

  .button--small {
    min-height: 34px;
    padding: 0.38rem 0.5rem;
  }

  .play-button {
    border-radius: 16px;
  }

  .resource-box__button {
    min-height: 40px;
    padding: 0.35rem 0.45rem;
    border-radius: 16px;
  }

  .action-button__value {
    font-size: 0.96rem;
  }

  .point-sequence-panel__teams span {
    font-size: 0.72rem;
    padding: 0.32rem 0.42rem;
  }

  .point-row {
    gap: 0.18rem;
  }

  .point-cell {
    min-height: 40px;
    font-size: 1.08rem;
  }

  .point-cell__play {
    font-size: 0.43rem;
  }

  .point-cell__score {
    font-size: 1.04rem;
  }

  .point-cell__score--current {
    font-size: 1.18rem;
  }
}
