:root {
  --bg-top: #f6efe2;
  --bg-bottom: #f2f6fb;
  --ink: #172133;
  --muted: #5f6b7b;
  --panel: rgba(255, 252, 246, 0.88);
  --panel-border: rgba(23, 33, 51, 0.12);
  --accent: #d2611c;
  --accent-dark: #a64812;
  --accent-soft: rgba(210, 97, 28, 0.14);
  --navy: #10304f;
  --navy-soft: rgba(16, 48, 79, 0.08);
  --success: #1d6b44;
  --shadow: 0 18px 45px rgba(17, 33, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(210, 97, 28, 0.16), transparent 26rem),
    radial-gradient(circle at right center, rgba(16, 48, 79, 0.12), transparent 28rem),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  letter-spacing: -0.02em;
}

p {
  margin: 0;
}

.page-shell {
  width: min(1180px, calc(100vw - 2rem));
  margin: 1.25rem auto 2rem;
}

.topbar,
.panel {
  backdrop-filter: blur(12px);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.2rem;
  border-radius: 22px;
}

.topbar h1 {
  font-size: clamp(1.7rem, 3vw, 2.4rem);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.button {
  border: 0;
  border-radius: 999px;
  padding: 0.9rem 1.2rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

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

.button-primary {
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.simulation-control {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.8rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(16, 48, 79, 0.12);
  color: var(--navy);
  font-weight: 700;
}

.simulation-control span {
  font-size: 0.92rem;
}

.simulation-control small {
  color: var(--muted);
  font-size: 0.82rem;
}

#simulation-count {
  width: 6.5rem;
  padding: 0.32rem 0.45rem;
  border-radius: 12px;
  border: 1px solid rgba(16, 48, 79, 0.15);
  background: white;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}

#simulation-count:disabled,
.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.95fr);
  gap: 1rem;
  margin-top: 1rem;
  align-items: start;
}

.panel {
  border-radius: 28px;
  padding: 1.25rem;
}

.panel-header {
  margin-bottom: 1rem;
}

.panel-header h2 {
  font-size: 1.35rem;
}

.history-section {
  margin-top: 1.6rem;
  padding-top: 1.2rem;
  border-top: 1px solid rgba(16, 48, 79, 0.08);
}

.history-header h3 {
  font-size: 1.15rem;
}

.history-note {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.history-chart-wrap {
  position: relative;
  margin-top: 1rem;
  height: 300px;
}

.history-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.history-legend button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(16, 48, 79, 0.12);
  background: rgba(255, 255, 255, 0.92);
  color: var(--navy);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.history-legend button.is-muted {
  opacity: 0.55;
}

.legend-swatch {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 999px;
}

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

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

thead th {
  padding: 0.7rem 0.75rem;
  text-align: left;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

tbody td {
  padding: 0.9rem 0.75rem;
  border-top: 1px solid rgba(16, 48, 79, 0.08);
  vertical-align: middle;
}

tbody tr.is-eliminated td {
  background: rgba(186, 63, 63, 0.08);
}

.team-cell {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
}

.team-logo {
  display: block;
  width: 2.3rem;
  height: 2.3rem;
  object-fit: contain;
  flex: 0 0 2.3rem;
}

.chance-wrap {
  min-width: 180px;
}

.chance-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.92rem;
  font-weight: 700;
}

.chance-bar {
  margin-top: 0.4rem;
  height: 0.68rem;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(16, 48, 79, 0.12);
}

.chance-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #efb04e);
}

.matches-list {
  display: grid;
  gap: 0.9rem;
}

.matches-empty {
  padding: 1rem 0.2rem 0.1rem;
  color: var(--muted);
  font-weight: 700;
}

.match-card {
  padding: 0.95rem 1rem;
  border-radius: 20px;
  background: white;
  border: 1px solid rgba(16, 48, 79, 0.08);
}

.match-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
  font-weight: 700;
}

.match-id {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.slider-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
}

.slider-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.probability-pill {
  display: inline-flex;
  min-width: 4rem;
  justify-content: center;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 800;
}

.team-side {
  font-weight: 700;
  color: var(--navy);
}

@media (max-width: 960px) {
  .topbar,
  .layout-grid {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    min-width: 0;
    align-items: stretch;
    flex-direction: column;
  }
}
