:root {
  --bg: #f7f9fb;
  --bg-raised: #ffffff;
  --bg-inset: #eef2f6;
  --border: #dfe6ec;
  --border-soft: #e9eef3;
  --text: #24313d;
  --text-muted: #64758a;

  --accent: #7497af;
  --accent-dark: #4f7191;
  --accent-darker: #385669;
  --accent-light: #e7eef3;
  --accent-soft: #d3e0e8;

  --sun: #f6c453;
  --sun-dark: #d9a520;
  --mint: #62c3a0;
  --mint-dark: #2f9c76;
  --coral: #ef8a6b;
  --coral-dark: #d4603d;
  --grape: #9b8bd6;

  --danger: #c0392b;
  --danger-soft: #fbe4e1;
  --ok-soft: #e4f6ef;

  --shadow-sm: 0 1px 3px rgba(36, 49, 61, 0.06);
  --shadow-md: 0 10px 26px rgba(36, 49, 61, 0.08);
  --shadow-lg: 0 20px 46px rgba(36, 49, 61, 0.13);
  --shadow-accent: 0 10px 22px rgba(79, 113, 145, 0.28);

  --radius: 16px;
  --radius-lg: 22px;
  --font-ui: 'Nunito', system-ui, sans-serif;
  --font-display: 'Fredoka', var(--font-ui);
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 76px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
}

::selection { background: var(--accent-soft); color: var(--accent-darker); }

a { color: var(--accent-dark); font-weight: 700; text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; margin: 0; }

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--accent-light);
  color: var(--accent-darker);
  padding: 1px 6px;
  border-radius: 6px;
}

.hidden { display: none !important; }

/* ---------- Buttons ---------- */

button { font: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }

.btn-primary, .btn-ghost, .btn-site {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.92rem;
  padding: 8px 18px;
  border: 2px solid transparent;
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--accent-dark); color: #fff; box-shadow: var(--shadow-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-darker); transform: translateY(-1px); text-decoration: none; }
.btn-ghost { background: var(--bg-raised); color: var(--accent-darker); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-light); }
.btn-lg { padding: 13px 26px; font-size: 1.02rem; }
.btn-site { background: var(--accent); color: #fff; }
.btn-site:hover { background: var(--accent-dark); text-decoration: none; }

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
}
.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent-darker);
  white-space: nowrap;
}
.logo:hover { text-decoration: none; }
.logo-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
.logo-tag {
  background: var(--sun);
  color: #5a4300;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.site-nav { display: flex; align-items: center; gap: 20px; }
.site-nav a:not(.btn-site) { color: var(--text-muted); font-size: 0.95rem; }
.site-nav a:not(.btn-site):hover { color: var(--accent-darker); text-decoration: none; }

/* ---------- Hero ---------- */

.hero {
  position: relative;
  background:
    radial-gradient(560px circle at 8% 10%, rgba(116, 151, 175, 0.18), transparent 60%),
    radial-gradient(480px circle at 92% 5%, rgba(246, 196, 83, 0.16), transparent 60%),
    radial-gradient(520px circle at 80% 100%, rgba(98, 195, 160, 0.12), transparent 60%),
    #fbfcfd;
  padding: 64px 20px 90px;
}
.hero-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 40px;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--accent-darker);
  font-weight: 800;
  font-size: 0.85rem;
  padding: 5px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.eyebrow::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 4px rgba(98, 195, 160, 0.2); }
.hero h1 {
  font-size: clamp(2.6rem, 7vw, 4.6rem);
  font-weight: 700;
  color: var(--accent-darker);
  margin: 18px 0 16px;
  letter-spacing: -0.01em;
}
.highlight { position: relative; color: var(--accent-dark); white-space: nowrap; }
.highlight::after {
  content: "";
  position: absolute;
  left: -2px; right: -2px; bottom: 0.08em;
  height: 0.3em;
  background: var(--sun);
  opacity: 0.55;
  border-radius: 6px;
  z-index: -1;
}
.hero p { font-size: 1.15rem; color: var(--text-muted); max-width: 540px; margin: 0 0 26px; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.countdown { font-weight: 800; color: var(--accent-dark); font-size: 0.95rem; }
.hero-art img {
  display: block;
  width: 182px;
  height: auto;
  filter: drop-shadow(0 18px 24px rgba(36, 49, 61, 0.16));
  animation: bob 4s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-10px); } }
@media (prefers-reduced-motion: reduce) { .hero-art img { animation: none; } }

