:root {
  color-scheme: light;
  --navy-950: #061827;
  --navy-900: #0b2943;
  --navy-800: #153a57;
  --navy-700: #244d67;
  --ivory-50: #fffdf7;
  --ivory-100: #f7f1e2;
  --ivory-200: #eadfc7;
  --ivory-300: #d8c8a7;
  --wood-200: #e6c69d;
  --wood-300: #d3a56f;
  --wood-500: #9c6638;
  --ink: #172431;
  --muted: #697177;
  --line: #d2c5aa;
  --danger: #a93635;
  --p1: #b63732;
  --p1-soft: #f6e5df;
  --p2: #2d3338;
  --p2-soft: #e8e8e5;
  --p3: #268f91;
  --p3-soft: #dff1ee;
  --p4: #cf8427;
  --p4-soft: #f7ead5;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--navy-950);
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.035), transparent 38%),
    linear-gradient(25deg, rgba(211, 165, 111, 0.08), transparent 42%),
    var(--navy-950);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    linear-gradient(rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0)),
    var(--ivory-100);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.7rem;
  padding: max(1rem, env(safe-area-inset-top)) 1.15rem 0.9rem;
  border-bottom: 0.25rem solid var(--wood-300);
  color: var(--ivory-100);
  background: var(--navy-900);
  box-shadow:
    inset 0 -1px rgba(255, 255, 255, 0.34),
    inset 0 0 0 1px rgba(247, 241, 226, 0.08);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.72rem;
  min-width: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.015em;
}

.brand-grid {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(4, 0.37rem);
  gap: 0.14rem;
  align-items: end;
  padding: 0.28rem 0.3rem;
  border: 1px solid rgba(247, 241, 226, 0.58);
  border-radius: 0.3rem;
}

.brand-grid span {
  width: 0.37rem;
  height: 1rem;
  border-radius: 0.1rem;
  background: var(--ivory-100);
  box-shadow: inset 0 -0.19rem currentColor;
}

.brand-grid span:nth-child(1) {
  color: var(--p1);
}

.brand-grid span:nth-child(2) {
  color: var(--p2);
}

.brand-grid span:nth-child(3) {
  color: var(--p3);
}

.brand-grid span:nth-child(4) {
  color: var(--p4);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
}

.topbar-action {
  min-height: 2.5rem;
  padding: 0.52rem 0.72rem;
  border: 1px solid rgba(247, 241, 226, 0.45);
  border-radius: 0.42rem;
  color: var(--ivory-100);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.875rem;
  font-weight: 750;
  cursor: pointer;
}

.topbar-action:active {
  background: rgba(255, 255, 255, 0.12);
}

.language-toggle {
  border-color: var(--ivory-100);
  color: var(--navy-900);
  background: var(--ivory-100);
}

.language-toggle:active {
  background: var(--ivory-200);
}

.content {
  width: 100%;
  max-width: 39rem;
  margin: 0 auto;
  padding: 1.65rem 1rem 2.25rem;
}

.content.with-totals {
  padding-bottom: 1rem;
}

.eyebrow {
  margin: 0 0 0.55rem;
  color: var(--wood-500);
  font-size: 0.8rem;
  font-weight: 850;
  letter-spacing: 0.105em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--navy-900);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 8vw, 3.15rem);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.035em;
}

.lead {
  max-width: 33rem;
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.panel {
  position: relative;
  margin-top: 1.5rem;
  padding: 1.15rem;
  border: 1px solid var(--line);
  border-radius: 0.72rem;
  background: var(--ivory-50);
  box-shadow:
    inset 0 0 0 0.2rem rgba(234, 223, 199, 0.34),
    0 0.8rem 2rem rgba(39, 43, 43, 0.08);
}

.mode-options {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.5rem;
}

.mode-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.95rem;
  min-height: 7.6rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-bottom: 0.25rem solid var(--wood-300);
  border-radius: 0.65rem;
  color: var(--ink);
  background: var(--ivory-50);
  text-align: start;
  box-shadow: 0 0.55rem 1.3rem rgba(39, 43, 43, 0.07);
  cursor: pointer;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    transform 100ms ease;
}

