:root {
  --ink: #17312a;
  --ink-soft: #587168;
  --forest: #123d32;
  --forest-deep: #0b2e26;
  --forest-light: #dce9df;
  --paper: #f7f2e8;
  --paper-strong: #fffdf7;
  --paper-muted: #ece5d8;
  --line: rgba(18, 61, 50, 0.14);
  --red: #c84d3c;
  --red-soft: #f6dfda;
  --gold: #d4a63f;
  --gold-soft: #f5ebcb;
  --success: #21715b;
  --success-soft: #dceee7;
  --shadow-sm: 0 2px 8px rgba(25, 47, 40, 0.08);
  --shadow-md: 0 14px 36px rgba(25, 47, 40, 0.13);
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --tap: 48px;
  font-family:
    Inter, ui-rounded, "SF Pro Rounded", "SF Pro Display", -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
  touch-action: manipulation;
}

html {
  min-height: 100%;
  background: var(--forest);
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 15% -10%, rgba(212, 166, 63, 0.2), transparent 30rem),
    linear-gradient(180deg, var(--forest) 0, var(--forest) 210px, var(--paper) 210px);
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(212, 166, 63, 0.65);
  outline-offset: 2px;
}

.app-shell {
  width: min(100%, 780px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 16px calc(28px + env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 82px;
  color: white;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
}

.brand__mark {
  display: grid;
  width: 42px;
  height: 48px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 10px;
  color: var(--gold);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 3px rgba(18, 61, 50, 0.55);
  transform: rotate(-4deg);
}

.brand__mark svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.brand__text strong,
.brand__text span {
  display: block;
}

.brand__text strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
  line-height: 1;
  letter-spacing: -0.03em;
}

.brand__text span {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  display: inline-grid;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  color: white;
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
}

.icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button--plain {
  border-color: transparent;
  color: var(--ink-soft);
  background: transparent;
}

.page-card {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: var(--radius-lg);
  background: var(--paper-strong);
  box-shadow: var(--shadow-md);
}

.hero {
  position: relative;
  padding: 30px 24px 26px;
  color: white;
  background: var(--forest-deep);
  isolation: isolate;
}

.hero::after {
  position: absolute;
  right: -40px;
  bottom: -80px;
  z-index: -1;
  width: 210px;
  height: 210px;
  border: 42px solid rgba(212, 166, 63, 0.08);
  border-radius: 50%;
  content: "";
}

.hero .eyebrow {
  color: var(--gold);
}

.hero h1,
.winner-hero h1 {
  max-width: 560px;
  margin: 8px 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 8vw, 3.35rem);
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.hero p:not(.eyebrow) {
  max-width: 490px;
  margin: 0;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.55;
}

.eyebrow {
  margin: 0;
  color: var(--red);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.content {
  padding: 22px 18px 24px;
}

.section + .section {
  margin-top: 26px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.section-heading h2,
.section-heading h3,
.round-heading,
.dialog h2 {
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.05;
  letter-spacing: -0.025em;
}

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

.section-heading h3 {
  font-size: 1.17rem;
}

.section-heading p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.player-list {
  display: grid;
  gap: 9px;
}

.player-input-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 9px;
}

.seat-number {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  color: var(--forest);
  background: var(--forest-light);
  font-size: 0.8rem;
  font-weight: 850;
}

.text-input,
.select-input,
.number-input {
  width: 100%;
  min-height: var(--tap);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(18, 61, 50, 0.03);
}

.text-input,
.select-input {
  padding: 0 14px;
}

.text-input::placeholder {
  color: #92a099;
}

.remove-player {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
}

.remove-player svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.text-button {
  display: inline-flex;
  min-height: 40px;
  padding: 0;
  align-items: center;
  gap: 7px;
  border: 0;
  color: var(--forest);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.text-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.setup-grid {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
}

.field > span,
.field-label {
  color: var(--ink-soft);
  font-size: 0.79rem;
  font-weight: 800;
}

.field-help {
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.45;
}

.card-count-control {
  display: grid;
  grid-template-columns: var(--tap) minmax(0, 1fr) var(--tap);
  gap: 8px;
}

.small-step-button {
  display: grid;
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--forest);
  background: var(--paper-strong);
  font-size: 1.3rem;
  font-weight: 800;
  cursor: pointer;
}

.small-step-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.number-input {
  appearance: textfield;
  padding: 0 12px;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 850;
}

.number-input::-webkit-inner-spin-button,
.number-input::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
}

.rule-card {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  padding: 15px;
  border: 1px solid rgba(212, 166, 63, 0.3);
  border-radius: var(--radius-md);
  background: var(--gold-soft);
}

.rule-card__icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  color: var(--forest);
  background: rgba(255, 255, 255, 0.58);
}

