:root {
  color-scheme: dark;
  --felt: #0f4c3a;
  --felt-dark: #08261f;
  --felt-light: #1a775a;
  --gold: #f7c948;
  --red: #f87171;
  --card: rgba(255, 255, 255, 0.09);
  --card-strong: rgba(255, 255, 255, 0.14);
  --text: #f7fbf9;
  --muted: #b9d1c8;
  --border: rgba(255, 255, 255, 0.16);
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(247, 201, 72, 0.18), transparent 32rem),
    radial-gradient(circle at bottom right, rgba(26, 119, 90, 0.5), transparent 28rem),
    linear-gradient(145deg, #061814, #0f4c3a 52%, #051511);
}

button, input, select, textarea {
  font: inherit;
}

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

.app-shell,
.login-screen {
  width: min(100%, 780px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(28px, env(safe-area-inset-bottom));
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-screen[hidden],
.app-shell[hidden] {
  display: none;
}

.login-card {
  display: grid;
  gap: 16px;
  width: 100%;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 32px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: end;
  padding: 18px 4px 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 8px;
  font-size: clamp(4rem, 24vw, 7rem);
  line-height: 0.78;
  letter-spacing: -0.08em;
}

h2 {
  margin-bottom: 0;
  font-size: 1.08rem;
}

.subtitle {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.total-card, .card, .score-card {
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.total-card {
  min-width: 86px;
  padding: 13px 12px;
  border-radius: 24px;
  text-align: center;
}

.total-card span {
  display: block;
  font-size: 2rem;
  font-weight: 900;
}

.total-card small {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card {
  margin-top: 14px;
  padding: 16px;
  border-radius: 28px;
}

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

.player-inputs {
  display: grid;
  gap: 10px;
}

.player-inputs label,
.match-form label,
.login-card label,
.match-selectors label,
.add-player-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

input, select, textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 18px;
  color: var(--text);
  background: rgba(1, 14, 11, 0.55);
  padding: 12px 14px;
  outline: none;
}

textarea { resize: vertical; }

input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(247, 201, 72, 0.16);
}

.tab-menu {
  position: sticky;
  top: 8px;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 8px 0 14px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(4, 22, 17, 0.82);
  backdrop-filter: blur(18px);
}

.tab-button {
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 0.88rem;
  font-weight: 900;
}

.tab-button.active {
  color: #062017;
  background: var(--gold);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.score-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 14px;
}

.score-card {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border-radius: 28px;
}

.score-card::after {
  content: "";
  position: absolute;
  right: -38px;
  top: -38px;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.player-name {
  color: var(--muted);
  font-weight: 800;
}

.record {
  margin: 8px 0 4px;
  font-size: 2rem;
  font-weight: 950;
  letter-spacing: -0.04em;
}

.win-rate {
  color: var(--gold);
  font-weight: 800;
}

.match-form {
  display: grid;
  gap: 13px;
}

.score-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.match-selectors {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.add-player-form {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.quick-buttons {
  display: grid;
  gap: 14px;
}

.win-button {
  display: grid;
  gap: 4px;
  min-height: 132px;
  place-items: center;
  border: 0;
  border-radius: 32px;
  color: #062017;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.28);
  font-weight: 950;
}

.win-button span {
  font-size: clamp(2rem, 11vw, 4rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
}

.win-button small {
  font-size: 0.95rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.win-button-primary {
  background: linear-gradient(135deg, var(--gold), #fff3a3);
}

.win-button-secondary {
  color: var(--text);
  background: linear-gradient(135deg, #54d6a3, var(--felt-light));
}

.settings-card summary {
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
}

.settings-inner {
  display: grid;
  gap: 12px;
  padding-top: 14px;
}

.wide-button {
  width: 100%;
}

.primary-button, .ghost-button, .delete-button {
  border: 0;
  border-radius: 999px;
  font-weight: 900;
}

.primary-button {
  min-height: 54px;
  color: #062017;
  background: linear-gradient(135deg, var(--gold), #fff3a3);
  box-shadow: 0 12px 22px rgba(247, 201, 72, 0.22);
}

.ghost-button {
  min-height: 38px;
  padding: 0 12px;
  color: var(--text);
  background: var(--card-strong);
}

.status {
  min-height: 1.1em;
  color: var(--gold);
  font-size: 0.85rem;
  font-weight: 700;
  text-align: right;
}

.period-stats,
.game-stats {
  display: grid;
  gap: 10px;
}

.game-stats {
  margin-top: 12px;
}

.subsection-title {
  margin: 18px 0 10px;
}

.game-stat-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(0, 0, 0, 0.18);
}

.game-stat-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 10px;
}

.game-stat-header h3 {
  margin: 0;
  font-size: 1rem;
}

.game-stat-header span {
  color: var(--gold);
  font-size: 0.9rem;
  font-weight: 900;
}

.game-player-stats {
  display: grid;
  gap: 8px;
}

.game-player-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.game-player-row strong {
  color: var(--text);
}

.compact-select {
  min-height: 40px;
  width: auto;
  min-width: 130px;
  border-radius: 999px;
}

.period-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(0, 0, 0, 0.18);
}

.period-title {
  font-weight: 950;
}

.period-players {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.period-total {
  min-width: 48px;
  min-height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #062017;
  background: var(--gold);
  font-size: 1.25rem;
  font-weight: 950;
}

.matches {
  display: grid;
  gap: 10px;
}

.match-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(0, 0, 0, 0.18);
}

.match-title {
  font-weight: 900;
}

.match-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.35;
}

.match-notes {
  display: none;
  margin: 8px 0 0;
  color: #dbece6;
  line-height: 1.4;
}

.match-notes:not(:empty) {
  display: block;
}

.delete-button {
  width: 36px;
  height: 36px;
  color: white;
  background: rgba(248, 113, 113, 0.22);
  font-size: 1.45rem;
  line-height: 1;
}

.empty-state {
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

@media (min-width: 620px) {
  .app-shell { padding-inline: 22px; }
  .score-grid, .player-inputs, .quick-buttons { grid-template-columns: 1fr 1fr; }
  .match-selectors { grid-template-columns: 0.75fr 1fr 1fr; }
}