.mode-card:hover {
  border-color: var(--navy-700);
  box-shadow: 0 0.7rem 1.5rem rgba(11, 41, 67, 0.12);
}

.mode-card:active {
  transform: translateY(0.1rem);
}

.mode-tiles {
  display: grid;
  grid-template-columns: repeat(4, 0.7rem);
  gap: 0.16rem;
  align-items: end;
  padding: 0.55rem;
  border: 1px solid var(--ivory-300);
  border-radius: 0.4rem;
  background: var(--ivory-100);
}

.mode-tiles span {
  width: 0.7rem;
  height: 2.65rem;
  border: 1px solid var(--ivory-300);
  border-top-width: 0.22rem;
  border-radius: 0.18rem;
  background: var(--ivory-50);
}

.mode-tiles span:nth-child(1) {
  border-top-color: var(--p1);
}

.mode-tiles span:nth-child(2) {
  border-top-color: var(--p2);
}

.mode-tiles span:nth-child(3) {
  border-top-color: var(--p3);
}

.mode-tiles span:nth-child(4) {
  border-top-color: var(--p4);
}

.mode-tiles-duo span:nth-child(3) {
  margin-inline-start: 0.48rem;
}

.mode-tiles-duo {
  grid-template-columns: 0.7rem 0.7rem 1.18rem 0.7rem;
}

.mode-card-copy {
  display: grid;
  gap: 0.32rem;
  min-width: 0;
}

.mode-card-copy strong {
  color: var(--navy-900);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.3rem;
  line-height: 1.1;
}

.mode-card-copy span {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.mode-arrow {
  color: var(--wood-500);
  font-size: 1.35rem;
  font-weight: 850;
}

.mode-saved-note {
  margin-inline: 0.1rem;
}

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

.field + .field {
  margin-top: 1rem;
}

.field-label {
  color: var(--navy-800);
  font-size: 0.9rem;
  font-weight: 800;
}

.text-input,
.round-input {
  width: 100%;
  min-height: 3.65rem;
  border: 1.5px solid var(--ivory-300);
  border-radius: 0.48rem;
  outline: none;
  color: var(--ink);
  background: #fffef9;
  font-size: 1.05rem;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

.text-input {
  padding: 0 0.95rem;
}

.round-input {
  padding: 0.2rem 1rem;
  color: var(--navy-900);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.text-input:focus,
.round-input:focus,
.score-input:focus {
  border-color: var(--navy-700);
  background: #fff;
  box-shadow: 0 0 0 0.22rem rgba(21, 58, 87, 0.13);
}

.hint {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.45;
}

.saved-note {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 1rem 0 0;
  color: #626b70;
  font-size: 0.875rem;
  line-height: 1.4;
}

.saved-note::before {
  width: 1.15rem;
  height: 0.36rem;
  border: 1px solid var(--line);
  border-radius: 0.12rem;
  background:
    linear-gradient(
      90deg,
      var(--p1) 0 25%,
      var(--p2) 25% 50%,
      var(--p3) 50% 75%,
      var(--p4) 75% 100%
    );
  content: "";
}

.primary-button {
  width: 100%;
  min-height: 3.65rem;
  margin-top: 1.1rem;
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--navy-950);
  border-bottom: 0.25rem solid var(--wood-500);
  border-radius: 0.48rem;
  color: var(--ivory-50);
  background: var(--navy-900);
  font-size: 1rem;
  font-weight: 850;
  cursor: pointer;
  transition:
    transform 100ms ease,
    background 150ms ease;
}

.primary-button:hover {
  background: var(--navy-800);
}

.primary-button:active {
  transform: translateY(0.12rem);
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.75rem;
  margin: -0.3rem 0 1rem;
  padding: 0.5rem 0.65rem 0.5rem 0.2rem;
  border: 0;
  color: var(--navy-800);
  background: transparent;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
}

.back-button::before {
  content: "←";
  font-size: 1.15rem;
}

.setup-context {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0 0 0.72rem;
}

.context-chip,
.round-mode {
  display: inline-flex;
  align-items: center;
  min-height: 1.85rem;
  padding: 0.32rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 0.3rem;
  color: var(--navy-800);
  background: var(--ivory-50);
  font-size: 0.78rem;
  font-weight: 800;
}

.context-chip-mode,
.round-mode {
  border-color: rgba(36, 77, 103, 0.36);
  color: var(--ivory-100);
  background: var(--navy-800);
}

.player-fields {
  display: grid;
  gap: 0.85rem;
}

.team-player-groups {
  display: grid;
  gap: 0.9rem;
}

.team-player-group {
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  background: var(--ivory-100);
}

.team-group-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.team-group-head h2 {
  margin: 0;
  color: var(--navy-900);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  line-height: 1.2;
}

.team-pair-mark {
  display: inline-grid;
  grid-template-columns: repeat(2, 0.38rem);
  gap: 0.12rem;
  padding: 0.28rem;
  border: 1px solid var(--ivory-300);
  border-radius: 0.25rem;
  background: var(--ivory-50);
}

.team-pair-mark span {
  width: 0.38rem;
  height: 1.2rem;
  border-radius: 0.08rem;
}

.team-1 .team-pair-mark span:first-child {
  background: var(--p1);
}

.team-1 .team-pair-mark span:last-child {
  background: var(--p2);
}

.team-2 .team-pair-mark span:first-child {
  background: var(--p3);
}

.team-2 .team-pair-mark span:last-child {
  background: var(--p4);
}

.player-field {
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
}

.player-number,
.player-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--ivory-300);
  border-top-width: 0.25rem;
  border-radius: 0.3rem;
  background: var(--ivory-50);
  box-shadow: 0 0.2rem 0.45rem rgba(61, 47, 29, 0.1);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 800;
}

