@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=Manrope:wght@500;600&display=swap");

:root {
  --paper: #f4f2ed;
  --surface: #fbfaf7;
  --ink: #1e2521;
  --muted: #747872;
  --line: #dcd9d1;
  --line-dark: #c7c3ba;
  --green: #23372d;
  --green-soft: #dfe6df;
  --red: #9b4139;
  --shadow: 0 24px 70px rgba(31, 39, 34, .08);
  --radius: 18px;
  --sans: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --display: "Manrope", var(--sans);
}

* { box-sizing: border-box; }

html { color-scheme: light; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 84% 8%, rgba(222, 226, 214, .65), transparent 26rem),
    var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button { color: inherit; }

.shell { width: min(1180px, calc(100% - 48px)); margin-inline: auto; }
.shell.narrow { width: min(760px, calc(100% - 32px)); }

.site-header {
  height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  font: 600 17px/1 var(--display);
  text-decoration: none;
  letter-spacing: -.03em;
}

.text-link, .text-button {
  border: 0;
  padding: 0;
  color: var(--muted);
  background: none;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: color .2s ease;
}
.text-link:hover, .text-button:hover { color: var(--ink); }
.is-hidden { display: none !important; }

.hero {
  min-height: 610px;
  padding: 78px 0 86px;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 10%;
  align-items: center;
}

.eyebrow {
  margin: 0 0 18px;
  color: #657068;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.hero h1, .game-heading h1, .manage-heading h1, .access-card h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 500;
  letter-spacing: -.055em;
}

