:root {
  --bg: #f6efe4;
  --bg-accent: #efe1c8;
  --surface: rgba(255, 250, 242, 0.88);
  --surface-strong: #fffdf9;
  --surface-dark: #123629;
  --text: #1d271f;
  --muted: #5d655d;
  --line: rgba(29, 39, 31, 0.12);
  --primary: #0f7b57;
  --primary-dark: #0c5b41;
  --primary-soft: rgba(15, 123, 87, 0.14);
  --danger: #b64537;
  --danger-soft: rgba(182, 69, 55, 0.12);
  --warning: #8b5b08;
  --shadow: 0 18px 40px rgba(73, 60, 37, 0.14);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(15, 123, 87, 0.18), transparent 28%),
    radial-gradient(circle at left 10% bottom 10%, rgba(208, 153, 61, 0.18), transparent 24%),
    linear-gradient(180deg, var(--bg-accent) 0%, var(--bg) 36%, #f8f4ed 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  width: min(1200px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.page-header {
  padding: 24px 4px 22px;
}

.page-header h1,
.panel h2,
.hero-card h2,
.table-title,
.match-card h3 {
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: 0.01em;
}

.page-header h1 {
  margin: 10px 0 8px;
  font-size: clamp(2.4rem, 6vw, 4.6rem);
  line-height: 0.94;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.lead {
  max-width: 60ch;
  margin: 0;
  color: var(--muted);
  font-size: 1.02rem;
}

.app-shell {
  display: grid;
  gap: 18px;
}

.hero-card,
.panel,
.metric-card,
.history-item,
.banner,
.team-card {
  background: var(--surface);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: var(--shadow);
}

.hero-card {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 18px;
  padding: 26px;
  border-radius: var(--radius-xl);
}

.hero-card::after {
  content: "";
  position: absolute;
  inset: auto -30px -50px auto;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15, 123, 87, 0.22), transparent 68%);
}

.hero-card h2 {
  margin: 8px 0;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
}

.hero-card p {
  margin: 0;
}

.hero-actions,
.button-row,
.inline-form,
.score-form,
.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

.panel {
  border-radius: var(--radius-lg);
  padding: 22px;
}

.panel h2,
.table-title {
  margin: 0 0 14px;
  font-size: 1.5rem;
}

.panel p {
  color: var(--muted);
}

.panel.setup-players {
  grid-column: span 7;
}

.panel.setup-config {
  grid-column: span 5;
}

.panel.table-panel,
.panel.history-panel {
  grid-column: span 12;
}

.panel.match-panel,
.panel.summary-panel {
  grid-column: span 4;
}

.panel.standings-panel {
  grid-column: span 8;
}

.field,
.field-group {
  display: grid;
  gap: 8px;
}

.field + .field,
.field + .button-row,
.field-group + .field-group,
.field-group + .button-row {
  margin-top: 16px;
}

label {
  font-weight: 600;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
}

input[type="text"]:focus,
input[type="number"]:focus {
  outline: 3px solid rgba(15, 123, 87, 0.16);
  border-color: rgba(15, 123, 87, 0.36);
}

.button,
.ghost-button,
.danger-button {
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  font-weight: 700;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

.button:hover,
.ghost-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

.button {
  color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  box-shadow: 0 12px 22px rgba(12, 91, 65, 0.22);
}

.ghost-button {
  color: var(--primary-dark);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(15, 123, 87, 0.22);
}

.danger-button {
  color: var(--danger);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(182, 69, 55, 0.26);
}

.button:disabled,
.ghost-button:disabled,
.danger-button:disabled {
  cursor: not-allowed;
  transform: none;
  opacity: 0.55;
  box-shadow: none;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0;
  list-style: none;
  margin: 18px 0 0;
}

.pill-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(15, 123, 87, 0.14);
}

.pill-item strong {
  font-size: 0.98rem;
}

.pill-item button {
  border: 0;
  background: transparent;
  color: var(--danger);
  font-weight: 700;
  padding: 0;
}

.hint,
.muted {
  color: var(--muted);
  font-size: 0.94rem;
}

.banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}

.banner strong {
  display: block;
  margin-bottom: 4px;
}

.banner.info {
  background: rgba(255, 255, 255, 0.76);
}

.banner.error {
  background: #fff4f2;
  border-color: rgba(182, 69, 55, 0.26);
}

.banner.error strong {
  color: var(--danger);
}

.metric-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-card {
  border-radius: var(--radius-lg);
  padding: 18px;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.8rem;
  font-family: Georgia, "Times New Roman", serif;
}

.metric-card span {
  color: var(--muted);
  font-size: 0.92rem;
}

.progress-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(18, 54, 41, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #d0933d 0%, var(--primary) 100%);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.standings-rank {
  font-weight: 700;
  color: var(--primary-dark);
}

.match-card {
  display: grid;
  gap: 16px;
}

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

.team-card {
  border-radius: 18px;
  padding: 16px;
}

.team-card h3 {
  margin: 0 0 10px;
  font-size: 1.2rem;
}

.team-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.score-form {
  align-items: end;
}

.score-form .field {
  flex: 1 1 140px;
}

.history-list {
  display: grid;
  gap: 14px;
}

.history-item {
  border-radius: 18px;
  padding: 18px;
}

.history-item header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.history-item header strong {
  font-size: 1.06rem;
}

.history-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 700;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0;
}

.history-row span {
  color: var(--muted);
}

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

.champion {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(208, 153, 61, 0.18);
  color: #6c4812;
  font-weight: 700;
}

.empty-state {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.56);
  border: 1px dashed rgba(15, 123, 87, 0.22);
}

@media (max-width: 960px) {
  .panel.setup-players,
  .panel.setup-config,
  .panel.match-panel,
  .panel.summary-panel,
  .panel.standings-panel {
    grid-column: span 12;
  }

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

@media (max-width: 720px) {
  .page-shell {
    width: min(100vw - 20px, 100%);
    padding-top: 18px;
  }

  .hero-card,
  .panel,
  .metric-card,
  .history-item {
    padding: 18px;
  }

  .metric-grid,
  .versus-grid {
    grid-template-columns: 1fr;
  }

  .history-row,
  .history-item header,
  .banner {
    align-items: flex-start;
    flex-direction: column;
  }

  th,
  td {
    padding-inline: 8px;
  }
}