.player-number {
  width: 2.55rem;
  height: 3.1rem;
  font-size: 1.05rem;
}

.player-avatar {
  width: 2.65rem;
  height: 3rem;
  font-size: 1.05rem;
}

.player-1 .player-number,
.player-1 .player-avatar {
  border-top-color: var(--p1);
  color: var(--p1);
}

.player-2 .player-number,
.player-2 .player-avatar {
  border-top-color: var(--p2);
  color: var(--p2);
}

.player-3 .player-number,
.player-3 .player-avatar {
  border-top-color: var(--p3);
  color: var(--p3);
}

.player-4 .player-number,
.player-4 .player-avatar {
  border-top-color: var(--p4);
  color: var(--p4);
}

.form-error {
  min-height: 1.4rem;
  margin: 0.8rem 0 -0.25rem;
  color: var(--danger);
  font-size: 0.875rem;
  font-weight: 750;
  line-height: 1.35;
}

.dealer-content {
  text-align: center;
}

.dealer-content .lead {
  margin-inline: auto;
}

.dealer-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: min(21rem, 86vw);
  margin: 2rem auto 0;
  padding-top: 1rem;
}

.wheel-pointer {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 50%;
  width: 0;
  height: 0;
  border-right: 0.82rem solid transparent;
  border-left: 0.82rem solid transparent;
  border-top: 1.4rem solid var(--wood-500);
  filter: drop-shadow(0 0.15rem 0.12rem rgba(0, 0, 0, 0.18));
  transform: translateX(-50%);
}

.roulette-wheel {
  --wheel-rotation: 0deg;
  position: relative;
  width: min(18.5rem, 77vw);
  aspect-ratio: 1;
  overflow: hidden;
  border: 0.7rem solid var(--ivory-100);
  border-radius: 50%;
  outline: 0.18rem solid var(--wood-300);
  color: var(--ivory-50);
  background: conic-gradient(
    from -45deg,
    var(--p1) 0deg 90deg,
    var(--p2) 90deg 180deg,
    var(--p3) 180deg 270deg,
    var(--p4) 270deg 360deg
  );
  box-shadow:
    0 0 0 0.15rem var(--navy-900),
    0 1.1rem 2.6rem rgba(11, 41, 67, 0.2);
  cursor: pointer;
  transform: rotate(var(--wheel-rotation));
}

