:root {
  --bg: #f4efe6;
  --ink: #1f2933;
  --card: #fffaf2;
  --line: #d9cbb7;
  --accent: #b54708;
  --accent-soft: #ffe8cc;
  --medal-1: #ffd700;
  --medal-2: #c0c0c0;
  --medal-3: #cd7f32;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 0% 0%, #fff4dd 0%, transparent 30%),
    radial-gradient(circle at 100% 100%, #ffe3bf 0%, transparent 30%),
    var(--bg);
}

.page {
  max-width: 1300px;
  margin: 0 auto;
  padding: 24px;
}

.hero h1 {
  margin: 0;
  font-family: "Bebas Neue", sans-serif;
  letter-spacing: 1px;
  font-size: clamp(48px, 8vw, 84px);
  line-height: 0.95;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}

.submitEntryBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 10px;
  background: #a04d16;
  color: #fff8ee;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid #6f2f04;
  white-space: nowrap;
}

.submitEntryBtn:hover {
  background: #6f2f04;
  border-color: #5f2804;
}

.hero p {
  margin-top: 8px;
  font-size: 15px;
}

.card {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 14px;
  padding: 14px;
  margin-top: 14px;
}

.tabs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tabRow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tabButton {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
}

.tabButton.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

#scenarioTabs .tabButton.active {
  background: #ffe6c2;
  border-color: #c56a1a;
}

#trainModeTabs .tabButton.active {
  background: #e8f4ea;
  border-color: #3f7f53;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
  align-items: end;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

select, input, button {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  cursor: pointer;
  background: var(--accent-soft);
  border-color: #f6c788;
  font-weight: 700;
}

button:hover {
  border-color: var(--accent);
}

.summary {
  font-size: 14px;
  font-weight: 500;
}

.tableWrap {
  overflow: auto;
  max-height: 70vh;
}

.vizSection h2 {
  margin: 0;
  font-size: 16px;
}

.vizTitle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.vizHeader {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

#metricSelect {
  min-width: 0;
  width: auto;
  padding: 4px 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 8px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: none;
  box-shadow: none;
  transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease;
}

#metricSelect:hover {
  border-color: #b89e7f;
}

#metricSelect:focus,
#metricSelect:active {
  outline: none;
  border-color: #8f6d49;
  background: #f5e7d1;
}

#metricSelect::-ms-expand {
  display: none;
}

.vizLegend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: #3e4c59;
  margin-left: auto;
  justify-content: flex-end;
}

.legendItem {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legendDot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.preDot {
  background: #0b4f6c;
}

.scratchDot {
  background: #9eb2bc;
  border-radius: 0;
}

.vizPlotWrap {
  overflow-x: auto;
}

.errorbarSvg {
  width: 100%;
  min-width: 920px;
  display: block;
}

.axisTick {
  font-size: 11px;
  fill: #52606d;
}

.axisLabel {
  font-size: 11px;
  fill: #1f2933;
}

.axisTitle {
  font-size: 12px;
  font-weight: 600;
  fill: #1f2933;
}

.hidden {
  display: none;
}

.heatmapSection h2 {
  margin: 0;
  font-size: 16px;
}

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

.heatmapLegend {
  font-size: 12px;
  color: #3e4c59;
}

.lomoExplain {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.45;
  color: #3e4c59;
}

.heatmapWrap {
  overflow: auto;
}

.heatmapTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  min-width: 820px;
}

.heatmapTable th,
.heatmapTable td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  text-align: center;
}

.heatmapTable th:first-child,
.heatmapTable td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: #fffaf2;
  z-index: 1;
}

.heatmapTable th:last-child,
.heatmapTable td:last-child {
  font-weight: 700;
  background: #fff4df;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 980px;
}

thead th {
  position: sticky;
  top: 0;
  background: #fff4df;
  z-index: 1;
}

.sortableTh {
  cursor: pointer;
  user-select: none;
}

.sortableTh.sortedAsc::after {
  content: "  ↑";
  font-size: 11px;
  opacity: 0.85;
}

.sortableTh.sortedDesc::after {
  content: "  ↓";
  font-size: 11px;
  opacity: 0.85;
}

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

tr:hover td {
  background: #fff5e9;
}

.rank {
  font-weight: 700;
}

.metricStd {
  font-size: 11px;
  opacity: 0.78;
}

.vizEyeBtn {
  border: none;
  background: transparent;
  color: #b9ae9b;
  border-radius: 6px;
  width: 22px;
  height: 22px;
  padding: 0;
  margin-right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  line-height: 1;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, background-color 120ms ease, opacity 120ms ease;
}

.vizEyeBtn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

.vizEyeBtn.off {
  opacity: 0.18;
}

.vizEyeBtn:hover {
  color: #8f836f;
  background: transparent;
}

.vizEyeBtn:focus-visible {
  outline: none;
  color: #857864;
  background: transparent;
}

.vizEyeResetBtn {
  color: #9f927f;
  margin-right: 6px;
  position: relative;
  top: 0;
}

.medal-1 { background: linear-gradient(90deg, rgba(255,215,0,.2), transparent); }
.medal-2 { background: linear-gradient(90deg, rgba(192,192,192,.18), transparent); }
.medal-3 { background: linear-gradient(90deg, rgba(205,127,50,.18), transparent); }

@media (max-width: 920px) {
  .controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .controls {
    grid-template-columns: 1fr;
  }
}