.stats {
  max-width: 1080px;
  margin: 44px auto 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.stat {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}
.stat-num { font-family: var(--font-display); font-weight: 700; font-size: 2rem; color: var(--accent-darker); line-height: 1.1; }
.stat-label { color: var(--text-muted); font-weight: 700; font-size: 0.9rem; }
.stats-note { max-width: 1080px; margin: 10px auto 0 !important; font-size: 0.82rem !important; color: var(--text-muted); }

.hero-wave { position: absolute; left: 0; bottom: -1px; width: 100%; height: 60px; }
.hero-wave path { fill: var(--bg); }

/* ---------- Sections ---------- */

main { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
main > section { padding: 56px 0; }
main h2 { font-size: clamp(1.8rem, 4vw, 2.4rem); color: var(--accent-darker); }
.section-sub { color: var(--text-muted); margin: 8px 0 24px; font-size: 1.05rem; }

.reveal { opacity: 0; transform: translateY(28px); transition: opacity 0.7s ease, transform 0.7s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- Challenge ---------- */

.day-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.day-kicker { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8rem; font-weight: 800; color: var(--accent); }
.day-head h2 { margin: 4px 0 10px; }
.ch-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.ch-date { color: var(--text-muted); font-weight: 700; font-size: 0.95rem; }
.day-head-side { display: flex; align-items: center; gap: 14px; }
.back-link { font-size: 0.95rem; }

.chip { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 12px; font-size: 0.82rem; font-weight: 800; white-space: nowrap; }
.chip-easy { background: #e4f6ef; color: #23785b; }
.chip-medium { background: #fff3d1; color: #8a6400; }
.chip-hard { background: #fde8e1; color: #b44a2b; }

.solved-badge { display: inline-flex; align-items: center; gap: 6px; background: var(--mint); color: #fff; font-weight: 800; font-size: 0.9rem; padding: 6px 14px 6px 10px; border-radius: 999px; box-shadow: 0 8px 18px rgba(98, 195, 160, 0.3); }
.solved-badge svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

.workspace { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 18px; align-items: start; }
.card { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }

.brief { padding: 26px; }
.brief h3 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin-bottom: 10px; }
.prompt p { margin: 0 0 8px; }
.prompt ul { margin: 4px 0 10px; padding-left: 22px; }
.brief h4 { font-size: 1.05rem; color: var(--accent-darker); margin: 22px 0 10px; }

.example { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; background: var(--bg-inset); border-radius: 12px; margin-bottom: 8px; font-size: 0.92rem; }
.example code { background: var(--bg-raised); }
.example .arrow { color: var(--text-muted); font-weight: 700; font-size: 0.82rem; }
.example-out { flex-direction: column; align-items: stretch; gap: 6px; }
.example-out pre, .solution pre, .r-detail pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  background: var(--bg-raised);
  border-radius: 8px;
  padding: 8px 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

.hint { background: #fff8e3; border: 2px dashed var(--sun); border-radius: 12px; padding: 10px 14px; margin: 0 0 10px; }
.hint-num { display: inline-block; font-weight: 800; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: #8a6400; margin-right: 4px; }

.solution { margin-top: 18px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.solution summary { padding: 10px 14px; font-weight: 800; color: var(--accent-darker); cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
.solution summary::-webkit-details-marker { display: none; }
.solution summary::before { content: ""; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform 0.2s; }
.solution[open] summary::before { transform: rotate(45deg); }
.solution.locked summary { color: var(--text-muted); cursor: default; font-weight: 700; }
.solution.locked summary::before { border: 2px solid currentColor; border-radius: 3px; width: 10px; height: 8px; transform: none; }
.solution pre { margin: 0 12px 12px; background: var(--bg-inset); }
.solution pre code { background: none; padding: 0; color: var(--text); font-size: 1em; }

/* ---------- Editor ---------- */

.editor-card { overflow: hidden; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px 12px 18px; border-bottom: 1px solid var(--border-soft); flex-wrap: wrap; }
.panel-title { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 0.9rem; font-weight: 600; color: var(--accent-darker); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--mint); }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.editor-wrap { display: flex; height: 320px; background: #fbfcfd; }
.gutter {
  margin: 0;
  padding: 14px 10px 14px 14px;
  min-width: 46px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  line-height: 1.6;
  color: #a6b4c2;
  background: var(--bg-inset);
  overflow: hidden;
  user-select: none;
}
#editor {
  flex: 1;
  border: 0;
  outline: 0;
  resize: none;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text);
  background: transparent;
  white-space: pre;
  overflow: auto;
  tab-size: 4;
}

.console { border-top: 1px solid var(--border-soft); background: #24313d; color: #e6edf3; }
.console-head { display: flex; justify-content: space-between; padding: 8px 16px; font-size: 0.8rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: #9fb0c0; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.status { text-transform: none; letter-spacing: 0; font-weight: 700; }
.status.ok { color: #7fd8b5; }
.status.err { color: #f2a28a; }
.output { margin: 0; padding: 12px 16px 16px; min-height: 96px; max-height: 220px; overflow: auto; font-family: var(--font-mono); font-size: 0.88rem; white-space: pre-wrap; word-break: break-word; }
.output .muted { color: #8496a8; }
.output .err-line { color: #f5a78f; }

.results { padding: 16px 18px 18px; border-top: 1px solid var(--border-soft); }
.result-summary { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; padding: 10px 14px; border-radius: 12px; margin-bottom: 12px; }
.result-summary.pass { background: var(--ok-soft); color: var(--mint-dark); }
.result-summary.fail { background: #fff3ee; color: var(--coral-dark); }
.result-summary pre { margin: 8px 0 0; font-family: var(--font-mono); font-size: 0.86rem; white-space: pre-wrap; color: var(--danger); }
.result-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.result-list li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; background: var(--bg-inset); }
.result-list li > div { min-width: 0; flex: 1; }
.r-icon { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; margin-top: 1px; }
.r-icon svg { width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.ok .r-icon { background: var(--mint); }
.bad .r-icon { background: var(--coral); }
.r-detail { display: grid; grid-template-columns: 70px 1fr; gap: 8px; align-items: start; margin-top: 6px; font-size: 0.82rem; }
.r-detail span { font-weight: 800; color: var(--text-muted); padding-top: 6px; }

/* ---------- Archive ---------- */

.archive-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.day-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  text-align: left;
  padding: 16px 18px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.day-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--accent); }
.day-card.solved { border-color: var(--mint); background: #f7fcfa; }
.dc-top { display: flex; justify-content: space-between; align-items: center; }
.dc-num { font-size: 0.78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); }
.dc-check { width: 22px; height: 22px; border-radius: 50%; background: var(--mint); display: grid; place-items: center; }
.dc-check svg { width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.dc-title { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; color: var(--accent-darker); line-height: 1.25; }
.dc-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 4px; }
.dc-foot .chip { font-size: 0.75rem; padding: 2px 10px; }
.dc-date { font-size: 0.85rem; color: var(--text-muted); }
.archive-more { margin-top: 18px; }
.empty { grid-column: 1 / -1; background: var(--bg-raised); border: 2px dashed var(--border); border-radius: var(--radius); padding: 24px; color: var(--text-muted); margin: 0; }

/* ---------- How it works ---------- */

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 24px 0 28px; }
.step { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow-sm); }
.step-num { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; color: #fff; margin-bottom: 14px; }
.step:nth-child(1) .step-num { background: var(--mint); }
.step:nth-child(2) .step-num { background: var(--sun-dark); }
.step:nth-child(3) .step-num { background: var(--coral); }
.step h3 { font-size: 1.3rem; color: var(--accent-darker); margin-bottom: 6px; }
.step p { margin: 0; color: var(--text-muted); }
.step strong { color: var(--text); }

.teacher {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 26px 28px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--accent-light), #f3f0fb);
  border: 1px solid var(--accent-soft);
}
.teacher h3 { font-size: 1.4rem; color: var(--accent-darker); margin-bottom: 6px; }
.teacher p { margin: 0; color: var(--text); max-width: 680px; }

/* ---------- Footer ---------- */

.site-footer { text-align: center; padding: 34px 20px 44px; color: var(--text-muted); border-top: 1px solid var(--border-soft); font-size: 0.95rem; }
.site-footer p { margin: 4px 0; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-raised);
  border: 2px solid var(--mint);
  border-radius: var(--radius);
  padding: 12px 18px 12px 12px;
  box-shadow: var(--shadow-lg);
  animation: pop 0.35s ease;
  max-width: calc(100vw - 40px);
}
.toast strong { display: block; font-family: var(--font-display); font-size: 1.15rem; color: var(--mint-dark); }
.toast span { font-size: 0.92rem; color: var(--text-muted); }
@keyframes pop { from { transform: translateY(20px); opacity: 0; } }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .teacher { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 720px) {
  .site-nav a:not(.btn-site) { display: none; }
  .hero { padding: 40px 16px 80px; }
  .hero-inner { grid-template-columns: 1fr; gap: 0; }
  .hero-art { display: none; }
  .stats { gap: 8px; margin-top: 32px; }
  .stat { padding: 12px; }
  .stat-num { font-size: 1.5rem; }
  .stat-label { font-size: 0.78rem; line-height: 1.3; }
  main { padding: 0 16px; }
  .brief { padding: 20px; }
  .editor-wrap { height: 280px; }
  .logo-tag { display: none; }
}

@media (max-width: 420px) {
  .header-inner { padding: 10px 16px; }
  .logo { font-size: 1.1rem; gap: 8px; }
  .logo-mark { width: 32px; height: 32px; }
  .btn-site { padding: 7px 14px; font-size: 0.85rem; }
}
