:root {
  color-scheme: light;
  --ink: #17301f;
  --muted: #607268;
  --line: #cddbd2;
  --panel: #ffffff;
  --wash: #edf4ef;
  --accent: #007a3d;
  --accent-dark: #004b27;
  --accent-deep: #003719;
  --gold: #f7c600;
  --gold-dark: #b88a00;
  --rose: #b3273d;
  --shadow: 0 18px 42px rgba(0, 55, 25, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(0, 75, 39, 0.14), transparent 360px),
    var(--wash);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 34px clamp(18px, 4vw, 48px) 30px;
  border-bottom: 6px solid var(--gold);
  background:
    linear-gradient(120deg, rgba(247, 198, 0, 0.18), transparent 38%),
    linear-gradient(135deg, var(--accent-deep), var(--accent-dark) 54%, #006b36);
  color: #ffffff;
}

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

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4.6rem);
  line-height: 0.95;
  letter-spacing: 0;
  color: inherit;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.24);
}

main {
  padding: 24px clamp(18px, 4vw, 48px) 48px;
}

.source-pill {
  min-height: 38px;
  max-width: 420px;
  padding: 10px 14px;
  border: 1px solid rgba(247, 198, 0, 0.78);
  border-radius: 999px;
  background: rgba(247, 198, 0, 0.98);
  color: var(--accent-deep);
  font-size: 0.88rem;
  font-weight: 750;
  text-align: right;
}

.source-pill.warning {
  border-color: rgba(163, 59, 85, 0.35);
  color: var(--rose);
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid rgba(0, 75, 39, 0.18);
  border-top: 4px solid var(--accent);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 6px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 750;
}

select,
input {
  width: 100%;
  height: 42px;
  border: 1px solid #b9d0c0;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.96rem;
  font-weight: 650;
  padding: 0 12px;
}

select:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 122, 61, 0.16);
  outline: none;
}

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

.metric-card {
  min-height: 134px;
  padding: 18px;
  border: 1px solid rgba(0, 75, 39, 0.16);
  border-top: 5px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
}

.metric-card span {
  display: block;
  color: var(--accent-dark);
  font-size: 0.8rem;
  font-weight: 800;
}

.metric-card strong {
  display: block;
  margin: 8px 0;
  color: var(--accent);
  font-size: clamp(1.6rem, 2.8vw, 2.35rem);
  line-height: 1;
}

.metric-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.table-wrap,
.detail-pane {
  border: 1px solid rgba(0, 75, 39, 0.16);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1040px;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--accent-dark);
  color: #ffffff;
  font-size: 0.78rem;
  text-transform: uppercase;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: #e5f4e9;
}

.game-button {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.game-button small {
  color: #597562;
  font-size: 0.78rem;
  font-weight: 700;
}

.detail-pane {
  padding: 18px;
  position: sticky;
  top: 16px;
}

.ticket-frame {
  display: grid;
  place-items: center;
  min-height: 210px;
  margin-bottom: 18px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(0, 75, 39, 0.16), rgba(247, 198, 0, 0.28)),
    #f4faf6;
}

.ticket-frame img {
  max-width: min(220px, 80%);
  max-height: 190px;
  object-fit: contain;
  filter: drop-shadow(0 12px 18px rgba(24, 33, 42, 0.18));
}

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

.detail-heading h2 {
  margin-bottom: 4px;
  font-size: 1.35rem;
  line-height: 1.1;
}

.detail-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 700;
}

.detail-heading a {
  color: var(--accent);
  font-weight: 850;
  text-decoration: none;
}

.detail-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 18px;
}

.detail-stats div {
  padding: 12px;
  border: 1px solid #c5d8ca;
  border-radius: 8px;
  background: #f7fbf8;
}

dt {
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 800;
}

dd {
  margin: 4px 0 0;
  font-size: 1.08rem;
  font-weight: 850;
}

h3 {
  margin-bottom: 10px;
  font-size: 0.9rem;
  text-transform: uppercase;
}

.tier-list {
  display: grid;
  gap: 8px;
}

.tier-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #c5d8ca;
  border-radius: 8px;
  background: #ffffff;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.tier-row:hover,
.tier-row.selected {
  border-color: var(--accent);
  background: #edf8f0;
}

.tier-row:focus-visible {
  outline: 3px solid rgba(0, 122, 61, 0.2);
  outline-offset: 2px;
}

.tier-row span,
.tier-row strong {
  font-weight: 850;
}

.tier-row strong {
  color: var(--accent);
}

.tier-row small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-weight: 650;
}

.tier-cumulative {
  display: grid;
  gap: 10px;
  grid-column: 1 / -1;
  margin-top: 6px;
  padding: 12px;
  border: 1px solid rgba(0, 75, 39, 0.18);
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  background: #ffffff;
}

.tier-cumulative p {
  margin: 0;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 750;
}

.tier-cumulative dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.tier-cumulative dl div {
  padding: 10px;
  border: 1px solid #d7e4db;
  border-radius: 8px;
  background: #f7fbf8;
}

.tier-cumulative dd {
  font-size: 1rem;
}

.tier-cumulative small {
  color: var(--muted);
}

.error-text {
  color: var(--rose);
  font-weight: 800;
}

.about-section {
  margin-top: 22px;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid rgba(0, 75, 39, 0.16);
  border-top: 5px solid var(--gold);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.about-heading {
  max-width: 860px;
  margin-bottom: 18px;
}

.about-heading h2 {
  margin-bottom: 8px;
  font-size: clamp(1.45rem, 2.4vw, 2.1rem);
  line-height: 1.1;
}

.about-heading p,
.about-panel p,
.about-panel li {
  color: var(--muted);
  line-height: 1.5;
}

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

.about-panel {
  padding: 16px;
  border: 1px solid #c5d8ca;
  border-radius: 8px;
  background: #f7fbf8;
}

.about-panel h3 {
  margin-bottom: 8px;
  color: var(--ink);
}

.about-panel ul {
  display: grid;
  gap: 7px;
  margin: 12px 0 0;
  padding-left: 20px;
}

.formula-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

code {
  border-radius: 6px;
  background: #e1f1e6;
  color: var(--accent-dark);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.88rem;
  font-weight: 750;
}

.formula-list code {
  display: block;
  padding: 10px 12px;
  white-space: normal;
}

.about-note {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-weight: 700;
}

@media (max-width: 980px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .source-pill {
    max-width: none;
    text-align: left;
  }

  .toolbar,
  .summary-grid,
  .content-grid,
  .about-grid {
    grid-template-columns: 1fr;
  }

  .detail-pane {
    position: static;
  }
}

@media (max-width: 560px) {
  .app-header {
    padding-top: 22px;
  }

  .toolbar {
    padding: 10px;
  }

  .detail-stats {
    grid-template-columns: 1fr;
  }

  .tier-cumulative dl {
    grid-template-columns: 1fr;
  }
}