.hero h1 { max-width: 630px; font-size: clamp(46px, 6vw, 76px); line-height: .99; }
.hero h1 em { color: #66736a; font-family: Georgia, serif; font-weight: 400; }

.hero-description {
  max-width: 520px;
  margin: 28px 0 32px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.65;
}

.button {
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, border-color .18s ease, opacity .18s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:active:not(:disabled) { transform: translateY(0); }
.button:disabled { cursor: not-allowed; opacity: .48; }
.button-primary { color: #f9f8f4; background: var(--green); }
.button-primary:hover:not(:disabled) { background: #192b22; }
.button-secondary { border-color: var(--line); background: rgba(255,255,255,.38); }
.button-secondary:hover:not(:disabled) { border-color: var(--line-dark); background: var(--surface); }
.button-danger { border-color: #e3c5c1; color: var(--red); background: #fbf4f2; }
.button-large { min-height: 54px; padding-inline: 23px; }
.button-small { min-height: 38px; padding-inline: 14px; font-size: 12px; border-radius: 10px; }
.button-block { width: 100%; }
.microcopy { margin: 13px 0 0; color: #8a8c87; font-size: 11px; }

.score-preview {
  padding: 27px;
  border: 1px solid rgba(205, 202, 194, .8);
  border-radius: 24px;
  background: rgba(251, 250, 247, .78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  transform: rotate(.7deg);
  animation: settle .7s cubic-bezier(.2,.8,.2,1) both;
}

@keyframes settle {
  from { opacity: 0; transform: translateY(18px) rotate(1.5deg); }
}

.preview-top, .preview-foot, .section-heading, .game-heading, .manage-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.preview-top { margin-bottom: 23px; }
.preview-top > div { display: grid; gap: 5px; }
.preview-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.preview-top strong { font: 600 21px/1.2 var(--display); letter-spacing: -.03em; }
.live-dot { color: #647267; font-size: 11px; }
.live-dot::before { content: ""; width: 6px; height: 6px; display: inline-block; margin-right: 7px; border-radius: 50%; background: #6a816f; }

.preview-player, .score-row {
  min-height: 66px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 32px 38px 1fr auto;
  gap: 12px;
  align-items: center;
}
.preview-player:first-child { border-top: 0; }
.place, .rank { color: #a0a19c; font-size: 10px; letter-spacing: .08em; }
.avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #4b5b51;
  background: var(--green-soft);
  font-size: 12px;
  font-weight: 600;
}
.player-name, .score-name { font-size: 14px; }
.player-name small, .score-name small { margin-left: 7px; color: #9a5d57; font-size: 8px; letter-spacing: .1em; }
.preview-player strong, .score-row > strong { font: 600 22px/1 var(--display); letter-spacing: -.04em; }
.preview-player.out { color: #92938e; }
.preview-player.out .avatar { color: #898a85; background: #e8e6e0; }
.preview-foot { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); color: #898b85; font-size: 10px; }

.principles {
  padding: 40px 0 76px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7%;
}
.principles article { display: grid; grid-template-columns: 30px 1fr; }
.principles article > span { grid-row: 1 / 3; padding-top: 4px; color: #9a9b96; font-size: 9px; }
.principles h2 { margin: 0 0 7px; font: 600 14px/1.3 var(--display); }
.principles p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.site-footer { min-height: 88px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; color: #8b8d87; font-size: 11px; }
.creator-credit { color: inherit; text-decoration: none; transition: color .18s ease; }
.creator-credit:hover { color: var(--ink); }

.modal {
  width: min(450px, calc(100% - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  border: 0;
  border-radius: 22px;
  color: var(--ink);
  background: transparent;
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(26, 32, 28, .34); backdrop-filter: blur(5px); }
.modal[open] { animation: modal-in .22s ease-out both; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.modal-card { position: relative; padding: 34px; background: var(--surface); }
.modal-card.compact { padding-bottom: 28px; }
.modal-card h2 { margin: 0 0 8px; font: 600 28px/1.2 var(--display); letter-spacing: -.04em; }
.modal-close { position: absolute; top: 18px; right: 18px; }
.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}
.field { margin: 24px 0 0; display: grid; gap: 8px; }
.field > span { font-size: 12px; font-weight: 600; }
.field input {
  width: 100%;
  height: 49px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  color: var(--ink);
  background: white;
  transition: border-color .18s, box-shadow .18s;
}
.field input:focus { border-color: #738078; box-shadow: 0 0 0 3px rgba(85, 106, 93, .11); }
.field small { color: var(--muted); font-size: 10px; line-height: 1.4; }
.modal-card .button-block { margin-top: 26px; }
.form-error { min-height: 17px; margin: 12px 0 -12px; color: var(--red); font-size: 11px; }
.muted { color: var(--muted); }

.page-main { min-height: calc(100vh - 174px); padding: 54px 0 80px; }
.loading-state { min-height: 60vh; display: grid; place-content: center; justify-items: center; color: var(--muted); font-size: 12px; }
.loader { width: 22px; height: 22px; border: 2px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.connection-status { color: #66746a; font-size: 11px; }
.connection-status i { width: 6px; height: 6px; margin-right: 7px; display: inline-block; border-radius: 50%; background: #6d8b75; animation: pulse 2s infinite; }
.connection-status.offline { color: var(--red); }
.connection-status.offline i { background: var(--red); animation: none; }
.connection-status.finished { color: var(--muted); }
.connection-status.finished i { background: #92958f; animation: none; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(109,139,117,0); } 0%,100% { box-shadow: 0 0 0 0 rgba(109,139,117,.22); } }

.game-heading, .manage-heading { align-items: flex-end; margin-bottom: 30px; }
.game-heading h1, .manage-heading h1 { font-size: clamp(35px, 7vw, 48px); }
.game-heading .muted, .manage-heading .muted { margin: 10px 0 0; font-size: 12px; }
.scoreboard-card, .access-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(251,250,247,.75);
  box-shadow: 0 15px 45px rgba(31,39,34,.045);
}
.scoreboard-card { padding: 8px 24px 12px; }
.section-heading { min-height: 62px; }
.section-heading > div { display: flex; align-items: baseline; gap: 12px; }
.section-heading h2 { margin: 0; font: 600 14px/1 var(--display); }
.section-heading > span, .section-heading div > span { color: var(--muted); font-size: 10px; }
.score-row { min-height: 70px; }
.score-row.is-out { color: #90918c; }
.score-row.is-out .avatar { color: #878984; background: #e8e6e0; }
.score-list.editable .score-row { grid-template-columns: 32px 38px 1fr auto 26px; }
.row-menu { border: 0; padding: 5px; color: #9a9c96; background: none; cursor: pointer; letter-spacing: .08em; }

.score-table-wrap {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line-dark) transparent;
}
.score-table {
  width: 100%;
  min-width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}
.score-table th,
.score-table td {
  height: 58px;
  min-width: 58px;
  padding: 0 14px;
  border-top: 1px solid var(--line);
  text-align: center;
  white-space: nowrap;
}
.score-table thead th {
  height: 39px;
  border-top: 0;
  color: #92958f;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.round-header-button {
  min-width: 34px;
  min-height: 30px;
  padding: 0 7px;
  border: 0;
  border-radius: 8px;
  color: inherit;
  background: transparent;
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  transition: color .18s ease, background .18s ease;
}
.round-header-button:hover,
.round-header-button:focus-visible {
  color: var(--ink);
  background: var(--green-soft);
  outline: none;
}
.score-table th:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 165px;
  padding-left: 0;
  text-align: left;
  background: #f9f8f4;
}
.score-table thead th:first-child { z-index: 3; }
.score-table tbody th {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}
.score-table tbody th small {
  margin-left: 5px;
  color: #9a5d57;
  font-size: 8px;
  letter-spacing: .1em;
}
.score-table tbody td { color: #656a66; font-variant-numeric: tabular-nums; }
.score-table .total-column {
  position: sticky;
  right: 0;
  z-index: 2;
  min-width: 72px;
  border-left: 1px solid var(--line);
  background: #f1f2ed;
}
.score-table thead .total-column { z-index: 3; }
.score-table .total-column strong {
  color: var(--ink);
  font: 600 17px/1 var(--display);
  letter-spacing: -.03em;
}
.score-table tr.is-out { color: #92938e; }
.score-table tr.is-out th:first-child,
.score-table tr.is-out .total-column { background: #f1f0eb; }
.score-table tr.is-out .avatar { color: #878984; background: #e8e6e0; }

.winner-card {
  min-height: 100px;
  margin-bottom: 18px;
  padding: 20px 24px;
  border: 1px solid #cdd6cd;
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 14px;
  background: #e9eee8;
}
.winner-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--green); }
.winner-card .eyebrow { margin-bottom: 5px; }
.winner-card h2 { margin: 0; font: 600 20px/1.2 var(--display); letter-spacing: -.03em; }
.winner-card > strong { font: 600 27px/1 var(--display); }

.empty-state { min-height: 190px; display: grid; place-content: center; justify-items: center; text-align: center; }
.empty-state p, .empty-state strong { margin: 0 0 6px; }
.empty-state span, .empty-state small { color: var(--muted); font-size: 11px; }
.empty-button { width: 100%; border: 0; border-top: 1px solid var(--line); background: none; cursor: pointer; }
.empty-plus { width: 37px; height: 37px; margin-bottom: 13px; border: 1px solid var(--line); border-radius: 50%; display: grid; place-items: center; color: var(--ink) !important; font-size: 20px !important; }
.page-error h1 { margin: 0 0 8px; font: 600 35px/1.2 var(--display); letter-spacing: -.04em; }
.page-error .button { margin-top: 22px; }

.last-updated { margin: 23px 0 0; text-align: center; color: #979993; font-size: 10px; }

.access-card { width: min(440px, 100%); margin: 44px auto; padding: 36px; }
.access-card h1 { font-size: 36px; line-height: 1.1; }
.access-card > .muted { margin: 15px 0 30px; font-size: 13px; line-height: 1.6; }
.access-card .field { margin-top: 18px; }
.access-foot { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.access-foot a { color: var(--ink); font-weight: 600; }

.settings-button { font-size: 11px; letter-spacing: .08em; }
.share-strip {
  min-height: 70px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,.3);
}
.share-strip > div { display: flex; align-items: center; gap: 12px; }
.share-strip p { margin: 0; display: grid; gap: 4px; font-size: 11px; }
.share-strip small { color: var(--muted); font-size: 9px; }
.share-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--green-soft); }
.add-round-button { margin-top: 14px; min-height: 52px; justify-content: space-between; padding-inline: 20px; }
.danger-text { color: var(--red); }

.round-inputs { margin-top: 18px; border-top: 1px solid var(--line); }
.score-input-row { min-height: 61px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 36px 1fr 84px; gap: 11px; align-items: center; }
.score-input-row > span:nth-child(2) { display: grid; font-size: 12px; }
.score-input-row small { color: var(--red); font-size: 8px; text-transform: uppercase; }
.score-input-row input { width: 84px; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; outline: none; text-align: right; background: white; }
.score-input-row input:focus { border-color: #738078; }
.score-input-row.disabled { opacity: .48; }
.danger-zone { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--line); }
.danger-zone p { font-size: 11px; line-height: 1.5; }
.danger-zone .button { margin-top: 10px; }
.remove-player { width: 100%; margin-top: 17px; text-align: center; }
.remove-round { width: 100%; margin-top: 17px; text-align: center; }
.toast { position: fixed; left: 50%; bottom: 25px; padding: 11px 16px; border-radius: 10px; opacity: 0; pointer-events: none; color: white; background: var(--ink); font-size: 11px; transform: translate(-50%, 12px); transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.is-saving { cursor: progress; }

@media (max-width: 760px) {
  .shell { width: min(100% - 32px, 600px); }
  .site-header { height: 72px; }
  .hero { min-height: 0; padding: 64px 0 68px; grid-template-columns: 1fr; gap: 70px; }
  .hero-copy { text-align: center; }
  .hero-description { margin-inline: auto; }
  .score-preview { width: min(100%, 470px); margin-inline: auto; padding: 20px; transform: none; }
  .principles { grid-template-columns: 1fr; gap: 28px; padding: 34px 8px 56px; }
  .site-footer { min-height: 76px; }
  .page-main { padding-top: 34px; }
}

@media (max-width: 480px) {
  .shell.narrow { width: calc(100% - 24px); }
  .hero h1 { font-size: 45px; }
  .hero-description { font-size: 15px; }
  .score-preview { border-radius: 18px; }
  .modal-card { padding: 28px 22px; }
  .modal-close { top: 14px; right: 14px; }
  .game-heading, .manage-heading { align-items: flex-start; }
  .game-heading h1, .manage-heading h1 { font-size: 36px; }
  .scoreboard-card { padding-inline: 15px; }
  .score-row { grid-template-columns: 25px 34px 1fr auto; gap: 9px; }
  .score-list.editable .score-row { grid-template-columns: 25px 34px 1fr auto 24px; }
  .access-card { margin-top: 20px; padding: 28px 22px; }
  .share-strip small { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .winner-card { grid-template-columns: 36px 1fr auto; padding-inline: 16px; }
}

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