.rule-card__icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rule-card strong,
.rule-card span {
  display: block;
}

.rule-card strong {
  margin: 1px 0 4px;
  font-size: 0.95rem;
}

.rule-card span {
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.45;
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  min-height: 54px;
  padding: 0 20px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 17px;
  font-weight: 850;
  cursor: pointer;
  transition:
    transform 190ms cubic-bezier(0.34, 1.42, 0.64, 1),
    box-shadow 190ms ease,
    background 160ms ease,
    opacity 160ms ease;
}

.primary-button {
  border: 1px solid var(--forest);
  color: white;
  background: var(--forest);
  box-shadow: 0 9px 18px rgba(18, 61, 50, 0.2);
}

.primary-button svg,
.secondary-button svg,
.danger-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary-button:active,
.secondary-button:active,
.danger-button:active {
  transform: translateY(1px) scale(0.975);
  transition-duration: 70ms;
}

.primary-button:active {
  box-shadow: 0 4px 10px rgba(18, 61, 50, 0.22);
}

.primary-button:disabled {
  border-color: #9aa9a3;
  background: #9aa9a3;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.74;
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--forest);
  background: var(--paper-strong);
}

.danger-button {
  border: 1px solid rgba(200, 77, 60, 0.24);
  color: var(--red);
  background: var(--red-soft);
}

.full-width {
  width: 100%;
}

.setup-submit {
  margin-top: 22px;
}

.form-error {
  display: none;
  margin: 12px 0 0;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  color: #8d3025;
  background: var(--red-soft);
  font-size: 0.82rem;
  font-weight: 750;
  line-height: 1.4;
}

.form-error.is-visible {
  display: block;
}

.game-layout {
  display: grid;
  gap: 14px;
}

.standings {
  padding: 16px 16px 6px;
  border-radius: var(--radius-lg);
  background: var(--paper-strong);
  box-shadow: var(--shadow-sm);
}

.standings__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.standings__header h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.standings__header span {
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 700;
}

.standings__list {
  margin-top: 4px;
}

.standings__row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: 47px;
  border-bottom: 1px solid var(--line);
}

.standings__row:last-child {
  border-bottom: 0;
}

.standings__rank {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 900;
}

.standings__row.is-leader .standings__rank {
  color: #a87b12;
}

.standings__name {
  overflow: hidden;
  font-size: 0.9rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.standings__hits {
  color: var(--ink-soft);
  font-size: 0.7rem;
}

.standings__score {
  min-width: 44px;
  color: var(--forest);
  text-align: right;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.18rem;
  font-weight: 700;
}

.game-card {
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--paper-strong);
  box-shadow: var(--shadow-md);
}

.round-header {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--line);
}

.round-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 13px;
}

.round-chip,
.dealer-chip {
  display: inline-flex;
  min-height: 28px;
  padding: 0 10px;
  align-items: center;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 820;
}

.round-chip {
  color: var(--forest);
  background: var(--forest-light);
}

.dealer-chip {
  color: var(--ink-soft);
  background: var(--paper-muted);
}

.round-heading {
  margin: 12px 0 0;
  font-size: clamp(1.75rem, 7vw, 2.3rem);
}

.round-sub {
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
  line-height: 1.45;
}

.phase-steps {
  display: flex;
  gap: 7px;
  margin-top: 13px;
}

.phase-step {
  display: inline-flex;
  min-height: 30px;
  padding: 0 12px;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  background: var(--paper-strong);
  font-size: 0.73rem;
  font-weight: 820;
}

.phase-step.is-active {
  border-color: var(--forest);
  color: #fff;
  background: var(--forest);
}

.phase-step.is-done {
  border-color: rgba(33, 113, 91, 0.35);
  color: var(--success);
  background: var(--success-soft);
}

