:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --ink: #17201d;
  --muted: #66736e;
  --line: #cdd8d4;
  --panel: #ffffff;
  --accent: #176b5c;
  --accent-2: #a24724;
  --soft: #e7efec;
  --warn: #fff4df;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Malgun Gothic", Arial, sans-serif;
}

.shell {
  min-height: 100vh;
  padding: 24px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 20px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.title-block h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

.title-block p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.nav-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.nav-link:hover {
  text-decoration: underline;
}

.controls {
  display: grid;
  grid-template-columns: 160px 132px 110px 132px;
  gap: 10px;
  align-items: end;
}

.weekly-controls {
  grid-template-columns: 150px 110px 130px 130px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
button {
  height: 38px;
  border-radius: 6px;
  border: 1px solid var(--line);
  font: inherit;
}

input,
select {
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 0 14px;
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  cursor: progress;
  opacity: 0.65;
}

.status-band {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 140px minmax(260px, 1.3fr);
  gap: 12px;
  margin: 18px 0;
}

.status-band > div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
}

.label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

.status-band strong,
.status-band a {
  color: var(--ink);
  font-size: 15px;
}

.status-band a {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
  white-space: nowrap;
}

.result-area {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.result-area + .result-area {
  margin-top: 18px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
}

.section-heading h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.section-heading span {
  color: var(--muted);
  font-size: 12px;
}

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

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

.simulation-area table {
  min-width: 1120px;
}

.weekly-table {
  min-width: 1220px;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  background: #fbfcfc;
}

tbody tr:nth-child(1) td:first-child {
  color: var(--accent-2);
  font-weight: 900;
}

.win-prob-band {
  background: #fff0a8;
  color: #4a3500;
  font-weight: 900;
}

.actual-rank-1 {
  background: #f8d75c;
  color: #332400;
  font-weight: 900;
}

.actual-rank-2 {
  background: #dfe3ea;
  color: #202833;
  font-weight: 900;
}

.actual-rank-3 {
  background: #e7c6a3;
  color: #3b2412;
  font-weight: 900;
}

.weekly-hit {
  color: #116149;
  font-weight: 900;
}

.weekly-miss {
  color: #9b3924;
  font-weight: 900;
}

.weekly-pending {
  color: var(--muted);
  font-weight: 800;
}

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

.empty-row td {
  color: var(--muted);
  text-align: center;
  padding: 32px 14px;
}

.combo-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 16px;
  border-top: 1px solid var(--line);
}

.combo-section h3 {
  margin: 0 0 10px;
  font-size: 14px;
  letter-spacing: 0;
}

.combo-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
}

.combo-list li {
  color: var(--muted);
  font-size: 14px;
}

.combo-list li span {
  color: var(--ink);
  font-weight: 800;
}

.combo-list li strong {
  color: var(--accent-2);
  margin-left: 8px;
}

.error {
  background: var(--warn);
}

@media (max-width: 860px) {
  .shell {
    padding: 16px;
  }

  .toolbar,
  .status-band {
    grid-template-columns: 1fr;
  }

  .controls {
    grid-template-columns: 1fr 1fr;
  }

  .weekly-controls {
    grid-template-columns: 1fr;
  }

  .controls button {
    grid-column: 1 / -1;
  }

  .combo-area {
    grid-template-columns: 1fr;
  }
}
