:root {
  --green: #087a43;
  --green-2: #16a357;
  --green-soft: #e7f6ec;
  --yellow: #ffd928;
  --orange: #ff7438;
  --blue: #1b64b0;
  --ink: #183128;
  --muted: #66766f;
  --paper: #fffef8;
  --line: #dce7df;
  --shadow: 0 18px 45px rgba(20, 74, 49, .12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 8%, rgba(255, 217, 40, .18), transparent 25rem),
    linear-gradient(180deg, #f8fff9 0, #fffef8 36rem, #f5faf6 100%);
  font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", system-ui, sans-serif;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.site-header {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { border: 0; background: transparent; display: flex; align-items: center; gap: 10px; color: var(--ink); padding: 0; text-align: left; }
.brand img { width: 54px; height: 54px; border-radius: 16px; box-shadow: 0 7px 18px rgba(10, 102, 56, .14); }
.brand span { display: grid; line-height: 1.2; }
.brand strong { font-size: 1rem; }
.brand small { color: var(--muted); margin-top: 3px; }
.admin-link { color: #66766f; text-decoration: none; font-size: .82rem; border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; background: rgba(255,255,255,.75); }

main { width: min(920px, calc(100% - 32px)); margin: 0 auto 80px; }
.hero { min-height: 330px; border-radius: 34px; padding: 50px clamp(28px, 7vw, 68px); display: flex; justify-content: space-between; align-items: center; gap: 30px; overflow: hidden; position: relative; color: white; background: linear-gradient(128deg, #086c3e 0%, #0d8d4c 55%, #29ae65 100%); box-shadow: var(--shadow); }
.hero::before, .hero::after { content: ""; position: absolute; border: 3px solid rgba(255,255,255,.12); border-radius: 50%; }
.hero::before { width: 430px; height: 430px; right: -190px; top: -210px; }
.hero::after { width: 250px; height: 250px; right: 70px; bottom: -190px; }
.hero-copy { position: relative; z-index: 1; }
.eyebrow { display: inline-flex; margin: 0 0 14px; border-radius: 999px; background: var(--yellow); color: #183128; padding: 7px 13px; font-weight: 900; font-size: .82rem; letter-spacing: .02em; }
.hero h1 { font-size: clamp(2.5rem, 8vw, 5rem); letter-spacing: -.06em; line-height: .98; margin: 0; }
.hero h1 span { color: var(--yellow); }
.hero-sub { margin: 20px 0 0; font-size: clamp(1rem, 2.3vw, 1.25rem); font-weight: 700; color: rgba(255,255,255,.9); }
.goal-badge { position: relative; z-index: 1; width: 180px; height: 180px; flex: 0 0 180px; border-radius: 50%; display: grid; place-content: center; text-align: center; color: var(--ink); background: var(--yellow); transform: rotate(6deg); box-shadow: inset 0 0 0 9px rgba(255,255,255,.35), 0 18px 30px rgba(0,0,0,.18); }
.goal-badge span { font-size: .78rem; font-weight: 900; letter-spacing: .18em; }
.goal-badge strong { font-size: 4rem; line-height: .9; letter-spacing: -.08em; }
.goal-badge small { font-size: 1.15rem; font-weight: 900; }

.progress-card, .record-card, .rules, .admin-card { background: rgba(255,255,255,.95); border: 1px solid rgba(8, 122, 67, .12); border-radius: 28px; box-shadow: var(--shadow); }
.progress-card { margin: -32px 28px 28px; padding: 28px 32px 25px; position: relative; z-index: 2; }
.progress-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; }
.progress-heading > div { display: grid; gap: 4px; }
.section-kicker { font-size: .86rem; color: var(--muted); font-weight: 800; }
#totalKm { font-size: clamp(2rem, 6vw, 3.4rem); line-height: 1; letter-spacing: -.05em; color: var(--green); }
#progressPercent { font-size: 1.2rem; font-weight: 900; color: var(--orange); }
.track { height: 28px; background: #e6ece7; border-radius: 999px; margin: 22px 0 12px; position: relative; box-shadow: inset 0 2px 7px rgba(0,0,0,.08); }
.track-fill { position: absolute; inset: 0 auto 0 0; width: 0%; border-radius: inherit; background: repeating-linear-gradient(135deg, var(--green), var(--green) 12px, #18a85e 12px, #18a85e 24px); transition: width .8s cubic-bezier(.2,.9,.2,1); }
.runner { position: absolute; left: 0%; top: 50%; transform: translate(-50%, -58%); font-size: 2rem; transition: left .8s cubic-bezier(.2,.9,.2,1); filter: drop-shadow(0 4px 4px rgba(0,0,0,.2)); }
.finish { position: absolute; right: -9px; top: -32px; font-size: 2.1rem; }
.progress-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: .9rem; }
.progress-meta b { color: var(--ink); }
.notice { margin: 18px 0 0; padding: 10px 14px; border-radius: 12px; background: var(--green-soft); color: var(--green); font-weight: 750; text-align: center; }

.science-unlock { margin: 0 28px 28px; padding: 24px 26px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px; border: 2px solid #f0d96b; border-radius: 24px; color: var(--ink); background: linear-gradient(135deg, #fffbe2, #fff6b9); box-shadow: var(--shadow); }
.science-unlock-icon { display: grid; place-items: center; width: 68px; height: 68px; border-radius: 20px; background: white; font-size: 2.2rem; box-shadow: 0 8px 20px rgba(132, 102, 0, .12); }
.science-unlock-copy span { color: #8a6500; font-size: .78rem; font-weight: 950; letter-spacing: .04em; }
.science-unlock-copy h2 { margin-top: 3px; color: var(--green); }
.science-unlock-copy p { margin: 7px 0 0; color: #665d38; font-size: .9rem; line-height: 1.5; }
.science-button { border: 0; border-radius: 15px; padding: 13px 17px; color: white; background: var(--green); font-weight: 900; white-space: nowrap; box-shadow: 0 8px 18px rgba(8, 122, 67, .2); }

.poster-dialog { width: min(820px, calc(100% - 24px)); max-width: none; max-height: 94dvh; margin: auto; padding: 0; border: 0; border-radius: 22px; background: white; box-shadow: 0 30px 80px rgba(0,0,0,.35); overflow: hidden; }
.poster-dialog::backdrop { background: rgba(7, 28, 19, .76); backdrop-filter: blur(3px); }
.poster-dialog-inner { max-height: 94dvh; overflow-y: auto; overscroll-behavior: contain; }
.poster-dialog-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; color: white; background: var(--green); box-shadow: 0 4px 12px rgba(0,0,0,.16); }
.poster-dialog-bar h2 { font-size: clamp(1rem, 3vw, 1.35rem); }
.poster-dialog-bar button { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 42px; border: 0; border-radius: 50%; color: white; background: rgba(255,255,255,.18); font-size: 1.8rem; line-height: 1; }
.poster-dialog img { display: block; width: 100%; height: auto; }
.poster-new-window { display: block; margin: 14px 16px 18px; padding: 13px; border-radius: 14px; color: var(--green); background: var(--green-soft); font-weight: 900; text-align: center; text-decoration: none; }
body.modal-open { overflow: hidden; }

.record-card { padding: clamp(24px, 6vw, 48px); margin-bottom: 28px; }
.card-title-row { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 28px; }
.card-title-row > div { display: flex; align-items: center; gap: 12px; }
.step { display: inline-grid; place-items: center; width: 42px; height: 34px; border-radius: 10px; color: white; background: var(--green); font-weight: 900; font-size: .82rem; }
h2 { margin: 0; font-size: clamp(1.4rem, 4vw, 2rem); letter-spacing: -.04em; }
.course-chip { border-radius: 999px; padding: 8px 12px; background: #fff7cf; color: #6e5700; border: 1px solid #f5df72; font-size: .86rem; font-weight: 800; white-space: nowrap; }
label, legend { display: block; font-weight: 850; margin-bottom: 9px; }
.student-input-wrap { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
input, select, textarea { width: 100%; border: 2px solid var(--line); border-radius: 14px; padding: 14px 15px; color: var(--ink); background: white; outline: none; transition: .2s; }
input:focus, select:focus, textarea:focus { border-color: var(--green-2); box-shadow: 0 0 0 4px rgba(22, 163, 87, .13); }
#studentId { font-size: 1.35rem; font-weight: 900; letter-spacing: .2em; }
.help { color: var(--muted); font-size: .82rem; margin: 7px 0 24px; }
.goal-fieldset { margin-bottom: 26px; }
.goal-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.goal-options label { margin: 0; cursor: pointer; }
.goal-options input { position: absolute; opacity: 0; pointer-events: none; }
.goal-options span { min-height: 118px; display: grid; align-content: center; justify-items: center; gap: 3px; padding: 14px 8px; border: 2px solid var(--line); border-radius: 17px; background: white; text-align: center; transition: .2s; }
.goal-options b { color: var(--muted); font-size: .78rem; }
.goal-options strong { color: var(--green); font-size: 1.55rem; }
.goal-options small { color: var(--muted); font-size: .72rem; }
.goal-options input:checked + span { border-color: var(--green); background: var(--green-soft); box-shadow: 0 0 0 3px rgba(22, 163, 87, .12); }
.goal-options input:focus-visible + span { outline: 3px solid rgba(27, 100, 176, .35); outline-offset: 2px; }
.goal-help { margin-bottom: 0; text-align: center; }
.secondary-button { border: 1px solid var(--line); background: #f6faf7; color: var(--green); border-radius: 14px; padding: 0 17px; font-weight: 850; }
fieldset { border: 0; padding: 0; margin: 0 0 26px; }
.counter { display: grid; grid-template-columns: 62px 1fr 62px; gap: 10px; align-items: center; max-width: 360px; margin: 0 auto; }
.counter button { height: 58px; border: 0; border-radius: 16px; background: var(--green-soft); color: var(--green); font-size: 2rem; font-weight: 800; }
.counter output { text-align: center; font-size: 3rem; font-weight: 950; }
.quick-laps { display: flex; justify-content: center; gap: 8px; margin: 14px 0; }
.quick-laps button { min-width: 46px; border: 1px solid var(--line); background: white; border-radius: 999px; padding: 8px 12px; font-weight: 800; color: var(--muted); }
.quick-laps button.active { background: var(--green); color: white; border-color: var(--green); }
.distance-preview { text-align: center; color: var(--muted); }
.distance-preview strong { color: var(--orange); font-size: 1.2rem; }
.primary-button { width: 100%; border: 0; border-radius: 17px; color: white; background: linear-gradient(90deg, var(--green), var(--green-2)); font-weight: 900; font-size: 1.08rem; padding: 16px 20px; box-shadow: 0 10px 22px rgba(8,122,67,.2); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.form-message { min-height: 24px; text-align: center; margin: 12px 0 0; color: #b23a2c; font-weight: 750; }
.form-message.success { color: var(--green); }
.my-record { margin-top: 20px; padding: 18px; background: #f4f8ff; border: 1px solid #dce8f6; border-radius: 16px; color: #38506b; }
.my-record-heading, .my-record-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.my-record-heading strong { font-size: 1.45rem; color: var(--blue); }
.personal-track { height: 12px; margin: 14px 0 9px; overflow: hidden; border-radius: 999px; background: #dce8f6; }
.personal-track span { display: block; width: 0%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), #4c91d7); transition: width .6s ease; }
.my-record-meta { color: var(--muted); font-size: .82rem; }
.my-record-meta b { color: var(--blue); }
.my-record.achieved { background: #fff9da; border-color: #f0d96b; }
.my-record.achieved .personal-track span { background: linear-gradient(90deg, var(--orange), var(--yellow)); }

.rules { padding: clamp(24px, 6vw, 42px); }
.rules > .step { vertical-align: middle; margin-right: 10px; }
.rules h2 { display: inline-block; vertical-align: middle; }
.rule-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 24px; }
.rule-grid article { padding: 20px 16px; border: 1px solid var(--line); background: var(--paper); border-radius: 18px; }
.rule-grid article > span { display: block; font-size: 2rem; margin-bottom: 10px; }
.rule-grid strong { display: block; font-size: .98rem; }
.rule-grid p { color: var(--muted); font-size: .84rem; line-height: 1.55; margin: 6px 0 0; }
footer { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 28px; color: var(--muted); text-align: left; }
footer img { width: 42px; height: 42px; }
footer p { margin: 0; font-weight: 800; }
footer small { font-weight: 500; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 10; max-width: calc(100% - 32px); background: #173a2c; color: white; border-radius: 14px; padding: 13px 18px; box-shadow: 0 12px 30px rgba(0,0,0,.22); font-weight: 750; }

/* Admin */
.admin-page main { max-width: 1100px; }
.admin-hero { padding: 26px 0 18px; }
.admin-hero h1 { margin: 0; font-size: clamp(2rem, 6vw, 3.3rem); letter-spacing: -.05em; }
.admin-hero p { color: var(--muted); }
.admin-card { padding: clamp(22px, 5vw, 36px); margin-bottom: 20px; }
.login-card { max-width: 480px; margin: 55px auto; }
.login-card h1 { margin-top: 0; }
.login-card .primary-button { margin-top: 12px; }
.admin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.metric { padding: 22px; border-radius: 20px; background: white; border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(20,74,49,.08); }
.metric span { display: block; color: var(--muted); font-size: .85rem; font-weight: 800; }
.metric strong { font-size: 2rem; color: var(--green); }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.toggle-row { display: flex; align-items: center; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; }
.toggle-row input { width: 20px; height: 20px; }
.table-actions { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 14px; }
.table-actions div { display: flex; gap: 8px; }
.small-button { border: 1px solid var(--line); border-radius: 11px; background: white; color: var(--green); padding: 9px 12px; font-weight: 800; text-decoration: none; }
.danger-button { color: #b43c31; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table { border-collapse: collapse; min-width: 760px; width: 100%; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: center; font-size: .88rem; }
th { background: var(--green-soft); color: var(--green); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td button { border: 0; background: transparent; font-weight: 800; }
.edit-record { color: var(--blue); }
.delete-record { color: #b43c31; }
.logout-button { border: 0; background: transparent; color: var(--muted); text-decoration: underline; }
[hidden] { display: none !important; }

@media (max-width: 720px) {
  .site-header { width: min(100% - 24px, 1080px); }
  main { width: min(100% - 22px, 920px); }
  .hero { min-height: 300px; padding: 34px 26px; border-radius: 26px; }
  .goal-badge { width: 112px; height: 112px; flex-basis: 112px; position: absolute; right: -10px; bottom: 20px; opacity: .92; }
  .goal-badge strong { font-size: 2.7rem; }
  .progress-card { margin: -24px 10px 20px; padding: 24px 20px; }
  .science-unlock { margin: 0 10px 20px; grid-template-columns: auto 1fr; padding: 20px; }
  .science-button { grid-column: 1 / -1; width: 100%; }
  .record-card, .rules { border-radius: 22px; }
  .card-title-row { align-items: flex-start; flex-direction: column; }
  .rule-grid { grid-template-columns: 1fr 1fr; }
  .admin-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 430px) {
  .hero h1 { font-size: 2.6rem; }
  .hero-sub { max-width: 240px; }
  .goal-badge { right: -26px; }
  .progress-heading { align-items: center; }
  .progress-meta { font-size: .8rem; }
  .science-unlock { grid-template-columns: 1fr; text-align: center; }
  .science-unlock-icon { margin: 0 auto; }
  .rule-grid { grid-template-columns: 1fr; }
  .student-input-wrap { grid-template-columns: 1fr; }
  .goal-options { grid-template-columns: 1fr; }
  .goal-options span { min-height: 84px; grid-template-columns: 1fr auto; justify-items: start; align-items: center; text-align: left; padding: 12px 16px; }
  .goal-options strong { grid-row: 1 / span 2; grid-column: 2; }
  .secondary-button { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