.progress-track {
  height: 5px;
  margin-top: 17px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--paper-muted);
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--gold);
  transition: width 220ms ease;
}

.round-content {
  padding: 17px 14px 18px;
}

.score-entry-list {
  display: grid;
  gap: 9px;
}

.score-entry {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    box-shadow 150ms ease;
}

.score-entry.is-open {
  border-color: var(--forest);
  box-shadow: 0 0 0 2px rgba(18, 61, 50, 0.14);
}

.score-entry.is-hit {
  border-color: rgba(33, 113, 91, 0.3);
  background: var(--success-soft);
}

.score-entry__row {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 12px 14px;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 180ms ease;
}

.score-entry__row:active {
  background: rgba(18, 61, 50, 0.055);
  transition-duration: 60ms;
}

.score-entry__who {
  min-width: 0;
}

.score-entry__name {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  font-size: 1.04rem;
  font-weight: 850;
}

.score-entry__name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hit-flag {
  flex: 0 0 auto;
  display: inline-flex;
  min-height: 22px;
  padding: 0 8px;
  align-items: center;
  border-radius: 999px;
  color: var(--success);
  background: rgba(255, 255, 255, 0.8);
  font-size: 0.66rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.score-entry__meta {
  display: block;
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 0.76rem;
}

.score-entry__value {
  display: grid;
  min-width: 56px;
  height: 52px;
  padding: 0 12px;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  background: var(--forest);
  font-size: 1.45rem;
  font-weight: 900;
}

.score-entry__value.is-empty {
  color: var(--ink-soft);
  background: var(--paper-muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.number-pad {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 7px;
  padding: 2px 14px 14px;
}

.number-pad__key {
  display: grid;
  height: 54px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--ink);
  background: var(--paper);
  font-size: 1.2rem;
  font-weight: 850;
  cursor: pointer;
  transition:
    transform 210ms cubic-bezier(0.34, 1.5, 0.64, 1),
    border-color 150ms ease,
    color 150ms ease,
    background 150ms ease,
    box-shadow 150ms ease;
}

.number-pad__key:active {
  border-color: rgba(18, 61, 50, 0.3);
  background: var(--paper-muted);
  transform: scale(0.9);
  transition-duration: 60ms;
}

.number-pad__key.is-selected {
  border-color: var(--forest);
  color: #fff;
  background: var(--forest);
  box-shadow: 0 7px 15px rgba(18, 61, 50, 0.2);
}

.sum-hint {
  margin: 13px 2px 0;
  padding: 11px 14px;
  border-radius: 13px;
  color: var(--ink-soft);
  background: var(--paper-muted);
  font-size: 0.79rem;
  line-height: 1.45;
}

.sum-hint strong {
  color: var(--ink);
}

.sum-hint--ok {
  color: var(--success);
  background: var(--success-soft);
}

.sum-hint--ok strong {
  color: inherit;
}

.sum-hint--warn {
  color: #7c5410;
  background: var(--gold-soft);
}

.sum-hint--warn strong {
  color: inherit;
}

.bottom-action {
  position: sticky;
  bottom: 0;
  z-index: 3;
  margin: 0 -2px -2px;
  padding: 14px 2px 2px;
  background: linear-gradient(180deg, rgba(255, 253, 247, 0), var(--paper-strong) 30%);
}

.summary-stage {
  padding: 24px 18px 20px;
}

.summary-stage__icon {
  display: grid;
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  place-items: center;
  border-radius: 50%;
  color: var(--success);
  background: var(--success-soft);
}

.summary-stage__icon svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.summary-stage h2,
.summary-stage > p {
  text-align: center;
}

.summary-stage h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.7rem;
  letter-spacing: -0.025em;
}

.summary-stage > p {
  margin: 7px auto 20px;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.round-points {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.round-point-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: 55px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 15px;
}

.round-point-row__name {
  overflow: hidden;
  font-size: 0.88rem;
  font-weight: 820;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.round-point-row__result {
  color: var(--ink-soft);
  font-size: 0.74rem;
}

.round-point-row__score {
  min-width: 45px;
  color: var(--success);
  text-align: right;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.22rem;
  font-weight: 700;
}

.summary-actions,
.winner-actions {
  display: grid;
  gap: 9px;
}

.winner-hero {
  position: relative;
  overflow: hidden;
  padding: 34px 22px 30px;
  color: white;
  text-align: center;
  background: var(--forest-deep);
}

.winner-hero::before,
.winner-hero::after {
  position: absolute;
  width: 8px;
  height: 45px;
  border-radius: 4px;
  background: var(--gold);
  content: "";
  transform: rotate(24deg);
}

.winner-hero::before {
  top: 24px;
  left: 10%;
}

.winner-hero::after {
  right: 11%;
  bottom: 21px;
  background: var(--red);
  transform: rotate(-28deg);
}

.trophy {
  display: grid;
  width: 72px;
  height: 72px;
  margin: 0 auto 14px;
  place-items: center;
  border: 1px solid rgba(212, 166, 63, 0.4);
  border-radius: 50%;
  color: var(--gold);
  background: rgba(212, 166, 63, 0.12);
}

.trophy svg {
  width: 38px;
  height: 38px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.winner-hero .eyebrow {
  color: var(--gold);
}

.winner-hero h1 {
  margin-inline: auto;
}

.winner-hero p:not(.eyebrow) {
  margin: 8px 0 0;
  color: rgba(255, 255, 255, 0.68);
}

.final-ranking {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.final-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 62px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 17px;
}

.final-row--winner {
  border-color: rgba(212, 166, 63, 0.42);
  background: var(--gold-soft);
}

.final-row__rank {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: var(--forest);
  background: var(--forest-light);
  font-size: 0.77rem;
  font-weight: 900;
}

.final-row--winner .final-row__rank {
  background: rgba(255, 255, 255, 0.74);
}

.final-row__name strong,
.final-row__name span {
  display: block;
}

.final-row__name strong {
  overflow: hidden;
  font-size: 0.91rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.final-row__name span {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 0.7rem;
}

.final-row__score {
  color: var(--forest);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.42rem;
  font-weight: 700;
}

.dialog {
  width: min(calc(100% - 28px), 520px);
  max-height: min(82dvh, 720px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 24px;
  color: var(--ink);
  background: var(--paper-strong);
  box-shadow: 0 28px 80px rgba(4, 25, 20, 0.36);
}

.dialog::backdrop {
  background: rgba(5, 28, 22, 0.65);
  backdrop-filter: blur(5px);
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.955);
  }
}

@keyframes dialog-out {
  to {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }
}

@keyframes backdrop-out {
  to {
    opacity: 0;
  }
}

.dialog[open] {
  animation: dialog-in 330ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.dialog[open]::backdrop {
  animation: backdrop-in 330ms ease both;
}

.dialog[open].is-closing {
  animation: dialog-out 200ms cubic-bezier(0.4, 0, 0.9, 0.4) both;
}

.dialog[open].is-closing::backdrop {
  animation: backdrop-out 200ms ease both;
}

.dialog__inner {
  display: flex;
  max-height: min(82dvh, 720px);
  flex-direction: column;
}

.dialog__header {
  display: flex;
  padding: 18px 18px 13px 20px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.dialog__header h2 {
  margin-top: 5px;
  font-size: 1.45rem;
}

.dialog__content {
  overflow-y: auto;
  padding: 16px 18px 20px;
}

.dialog-menu {
  display: grid;
  gap: 8px;
}

.menu-button {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  min-height: 64px;
  padding: 9px 10px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: white;
  text-align: left;
  cursor: pointer;
  transition:
    transform 190ms cubic-bezier(0.34, 1.42, 0.64, 1),
    border-color 160ms ease,
    background 160ms ease;
}

.menu-button:active {
  border-color: rgba(18, 61, 50, 0.28);
  background: var(--paper);
  transform: scale(0.982);
  transition-duration: 70ms;
}

.menu-button__icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 12px;
  color: var(--forest);
  background: var(--forest-light);
}

.menu-button__icon svg,
.menu-button > svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.menu-button > svg {
  color: var(--ink-soft);
}

.menu-button strong,
.menu-button span {
  display: block;
}

.menu-button strong {
  font-size: 0.87rem;
}

.menu-button span {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 0.7rem;
}

.menu-button--danger .menu-button__icon {
  color: var(--red);
  background: var(--red-soft);
}

.dialog-note {
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.5;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 16px;
}

.history-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 15px;
}

.history-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.76rem;
}

.history-table th,
.history-table td {
  min-width: 104px;
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.history-table th:first-child,
.history-table td:first-child {
  min-width: 84px;
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--paper-strong);
}

.history-table th {
  color: var(--ink-soft);
  background: var(--paper);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.history-table tr:last-child td {
  border-bottom: 0;
}

.history-score {
  color: var(--success);
  font-weight: 850;
}

.history-miss {
  color: var(--ink-soft);
}

.rules-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rules-list li {
  position: relative;
  padding: 12px 12px 12px 42px;
  border-radius: 14px;
  background: var(--paper);
  font-size: 0.82rem;
  line-height: 1.45;
}

.rules-list li::before {
  position: absolute;
  top: 11px;
  left: 12px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--forest);
  content: counter(list-item);
  font-size: 0.68rem;
  font-weight: 900;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 16px;
  z-index: 20;
  width: fit-content;
  max-width: min(420px, calc(100% - 32px));
  min-height: 48px;
  margin: 0 auto;
  padding: 13px 17px;
  border-radius: 14px;
  color: white;
  background: var(--forest-deep);
  box-shadow: var(--shadow-md);
  font-size: 0.82rem;
  font-weight: 750;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.96);
  transition:
    opacity 230ms ease,
    transform 460ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

.empty-state {
  padding: 22px 10px;
  color: var(--ink-soft);
  text-align: center;
  font-size: 0.83rem;
}

.noscript {
  margin: 40px auto;
  padding: 20px;
  color: white;
  text-align: center;
}

/* Näkymänvaihdot: app.js kuvaa vanhan ja uuden tilan View Transitions -rajapinnalla.
   Nimetyt ryhmät (pelaajarivit, pistetaulukon rivit, edistymispalkki) venyvät ja
   liukuvat paikoilleen, muu sisältö ristihäivytetään. Kestot pidetään lyhyinä, koska
   selain ohittaa osumatunnistuksen siirtymän ajan. */
::view-transition {
  pointer-events: none;
}

::view-transition-group(*) {
  overflow: clip;
  animation-duration: 260ms;
  animation-timing-function: cubic-bezier(0.32, 0.72, 0, 1);
}

::view-transition-group(root) {
  overflow: visible;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 200ms;
  animation-timing-function: ease;
}

html[data-transition="page"]::view-transition-old(root) {
  animation: view-fade-out 140ms ease both;
}

html[data-transition="page"]::view-transition-new(root) {
  animation: view-page-in 260ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes view-fade-out {
  to {
    opacity: 0;
  }
}

@keyframes view-page-in {
  from {
    opacity: 0;
    transform: translateY(11px);
  }
}

/* Kertakäyttöinen kuittaus juuri merkitylle riville: luokka on olemassa vain siinä
   piirrossa, jossa numero valittiin, joten animaatio ei toistu myöhemmillä
   piirroilla. */
.score-entry.is-just-set .score-entry__value {
  animation: value-pop 330ms cubic-bezier(0.22, 1.2, 0.36, 1);
}

.score-entry.is-just-set .hit-flag {
  animation: flag-pop 380ms cubic-bezier(0.22, 1.3, 0.36, 1);
}

@keyframes value-pop {
  0% {
    opacity: 0.35;
    transform: scale(0.74);
  }

  55% {
    transform: scale(1.08);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes flag-pop {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }

  60% {
    transform: scale(1.12);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@media (min-width: 600px) {
  .app-shell {
    padding-inline: 24px;
  }

  .content,
  .round-content,
  .summary-stage {
    padding-inline: 26px;
  }

  .hero {
    padding: 38px 32px 32px;
  }

  .setup-grid {
    grid-template-columns: 1fr 1fr;
  }

  .setup-grid .field:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .round-points {
    grid-template-columns: 1fr 1fr;
  }

  .summary-actions,
  .winner-actions {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 390px) {
  .app-shell {
    padding-inline: 11px;
  }

  .brand__text strong {
    font-size: 1.4rem;
  }

  .brand__mark {
    width: 38px;
    height: 44px;
  }

  .content {
    padding-inline: 14px;
  }

  .score-entry__row {
    gap: 8px;
    padding-inline: 11px;
  }

  .number-pad {
    padding-inline: 11px;
    grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  }

  .number-pad__key {
    height: 48px;
  }
}

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

  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}
