:root {
  color-scheme: light;
  --ink: #1d2433;
  --muted: #637083;
  --line: #d9e0ea;
  --panel: #ffffff;
  --paper: #f6f8fb;
  --accent: #0f8b8d;
  --accent-dark: #09676a;
  --gold: #f2b705;
  --pink: #d9487d;
  --green: #2f9e44;
  --blue: #3b6fd8;
  --shadow: 0 18px 50px rgba(23, 34, 55, .12);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(15, 139, 141, .12), transparent 360px),
    var(--paper);
  color: var(--ink);
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

header {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr);
  gap: 22px;
  align-items: stretch;
  min-height: 300px;
}

.hero {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 82% 16%, rgba(242, 183, 5, .28), transparent 28%),
    linear-gradient(135deg, #ffffff 0%, #eef8f8 100%);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.eyebrow {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid rgba(15, 139, 141, .25);
  border-radius: 999px;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, .72);
  font-size: 13px;
  font-weight: 700;
}

h1 {
  margin: 22px 0 12px;
  max-width: 760px;
  font-size: clamp(34px, 5vw, 66px);
  line-height: 1.03;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 6px;
  font-size: 23px;
  letter-spacing: 0;
}

.hero p, .section > p, .sim-top p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.controls, .sim-controls, .sim-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.controls { margin-top: 28px; }

.tabs {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.tab-button {
  min-width: 130px;
}

.tab-button.active {
  background: var(--accent);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}

button:hover {
  background: var(--accent-dark);
  box-shadow: 0 10px 24px rgba(15, 139, 141, .22);
  transform: translateY(-1px);
}

button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

button.secondary:hover {
  background: #f0f5f6;
  box-shadow: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: .5;
  transform: none;
  box-shadow: none;
}

.latest {
  display: grid;
  gap: 14px;
}

.mini-card, .section, .result-card, .simulator, .sim-ticket, .sim-runner {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 34px rgba(23, 34, 55, .08);
}

.mini-card {
  padding: 18px;
}

.mini-card h2 {
  margin: 0 0 10px;
  font-size: 18px;
}

.meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.balls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.ball, .digit, .group {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #fff;
  font-weight: 900;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .12);
}

.large-balls .ball, .large-balls .digit, .large-balls .group {
  width: 48px;
  height: 48px;
}

.ball.low { background: var(--gold); color: #332700; }
.ball.mid { background: var(--blue); }
.ball.high { background: var(--pink); }
.ball.top { background: var(--green); }

.plus {
  display: inline-grid;
  place-items: center;
  width: 24px;
  color: var(--muted);
  font-weight: 900;
}

.digit {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #263447;
}

.group {
  width: 46px;
  height: 38px;
  border-radius: 8px;
  background: var(--accent);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 22px;
}

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

.section, .simulator {
  padding: 22px;
}

.section > p {
  margin-bottom: 18px;
}

.results {
  display: grid;
  gap: 12px;
}

.result-card {
  padding: 16px;
  box-shadow: none;
}

.insight-panel {
  align-self: start;
  position: sticky;
  top: 14px;
}

.sim-preset {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfd;
}

.sim-preset .balls {
  min-height: 42px;
}

.sim-preset button {
  width: 100%;
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eaf6f6;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.score {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.why {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.tool-panel {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 18px;
  align-items: start;
  margin-top: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.number-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 7px;
}

.number-board.compact {
  grid-template-columns: repeat(9, minmax(30px, 1fr));
  margin-top: 12px;
}

.pick {
  aspect-ratio: 1;
  min-height: 0;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.pick.selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.manual-output {
  min-height: 132px;
  margin-top: 12px;
  padding: 16px;
  border-radius: 8px;
  background: #f4f7fa;
  border: 1px dashed #c6d0dc;
}

.pension-picker {
  display: grid;
  grid-template-columns: 84px repeat(6, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.pension-picker select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 900;
  text-align: center;
}

.simulator {
  margin-top: 18px;
}

.sim-top {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.sim-layout {
  display: grid;
  grid-template-columns: minmax(320px, .85fr) minmax(0, 1.15fr);
  gap: 18px;
  margin-top: 18px;
}

.sim-ticket, .sim-runner {
  padding: 18px;
  box-shadow: none;
}

.runner-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.speed-box {
  display: grid;
  gap: 6px;
  min-width: 190px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.speed-box select,
.sim-controls select {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.sim-controls {
  align-items: end;
}

.sim-controls select {
  width: auto;
  min-width: 120px;
}

.select-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.rank-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.pension-rank-grid {
  grid-template-columns: repeat(4, 1fr);
}

.rank-card {
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfd;
}

.rank-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 18px;
}

.rank-card .hit {
  color: var(--accent-dark);
  font-size: 22px;
  font-weight: 950;
}

.rank-card .pending {
  color: var(--muted);
  font-size: 18px;
  font-weight: 900;
}

.table-head {
  margin-top: 18px;
}

.table-wrap {
  margin-top: 12px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.stats-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.stats-table.pension-table {
  min-width: 980px;
}

.stats-table th,
.stats-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-size: 14px;
}

.stats-table th {
  background: #f4f7fa;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.stats-table th:first-child,
.stats-table td:first-child {
  text-align: left;
  min-width: 230px;
}

.stats-table tr:last-child td {
  border-bottom: 0;
}

.mini-balls {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.mini-balls .ball {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

.mini-balls .digit,
.mini-balls .group {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 12px;
}

.notice {
  margin-top: 22px;
  padding: 16px 18px;
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  background: #fff8df;
  color: #5d4810;
  line-height: 1.55;
}

footer {
  margin-top: 24px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

footer a {
  color: var(--accent-dark);
  font-weight: 800;
}

@media (max-width: 900px) {
  main { width: min(100% - 20px, 720px); padding-top: 10px; }
  header, .grid, .tool-panel, .sim-layout { grid-template-columns: 1fr; }
  .hero { padding: 24px; min-height: 360px; }
  .number-board, .number-board.compact { grid-template-columns: repeat(5, 1fr); }
  .ball { width: 39px; height: 39px; }
  .section, .simulator { padding: 18px; }
  .sim-top, .runner-head { flex-direction: column; }
  .rank-grid { grid-template-columns: 1fr 1fr; }
  .pension-picker { grid-template-columns: repeat(4, 1fr); }
  .insight-panel { position: static; }
}

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