:root {
  --night: #173a38;
  --night-2: #20504c;
  --night-3: #2b625d;
  --gold: #d8b25c;
  --gold-soft: #ead39a;
  --gold-ink: #8a6a22;
  --paper: #eef1ea;
  --grid: #dbe3da;
  --ink: #1b2e2c;
  --muted: #566862;
  --line: #c9d4cb;

  --f-head: "LXGW WenKai TC", "BiauKai", "DFKai-SB", "Kaiti TC", serif;
  --f-body: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  --f-math: "STIX Two Text", "Cambria Math", "Times New Roman", serif;

  --wrap: min(1160px, 100% - 2 * clamp(20px, 6vw, 72px));
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.8 var(--f-body); -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 700; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; padding: 8px 14px; background: #fff; color: var(--ink); }
.skip-link:focus { left: 8px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 30;
  height: 64px; padding: 0 max(20px, calc((100% - 1240px) / 2));
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  background: color-mix(in srgb, var(--night) 94%, transparent);
  backdrop-filter: blur(8px);
  color: #e9efe9;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; color: var(--gold); }
.brand-text { font: 600 17px/1.1 var(--f-math); letter-spacing: .08em; }
.brand-text small { display: block; margin-top: 3px; font: 400 11px/1 var(--f-body); letter-spacing: .2em; color: #a9bcb5; }
.site-nav { display: flex; align-items: center; gap: clamp(18px, 2.6vw, 34px); font-size: 14px; }
.site-nav a { text-decoration: none; }
.site-nav > a:not(.nav-cta) { color: #c9d6d0; padding: 6px 0; border-bottom: 1px solid transparent; transition: color .15s, border-color .15s; }
.site-nav > a:not(.nav-cta):hover { color: #fff; border-color: var(--gold); }
.nav-cta { padding: 8px 16px; border-radius: 999px; background: var(--gold); color: var(--night); font-weight: 700; }
.nav-cta:hover { background: var(--gold-soft); }
.menu-toggle { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 28px; border-radius: 999px;
  font: 700 15px/1 var(--f-body); letter-spacing: .06em; text-decoration: none;
  transition: background-color .15s, box-shadow .15s;
}
.btn-gold { background: var(--gold); color: var(--night); box-shadow: 0 0 0 0 rgba(216,178,92,.0); }
.btn-gold:hover { background: var(--gold-soft); box-shadow: 0 0 0 6px rgba(216,178,92,.18); }
.btn-teal { background: var(--night); color: #fff; }
.btn-teal:hover { background: var(--night-2); }
.btn-block { width: 100%; }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.02fr); align-items: center; gap: clamp(24px, 5vw, 72px);
  padding: clamp(48px, 8vw, 96px) max(clamp(20px, 6vw, 72px), calc((100% - 1160px) / 2)) clamp(56px, 8vw, 104px);
  background:
    radial-gradient(ellipse 60% 70% at 78% 45%, rgba(216,178,92,.10), transparent 70%),
    var(--night);
  color: #e6ede8;
}
.hero h1 { display: grid; gap: 4px; }
.h1-year { font: 700 clamp(20px, 2.2vw, 26px)/1.2 var(--f-head); color: var(--gold); letter-spacing: .12em; }
.h1-name {
  font: italic 500 clamp(56px, 9vw, 116px)/.95 var(--f-math);
  letter-spacing: .01em; color: #fff;
  margin-left: -.04em;
}
.h1-zh { font: 700 clamp(34px, 4.6vw, 58px)/1.25 var(--f-head); letter-spacing: .18em; color: #f1ece0; }
.hero-lede { max-width: 30em; margin-top: 24px; color: #b9cbc4; font-size: 16px; line-height: 1.95; }

.hero-highlights { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.hero-highlights a { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; padding: 9px 13px; border: 1px solid var(--night-3); border-radius: 4px; background: rgba(255,255,255,.04); text-decoration: none; font-size: 14px; line-height: 1.5; }
.hero-highlights a:hover { border-color: var(--gold); background: rgba(255,255,255,.08); }
.hero-highlights b { color: var(--gold-soft); font-weight: 700; }
.hero-highlights span { color: #f3f6f2; }

.hero-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 32px; max-width: 520px; margin: 30px 0 0; }
.hero-facts div { padding-left: 14px; border-left: 2px solid var(--night-3); }
.hero-facts dt { font-size: 12px; color: #8fa8a0; letter-spacing: .1em; }
.hero-facts dd { margin: 2px 0 0; font-size: 15px; font-weight: 500; color: #f3f6f2; line-height: 1.6; }
.hero-facts .is-deadline { border-left-color: var(--gold); }
.hero-facts .is-deadline dd { color: var(--gold-soft); }

.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 26px; margin-top: 36px; }
.hero-link { color: #dbe5e0; font-size: 15px; text-decoration: underline; text-decoration-color: rgba(216,178,92,.6); text-underline-offset: 6px; }
.hero-link:hover { color: #fff; text-decoration-color: var(--gold); }

.hero-plot { margin: 0; justify-self: end; width: min(100%, 560px); }
.hero-plot svg { width: 100%; height: auto; aspect-ratio: 1; overflow: visible; }
.plot-grid { color: rgba(255,255,255,.12); }
.plot-axes line { stroke: rgba(230,237,232,.45); stroke-width: .012; }
.plot-ticks text { fill: #9fb4ad; font: italic .2px var(--f-math); }
.plot-asymptote { stroke: rgba(216,178,92,.45); stroke-width: .012; stroke-dasharray: .06 .06; }
.petals path { fill: rgba(216,178,92,.07); stroke: rgba(216,178,92,.42); stroke-width: .02; stroke-linejoin: round; }
.folium path { fill: none; stroke: var(--gold); stroke-width: .04; stroke-linecap: round; stroke-linejoin: round; }
.folium .d2 { fill: rgba(216,178,92,.14); }
.plot-star { fill: #fff; filter: drop-shadow(0 0 .08px #fff); }
.plot-origin { fill: var(--gold); }
.hero-plot figcaption { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; justify-content: flex-end; margin-top: 10px; color: #93aaa2; font-size: 13px; }
.eq { font: italic 500 20px/1 var(--f-math); color: var(--gold-soft); }
.eq i { font-style: italic; }
.eq sup { font-size: .6em; }

/* The one orchestrated moment: the curve draws itself, then the petals bloom */
@media (prefers-reduced-motion: no-preference) {
  .draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.1s cubic-bezier(.6,.1,.3,1) forwards; }
  .folium .d2 { fill-opacity: 0; animation: draw 1.4s cubic-bezier(.6,.1,.3,1) .7s forwards, fillin .8s ease 1.9s forwards; }
  .folium .d3 { animation-delay: 1.9s; }
  .petals path { opacity: 0; transform-origin: 0 0; animation: bloom .9s ease forwards; }
  .petals path:nth-child(1) { animation-delay: 2.3s; }
  .petals path:nth-child(2) { animation-delay: 2.45s; }
  .petals path:nth-child(3) { animation-delay: 2.6s; }
  .plot-star { opacity: 0; animation: twinkle .6s ease 2.1s forwards; }
}
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fillin { from { fill-opacity: 0; } to { fill-opacity: 1; } }
@keyframes bloom { to { opacity: 1; } }
@keyframes twinkle { 0% { opacity: 0; } 60% { opacity: 1; } 100% { opacity: .9; } }

/* ---------- Sections ---------- */
.section { padding: clamp(64px, 9vw, 112px) max(clamp(20px, 6vw, 72px), calc((100% - 1160px) / 2)); }
.section h2 { font: 700 clamp(32px, 4vw, 46px)/1.3 var(--f-head); color: var(--night); letter-spacing: .04em; }
.section-head { display: grid; grid-template-columns: auto minmax(0, 30em); justify-content: space-between; align-items: end; gap: 16px 48px; margin-bottom: 44px; }
.section-head p { color: var(--muted); font-size: 15px; }

/* graph paper */
.about, .info {
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: -1px -1px;
}

/* ---------- About ---------- */
.about-head { display: grid; grid-template-columns: 1fr; gap: 24px; }
.features { list-style: none; margin: 40px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.features li { padding: 26px 22px 24px; background: #fff; border: 1px solid var(--line); border-radius: 4px; }
.glyph { display: block; height: 64px; font: 400 56px/1 var(--f-math); color: var(--gold-ink); }
.features h3 { margin-top: 14px; font: 700 21px/1.4 var(--f-head); color: var(--night); }
.features p { margin-top: 6px; color: var(--muted); font-size: 14px; line-height: 1.85; }

/* ---------- Program ---------- */
.program { background: #f7f8f4; }
.days { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 28px; position: relative; }
.days::before { content: ""; position: absolute; left: 0; right: 0; top: 7px; height: 2px; background: var(--night); }
.day { position: relative; padding-top: 34px; }
.day::before { content: ""; position: absolute; top: 0; left: 0; width: 16px; height: 16px; border-radius: 50%; background: #f7f8f4; border: 2px solid var(--night); }
.day header { display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 0 10px; padding-bottom: 14px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.date { font: 600 40px/1 var(--f-math); color: var(--night); letter-spacing: -.01em; }
.weekday { font-size: 13px; color: var(--muted); }
.day h3 { grid-column: 1 / -1; margin-top: 8px; font: 700 20px/1.3 var(--f-head); color: var(--gold-ink); }
.slots { list-style: none; margin: 0; padding: 0; }
.slots li { display: grid; grid-template-columns: 46px 1fr; gap: 0 10px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.slots li:last-child { border-bottom: 0; }
.slots time { grid-row: span 2; font: 500 14px/1.6 var(--f-math); color: var(--muted); font-variant-numeric: tabular-nums; }
.slots b { font-weight: 500; font-size: 15px; line-height: 1.6; }
.slots span { font-size: 13px; color: var(--muted); }
.slots .hack { margin: 2px -10px; padding: 12px 10px; background: var(--night); color: #fff; border-radius: 4px; border-bottom: 0; }
.slots .hack time, .slots .hack span { color: #a9c0b8; }
.slots .hack b { color: var(--gold-soft); }

.poster-link { display: inline-flex; align-items: center; gap: 18px; margin-top: 48px; padding: 10px 26px 10px 10px; background: #fff; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; transition: border-color .15s; }
.poster-link:hover { border-color: var(--night); }
.poster-link img { width: 64px; height: 90px; object-fit: cover; object-position: top; border-radius: 3px; }
.poster-link span { display: grid; font-size: 13px; color: var(--muted); }
.poster-link b { font-size: 16px; color: var(--night); font-weight: 700; }

/* ---------- Awards ---------- */
.awards { background: var(--night); color: #dfe8e3; }
.awards h2 { color: #fff; }
.awards-grid { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 40px clamp(40px, 7vw, 96px); align-items: start; }
.awards-copy p { margin-top: 18px; max-width: 26em; color: #b9cbc4; font-size: 16px; line-height: 1.95; }
.awards-copy .awards-extra { padding-top: 18px; border-top: 1px solid rgba(255,255,255,.16); font-size: 14px; color: #9fb4ad; }

.s1 { --c: #f0d389; } .s2 { --c: #d8b25c; } .s3 { --c: #ad8a3f; } .s4 { --c: #6f8f7f; } .s0 { --c: rgba(255,255,255,.08); }
.dist-bar { display: flex; height: 54px; border-radius: 4px; overflow: hidden; gap: 2px; }
.seg { flex: var(--w) 0 0; background: var(--c); }
.dist-scale { position: relative; height: 26px; margin-top: 6px; font: 500 13px/1 var(--f-math); color: #8fa8a0; }
.dist-scale span { position: absolute; left: calc(var(--at) * 1%); transform: translateX(-50%); padding-top: 8px; }
.dist-scale span::before { content: ""; position: absolute; left: 50%; top: 0; height: 5px; width: 1px; background: #8fa8a0; }
.dist-scale span:first-child { transform: none; }
.dist-scale span:first-child::before { left: 0; }
.dist-scale span:last-child { transform: translateX(-100%); }
.dist-scale span:last-child::before { left: auto; right: 0; }

.prize-table { width: 100%; margin-top: 28px; border-collapse: collapse; }
.prize-table th, .prize-table td { padding: 15px 0; border-bottom: 1px solid rgba(255,255,255,.14); text-align: left; font-weight: 400; }
.prize-table thead th { padding: 0 0 10px; font-size: 12px; color: #8fa8a0; letter-spacing: .1em; }
.prize-table tbody th { font: 700 19px/1.3 var(--f-head); color: #fff; }
.prize-table td { color: #b9cbc4; font-size: 15px; }
.prize-table td:last-child, .prize-table thead th:last-child { text-align: right; }
.prize-table td:last-child { font: 600 22px/1 var(--f-math); color: var(--gold-soft); font-variant-numeric: tabular-nums; }
.sw { display: inline-block; width: 12px; height: 12px; margin-right: 12px; border-radius: 2px; background: var(--c); vertical-align: 1px; }

/* ---------- Info ---------- */
.info-grid { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 32px clamp(32px, 5vw, 64px); align-items: start; }
.fees { position: sticky; top: 88px; padding: 30px 30px 26px; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.fees h3, .details h3 { font: 700 21px/1.4 var(--f-head); color: var(--night); }
.fee-chart { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 12px; }
.fee-chart li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 14px; }
.fee-chart li::after { content: ""; grid-column: 1 / -1; height: 8px; border-radius: 4px; width: calc((var(--p) - 4000) / 1800 * 100%); background: var(--night); opacity: .85; }
.fee-chart li:first-child::after { background: var(--gold); opacity: 1; }
.fee-chart b { font: 600 18px/1.2 var(--f-math); font-variant-numeric: tabular-nums; }
.fee-note { margin: 20px 0 22px; padding-top: 14px; border-top: 1px dashed var(--line); color: var(--muted); font-size: 13px; }
.fee-deadline { margin-top: 12px; text-align: center; font-size: 13px; color: var(--gold-ink); font-weight: 500; }

.details { display: grid; gap: 14px; }
.details article { padding: 24px 28px; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.details p { margin-top: 8px; color: var(--muted); font-size: 15px; line-height: 1.9; max-width: 36em; }
.details .flag { padding: 8px 12px; background: #f7efd9; border-left: 3px solid var(--gold); color: var(--ink); border-radius: 0 3px 3px 0; }
.details strong { color: var(--gold-ink); }
.mail { color: var(--night); font-weight: 700; text-underline-offset: 4px; }

.fine-print { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 48px; margin-top: 48px; padding: 22px 0 0; border-top: 1px solid var(--line); }
.fine-print p { color: var(--muted); font-size: 13px; line-height: 1.85; }

/* ---------- Closing & footer ---------- */
.closing { padding: clamp(56px, 8vw, 88px) 24px; text-align: center; background: var(--night-2); color: #dfe8e3; }
.closing h2 { font: 700 clamp(26px, 3.4vw, 38px)/1.4 var(--f-head); color: #fff; letter-spacing: .03em; }
.closing p { margin: 10px 0 28px; color: #b9cbc4; }
.site-footer { display: flex; justify-content: space-between; gap: 16px; padding: 22px max(20px, calc((100% - 1160px) / 2)); background: var(--night); color: #8fa8a0; font-size: 13px; }
.site-footer a { color: var(--gold); text-underline-offset: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 1020px) {
  .features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .days { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px 28px; }
  .days::before { display: none; }
  .day::before { display: none; }
  .day { padding-top: 0; border-top: 2px solid var(--night); padding-top: 18px; }
}
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .hero-plot { justify-self: center; width: min(100%, 440px); order: -1; margin-bottom: -12px; }
  .hero-plot figcaption { justify-content: center; }
  .about-head, .section-head, .awards-grid, .info-grid, .fine-print { grid-template-columns: 1fr; }
  .fees { position: static; }
}
@media (max-width: 720px) {
  .menu-toggle { display: flex; width: 44px; height: 44px; flex-direction: column; justify-content: center; align-items: center; gap: 6px; border: 0; background: transparent; cursor: pointer; }
  .menu-toggle span { display: block; width: 22px; height: 2px; background: #e9efe9; transition: transform .18s; }
  .menu-toggle[aria-expanded="true"] span:first-child { transform: translateY(4px) rotate(45deg); }
  .menu-toggle[aria-expanded="true"] span:last-child { transform: translateY(-4px) rotate(-45deg); }
  .site-nav { display: none; position: absolute; left: 0; right: 0; top: 64px; flex-direction: column; align-items: stretch; gap: 0; padding: 8px 20px 20px; background: var(--night); border-top: 1px solid rgba(255,255,255,.1); }
  .site-nav.open { display: flex; }
  .site-nav > a:not(.nav-cta) { padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,.1); }
  .nav-cta { margin-top: 16px; text-align: center; padding: 12px; }
  .hero-facts { grid-template-columns: 1fr; }
  .features, .days { grid-template-columns: 1fr; }
  .features li { display: grid; grid-template-columns: 52px 1fr; padding: 20px; }
  .features .glyph { grid-row: span 2; height: auto; font-size: 40px; }
  .features h3 { margin-top: 0; }
  .h1-zh { letter-spacing: .1em; }
  .details article, .fees { padding: 22px 20px; }
  .prize-table tbody th { font-size: 17px; }
  .prize-table td:last-child { font-size: 18px; }
  .site-footer { flex-direction: column; }
}

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