.roulette-wheel::before,
.roulette-wheel::after {
  position: absolute;
  inset: 0;
  z-index: 0;
  margin: auto;
  background: rgba(247, 241, 226, 0.76);
  content: "";
}

.roulette-wheel::before {
  width: 100%;
  height: 0.1rem;
}

.roulette-wheel::after {
  width: 0.1rem;
  height: 100%;
}

.roulette-wheel.is-spinning {
  cursor: wait;
  transition: transform 2.8s cubic-bezier(0.12, 0.72, 0.16, 1);
}

.roulette-wheel:disabled {
  cursor: default;
  opacity: 1;
}

.wheel-name {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  width: 42%;
  overflow: hidden;
  font-size: clamp(0.8rem, 3.4vw, 0.95rem);
  font-weight: 850;
  line-height: 1.15;
  text-align: center;
  text-overflow: ellipsis;
  text-shadow: 0 0.12rem 0.24rem rgba(0, 0, 0, 0.34);
  white-space: nowrap;
}

.wheel-name-1 {
  transform: translate(-50%, -50%) translateY(-5.8rem);
}

.wheel-name-2 {
  transform: translate(-50%, -50%) translateX(5.8rem) rotate(90deg);
}

.wheel-name-3 {
  transform: translate(-50%, -50%) translateY(5.8rem) rotate(180deg);
}

.wheel-name-4 {
  transform: translate(-50%, -50%) translateX(-5.8rem) rotate(-90deg);
}

.wheel-hub {
  position: absolute;
  z-index: 2;
  inset: 50% auto auto 50%;
  display: grid;
  place-items: center;
  width: 4.7rem;
  height: 4.7rem;
  border: 0.3rem solid var(--ivory-100);
  border-radius: 50%;
  color: var(--ivory-100);
  background: var(--navy-900);
  box-shadow: 0 0.35rem 0.8rem rgba(0, 0, 0, 0.25);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.82rem;
  font-weight: 850;
  letter-spacing: 0.045em;
  transform: translate(-50%, -50%);
}

.dealer-status {
  min-height: 3.2rem;
  margin: 1.5rem 0 0;
  color: var(--navy-800);
  font-size: 1.05rem;
  font-weight: 800;
}

.dealer-result {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.2rem;
  padding: 0.72rem 1rem;
  border: 1px solid var(--line);
  border-bottom: 0.23rem solid var(--wood-300);
  border-radius: 0.48rem;
  color: var(--navy-900);
  background: var(--ivory-50);
  font-size: 1.08rem;
  font-weight: 850;
}

