:root {
  color-scheme: dark;
  --bg: #07100d;
  --felt: #0d2f27;
  --felt-2: #103c32;
  --panel: rgba(250, 247, 238, 0.96);
  --panel-dark: rgba(9, 19, 16, 0.74);
  --ink: #111813;
  --ink-light: #f7f2e6;
  --muted: #6c756f;
  --muted-light: #aab8b0;
  --line: rgba(255, 255, 255, 0.13);
  --line-dark: rgba(18, 28, 22, 0.12);
  --gold: #d2a44d;
  --gold-dark: #8b611f;
  --green: #2aa77f;
  --green-dark: #0a4f42;
  --red: #c4574a;
  --red-dark: #8f2f27;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 12%, rgba(210, 164, 77, 0.18), transparent 28%),
    linear-gradient(135deg, rgba(42, 167, 127, 0.2), transparent 36%),
    linear-gradient(180deg, #08120f, var(--bg));
  color: var(--ink-light);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 46px;
  border: 1px solid var(--line-dark);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 850;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(11, 44, 36, 0.13);
}

button:active {
  transform: translateY(0);
}

input {
  width: 100%;
  min-height: 52px;
  border: 1px solid rgba(17, 24, 19, 0.15);
  border-radius: 8px;
  padding: 0 14px;
  background: #fffdf8;
  color: var(--ink);
  font-weight: 900;
  outline: none;
}

input::placeholder {
  color: #9a9489;
  font-weight: 650;
}

input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(42, 167, 127, 0.16);
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 850;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.78fr);
  gap: 16px;
}

.scoreboard {
  position: relative;
  grid-column: 1 / -1;
  min-height: 390px;
  padding: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.08), transparent 36%),
    linear-gradient(180deg, var(--felt-2), var(--felt));
  box-shadow: var(--shadow);
}

.scoreboard::after {
  content: "";
  position: absolute;
  inset: 18px;
  pointer-events: none;
  border: 1px solid rgba(210, 164, 77, 0.22);
  border-radius: 8px;
}

.back-link {
  position: relative;
  z-index: 1;
  width: fit-content;
  display: inline-flex;
  margin-bottom: 22px;
  color: rgba(247, 242, 230, 0.78);
  font-size: 0.88rem;
  font-weight: 850;
  text-decoration: none;
}

.scoreboard-top {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 178px;
  gap: 18px;
  align-items: start;
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 0.75rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
.lead {
  margin: 0;
}

h1 {
  color: var(--ink-light);
  font-size: clamp(3.2rem, 9vw, 7.8rem);
  line-height: 0.9;
  letter-spacing: 0;
}

h2 {
  color: var(--ink);
  font-size: 1.36rem;
  line-height: 1.1;
}

.lead {
  max-width: 640px;
  margin-top: 12px;
  color: var(--muted-light);
  line-height: 1.75;
  font-weight: 750;
}

.target-control {
  padding: 14px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.target-control label {
  color: var(--muted-light);
}

.teams {
  position: relative;
  z-index: 1;
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.team-card {
  min-width: 0;
  padding: 20px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(16px);
}

.team-label,
.team-card small {
  display: block;
  color: rgba(247, 242, 230, 0.76);
  font-weight: 950;
}

.team-label {
  font-size: 1.05rem;
}

.team-card strong {
  display: block;
  margin: 12px 0;
  font-size: clamp(4.5rem, 13vw, 9.2rem);
  line-height: 0.86;
  letter-spacing: 0;
}

.ours strong {
  color: #9ff0d1;
}

.theirs strong {
  color: #ffb1a8;
}

.winner {
  position: relative;
  z-index: 1;
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(210, 164, 77, 0.42);
  border-radius: 8px;
  background: rgba(210, 164, 77, 0.16);
  color: #ffe3a1;
  font-weight: 950;
}

.entry-panel,
.history-panel {
  padding: 20px;
  border: 1px solid var(--line-dark);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 55px rgba(0,0,0,0.18);
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-width: 152px;
  padding: 4px;
  border: 1px solid var(--line-dark);
  border-radius: 8px;
  background: #eee7dc;
}

.mode-toggle button {
  min-height: 38px;
  border: 0;
  background: transparent;
}

.mode.active {
  background: var(--green-dark);
  color: #fff;
}

.round-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.quick-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.quick-grid button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
  padding: 0 14px;
  background: #f8f2e8;
  text-align: right;
}

.quick-grid button span {
  color: var(--muted);
  font-size: 0.86rem;
}

.quick-grid button strong {
  color: var(--green-dark);
}

.notes-row {
  margin-top: 16px;
}

.actions {
  margin-top: 18px;
  display: flex;
  gap: 10px;
}

.actions button {
  padding: 0 16px;
}

.actions.small {
  margin-top: 0;
}

.actions.small button {
  min-height: 38px;
  padding: 0 12px;
}

.primary {
  flex: 1;
  border-color: var(--green-dark);
  background: var(--green-dark);
  color: #fff;
}

.primary:hover {
  background: #073f35;
}

.round-list {
  max-height: 520px;
  overflow: auto;
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.round-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line-dark);
  border-radius: 8px;
  background: #fffaf0;
}

.round-number {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e3f2ed;
  color: var(--green-dark);
  font-weight: 950;
}

.round-score {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--ink);
  font-weight: 950;
}

.round-meta {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.empty-state {
  min-height: 170px;
  display: grid;
  place-items: center;
  margin: 0;
  border: 1px dashed rgba(17, 24, 19, 0.2);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  font-weight: 850;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(100% - 20px, 720px);
    padding: 10px 0;
  }

  .scoreboard {
    min-height: 0;
    padding: 18px;
  }

  .scoreboard::after {
    inset: 10px;
  }

  .scoreboard-top {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .mode-toggle {
    width: 100%;
  }
}

@media (max-width: 580px) {
  .teams,
  .round-inputs,
  .quick-grid {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
  }

  .actions.small {
    flex-direction: row;
  }

  .round-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .round-item > .round-meta {
    grid-column: 1 / -1;
  }
}