.round-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.round-count {
  flex: 0 0 auto;
  margin: 0 0 0.2rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.round-meta {
  display: grid;
  justify-items: end;
  gap: 0.38rem;
}

.round-mode {
  min-height: 1.7rem;
  padding-block: 0.22rem;
}

.progress-track {
  height: 0.38rem;
  margin: 1rem 0 1.4rem;
  overflow: hidden;
  border: 1px solid rgba(156, 102, 56, 0.24);
  border-radius: 999px;
  background: var(--wood-200);
}

.progress-value {
  height: 100%;
  border-radius: inherit;
  background: var(--navy-900);
  transition: width 260ms ease;
}

.score-list {
  display: grid;
  gap: 0.78rem;
}

.score-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.8rem;
  min-height: 5.3rem;
  padding: 0.72rem;
  border: 1px solid var(--line);
  border-inline-start-width: 0.32rem;
  border-radius: 0.62rem;
  background: var(--ivory-50);
  box-shadow:
    inset 0 -0.28rem var(--wood-200),
    0 0.35rem 0.85rem rgba(54, 44, 29, 0.06);
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.score-card.player-1 {
  border-inline-start-color: var(--p1);
}

.score-card.player-2 {
  border-inline-start-color: var(--p2);
}

.score-card.player-3 {
  border-inline-start-color: var(--p3);
}

.score-card.player-4 {
  border-inline-start-color: var(--p4);
}

.score-card.team-1 {
  border-inline-start-color: var(--p1);
}

.score-card.team-2 {
  border-inline-start-color: var(--p3);
}

.team-1 .player-avatar {
  border-top-color: var(--p2);
  color: var(--p1);
}

.team-2 .player-avatar {
  border-top-color: var(--p4);
  color: var(--p3);
}

.score-card.is-negative {
  border-color: #c98783;
  border-inline-start-color: var(--danger);
  box-shadow:
    inset 0 -0.28rem #dfb19f,
    0 0 0 0.18rem rgba(169, 54, 53, 0.08);
}

.score-player {
  display: flex;
  align-items: center;
  gap: 0.72rem;
  min-width: 0;
  cursor: pointer;
}

.score-player-copy {
  display: grid;
  gap: 0.16rem;
  min-width: 0;
}

.score-player-name {
  min-width: 0;
  overflow: hidden;
  color: var(--navy-900);
  font-size: 1rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-player-detail {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-controls {
  display: grid;
  grid-template-columns: 2.9rem 5.4rem;
  gap: 0.45rem;
}

.sign-toggle {
  width: 2.9rem;
  min-height: 3.25rem;
  border: 1.5px solid var(--ivory-300);
  border-radius: 0.4rem;
  color: var(--navy-800);
  background: #fffef9;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 800;
  cursor: pointer;
}

.sign-toggle[aria-pressed="true"] {
  border-color: #c77b78;
  color: #8e2d2c;
  background: #f9e8e3;
}

.score-input {
  width: 5.4rem;
  min-height: 3.25rem;
  padding: 0.35rem 0.45rem;
  border: 1.5px solid var(--ivory-300);
  border-radius: 0.4rem;
  outline: none;
  color: var(--navy-900);
  background: #fffef9;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 800;
  text-align: center;
}

.score-input::placeholder {
  color: #a99d88;
}

.score-tip {
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.4;
}

.totals-tray {
  position: sticky;
  z-index: 5;
  bottom: 0;
  width: 100%;
  padding: 0.82rem 1rem max(0.82rem, env(safe-area-inset-bottom));
  border-top: 0.25rem solid var(--wood-300);
  color: var(--ivory-100);
  background: rgba(11, 41, 67, 0.97);
  box-shadow: 0 -0.65rem 1.6rem rgba(6, 24, 39, 0.16);
  backdrop-filter: blur(12px);
}

.totals-inner {
  max-width: 39rem;
  margin: 0 auto;
}

.totals-label {
  margin: 0 0 0.55rem;
  color: rgba(247, 241, 226, 0.74);
  font-size: 0.75rem;
  font-weight: 850;
  letter-spacing: 0.095em;
  text-transform: uppercase;
}

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

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

.total-item {
  display: grid;
  grid-template-columns: 0.38rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.56rem 0.65rem;
  border: 1px solid rgba(247, 241, 226, 0.16);
  border-radius: 0.4rem;
  background: rgba(255, 255, 255, 0.055);
}

.total-bar {
  width: 0.38rem;
  height: 1.55rem;
  border-radius: 0.1rem;
}

.player-1 .total-bar {
  background: var(--p1);
}

.player-2 .total-bar {
  background: #92989c;
}

.player-3 .total-bar {
  background: var(--p3);
}

.player-4 .total-bar {
  background: var(--p4);
}

.team-1 .total-bar {
  background: linear-gradient(to bottom, var(--p1) 0 50%, #92989c 50% 100%);
}

.team-2 .total-bar {
  background: linear-gradient(to bottom, var(--p3) 0 50%, var(--p4) 50% 100%);
}

.total-copy {
  display: grid;
  gap: 0.08rem;
  min-width: 0;
}

.total-name {
  min-width: 0;
  overflow: hidden;
  color: rgba(247, 241, 226, 0.78);
  font-size: 0.875rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.total-members {
  min-width: 0;
  overflow: hidden;
  color: rgba(247, 241, 226, 0.58);
  font-size: 0.72rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.total-value {
  color: var(--ivory-50);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.finish-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
  padding: 0.42rem 0.68rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  color: var(--navy-900);
  background: var(--ivory-50);
  font-size: 0.82rem;
  font-weight: 850;
}

.finish-badge::before {
  color: var(--p3);
  content: "✓";
}

.winner-callout {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.82rem;
  margin-top: 1.5rem;
  padding: 0.95rem;
  border: 1px solid rgba(247, 241, 226, 0.52);
  border-bottom: 0.25rem solid var(--wood-300);
  border-radius: 0.55rem;
  color: var(--ivory-100);
  background: var(--navy-900);
  box-shadow:
    inset 0 0 0 0.2rem rgba(247, 241, 226, 0.05),
    0 0.75rem 1.7rem rgba(11, 41, 67, 0.16);
}

.winner-mark {
  display: grid;
  place-items: center;
  width: 2.45rem;
  height: 3.05rem;
  border: 1px solid var(--ivory-300);
  border-top: 0.25rem solid var(--p1);
  border-radius: 0.3rem;
  color: var(--p1);
  background: var(--ivory-50);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 800;
}

.winner-copy {
  min-width: 0;
}

.winner-label {
  display: block;
  color: rgba(247, 241, 226, 0.72);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.winner-name {
  display: block;
  overflow: hidden;
  margin-top: 0.15rem;
  font-size: 1.15rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.winner-members {
  display: block;
  overflow: hidden;
  margin-top: 0.18rem;
  color: rgba(247, 241, 226, 0.66);
  font-size: 0.78rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.winner-score {
  color: var(--ivory-50);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.final-board {
  display: grid;
  gap: 0.72rem;
  margin-top: 1rem;
}

.final-row {
  display: grid;
  grid-template-columns: 3.6rem 0.38rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.72rem;
  padding: 0.86rem;
  border: 1px solid var(--line);
  border-radius: 0.52rem;
  background: var(--ivory-50);
  box-shadow: inset 0 -0.22rem var(--wood-200);
}

.final-row.is-winner {
  border-color: var(--navy-700);
  background: #fffef9;
  box-shadow:
    inset 0 -0.25rem var(--wood-300),
    0 0.5rem 1.1rem rgba(11, 41, 67, 0.08);
}

.final-row .total-bar {
  height: 2.4rem;
}

.final-copy {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.rank-badge {
  display: grid;
  place-items: center;
  min-height: 2.35rem;
  padding: 0.25rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: 0.3rem;
  color: var(--navy-800);
  background: var(--ivory-100);
  font-size: 0.82rem;
  font-weight: 850;
}

.is-winner .rank-badge {
  border-color: var(--navy-900);
  color: var(--ivory-50);
  background: var(--navy-900);
}

.final-name {
  min-width: 0;
  overflow: hidden;
  color: var(--navy-900);
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.final-members {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.final-score {
  color: var(--navy-900);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.5rem, 7vw, 2.1rem);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.toast {
  position: fixed;
  z-index: 20;
  inset-inline-end: 1rem;
  bottom: 1rem;
  max-width: min(24rem, calc(100vw - 2rem));
  padding: 0.8rem 1rem;
  border: 1px solid #d6a7a1;
  border-radius: 0.45rem;
  color: #fff;
  background: #842d2c;
  box-shadow: 0 0.7rem 2rem rgba(0, 0, 0, 0.25);
  font-size: 0.9rem;
  font-weight: 750;
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.6rem);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 0.18rem solid rgba(38, 143, 145, 0.58);
  outline-offset: 0.18rem;
}

html[dir="rtl"] {
  font-family: Tahoma, Arial, "Segoe UI", sans-serif;
}

html[dir="rtl"] h1,
html[dir="rtl"] .brand,
html[dir="rtl"] .mode-card-copy strong,
html[dir="rtl"] .team-group-head h2,
html[dir="rtl"] .round-input,
html[dir="rtl"] .player-number,
html[dir="rtl"] .player-avatar,
html[dir="rtl"] .score-input,
html[dir="rtl"] .sign-toggle,
html[dir="rtl"] .total-value,
html[dir="rtl"] .winner-mark,
html[dir="rtl"] .winner-score,
html[dir="rtl"] .final-score,
html[dir="rtl"] .wheel-hub {
  font-family: Tahoma, Arial, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

html[dir="rtl"] .eyebrow,
html[dir="rtl"] .totals-label,
html[dir="rtl"] .winner-label {
  letter-spacing: 0;
  text-transform: none;
}

html[dir="rtl"] .back-button::before {
  content: "→";
}

html[dir="rtl"] .mode-arrow {
  transform: rotate(180deg);
}

@media (min-width: 43rem) {
  body {
    padding: 1.5rem;
  }

  .app-shell {
    width: min(46rem, 100%);
    min-height: calc(100dvh - 3rem);
    margin: 0 auto;
    overflow: hidden;
    border: 1px solid rgba(247, 241, 226, 0.3);
    border-radius: 1rem;
    box-shadow:
      0 0 0 0.22rem rgba(211, 165, 111, 0.22),
      0 1.5rem 5rem rgba(0, 0, 0, 0.35);
  }

  .topbar {
    padding-inline: 2rem;
  }

  .content {
    padding: 2.25rem 2rem 2.5rem;
  }

  .panel {
    padding: 1.5rem;
  }

  .mode-options,
  .team-player-groups {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mode-card {
    grid-template-columns: 1fr auto;
    align-items: start;
  }

  .mode-card .mode-tiles {
    grid-column: 1 / -1;
  }

  .totals-tray {
    padding-inline: 2rem;
  }

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

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

  .total-item {
    grid-template-columns: 0.35rem minmax(0, 1fr);
  }

  .total-value {
    grid-column: 2;
  }
}

@media (max-width: 22rem) {
  .content {
    padding-inline: 0.75rem;
  }

  .topbar {
    gap: 0.5rem;
    padding-inline: 0.72rem;
  }

  .brand {
    gap: 0.44rem;
    font-size: 0.9rem;
  }

  .brand-grid {
    grid-template-columns: repeat(4, 0.3rem);
    gap: 0.1rem;
    padding-inline: 0.22rem;
  }

  .brand-grid span {
    width: 0.3rem;
  }

  .topbar-actions {
    gap: 0.3rem;
  }

  .topbar-action {
    padding-inline: 0.52rem;
    font-size: 0.78rem;
  }

  .score-card {
    gap: 0.45rem;
    padding: 0.62rem;
  }

  .mode-card {
    gap: 0.68rem;
    padding: 0.8rem;
  }

  .mode-tiles {
    grid-template-columns: repeat(4, 0.58rem);
    padding: 0.42rem;
  }

  .mode-tiles span {
    width: 0.58rem;
    height: 2.35rem;
  }

  .mode-tiles-duo {
    grid-template-columns: 0.58rem 0.58rem 1.06rem 0.58rem;
  }

  .team-player-group {
    padding: 0.72rem;
  }

  .player-avatar {
    width: 2.3rem;
    height: 2.75rem;
  }

  .score-controls {
    grid-template-columns: 2.7rem 4.8rem;
    gap: 0.35rem;
  }

  .sign-toggle {
    width: 2.7rem;
  }

  .score-input {
    width: 4.8rem;
  }

  .final-row {
    grid-template-columns: 3.2rem 0.35rem minmax(0, 1fr) auto;
    gap: 0.5rem;
    padding: 0.72rem;
  }
}

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