:root {
  --ink: #1b1b2f;
  --muted: #5a5674;
  --paper: #fffdf6;
  --cream: #fff7e6;
  --pink: #ff8fb1;
  --yellow: #ffd23f;
  --teal: #2ec4b6;
  --purple: #7c5cff;
  --green: #4cc38a;
  --sky: #a9d9ff;
  --lav: #cdc0ff;
  --peach: #ffd6ba;
  --border: 3px solid var(--ink);
  --shadow: 6px 6px 0 var(--ink);
  --shadow-sm: 4px 4px 0 var(--ink);
  --radius: 22px;
  --maxw: 1160px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; scroll-padding-top: 92px; }

body {
  font-family: "Nunito", system-ui, -apple-system, Segoe UI, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, #fff7fb 0%, #f4f9ff 45%, #f2fff9 100%);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .brand, .btn, .pill, .chip, .when, .extras-title, .station-label {
  font-family: "Fredoka", "Nunito", sans-serif;
  font-weight: 600;
}

a { color: inherit; text-decoration: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- background ---------- */
#scene-container { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
#scene-container canvas { display: block; }

.bg-doodles {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.6;
  background-image:
    radial-gradient(rgba(255, 143, 177, 0.28) 2.5px, transparent 3px),
    radial-gradient(rgba(46, 196, 182, 0.26) 2.5px, transparent 3px);
  background-size: 96px 96px, 128px 128px;
  background-position: 0 0, 48px 64px;
  mask-image: radial-gradient(circle at 50% 20%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(circle at 50% 20%, #000 0%, transparent 78%);
}

main, .toolbar, .footer { position: relative; z-index: 2; }

/* ---------- toolbar ---------- */
.toolbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  max-width: var(--maxw); margin: 0 auto;
  padding: 0.7rem 1.1rem;
  background: rgba(255, 253, 246, 0.9);
  backdrop-filter: blur(12px);
  border: var(--border);
  border-top: none;
  border-radius: 0 0 20px 20px;
}

.brand { display: flex; align-items: center; gap: 0.55rem; font-size: 1.25rem; font-weight: 700; }
.brand-light { color: var(--pink); }
.brand-dot {
  width: 18px; height: 18px; border-radius: 50% 50% 50% 4px;
  background: linear-gradient(135deg, var(--yellow), var(--pink));
  border: 3px solid var(--ink); transform: rotate(-12deg);
}

.toolbar-links { display: flex; align-items: center; gap: 0.4rem; font-weight: 700; font-size: 0.92rem; }
.toolbar-links a { padding: 0.35rem 0.85rem; border-radius: 999px; transition: background 0.15s ease; }
.toolbar-links a:hover { background: var(--lav); }

.toolbar-actions { display: flex; align-items: center; gap: 0.55rem; }
.toolbar-toggle { display: none; background: none; border: none; cursor: pointer; }
.toolbar-toggle span { display: block; width: 26px; height: 3px; margin: 5px 0; background: var(--ink); border-radius: 3px; }

/* ---------- hero ---------- */
.hero {
  max-width: var(--maxw); margin: 0 auto;
  padding: 3.2rem 1.1rem 2.6rem;
  display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 3rem; align-items: center;
  min-height: 72vh;
}

.hero-copy { max-width: 620px; }

.pill {
  display: inline-block; background: var(--yellow); border: var(--border); border-radius: 999px;
  padding: 0.32rem 0.95rem; font-size: 0.82rem; margin-bottom: 1.3rem; box-shadow: 3px 3px 0 var(--ink);
}

.hero h1 { font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.1; margin-bottom: 1.2rem; }

.hl { position: relative; z-index: 0; white-space: nowrap; }
.hl::after {
  content: ""; position: absolute; left: -3px; right: -3px; bottom: 0.04em; height: 0.44em;
  border-radius: 8px; z-index: -1; transform: rotate(-1.2deg);
}
.hl-pink::after { background: var(--pink); }
.hl-teal::after { background: var(--teal); }
.hl-yellow::after { background: var(--yellow); }
.hl-violet::after { background: var(--lav); }

.hero-sub { font-size: 1.05rem; color: var(--muted); margin-bottom: 1.8rem; max-width: 54ch; }
.hero-actions { display: flex; gap: 0.8rem; flex-wrap: wrap; margin-bottom: 2rem; }
.hero-stats { display: flex; gap: 2.4rem; list-style: none; }
.hero-stats li { display: flex; flex-direction: column; }
.hero-stats strong { font-family: "Fredoka", sans-serif; font-size: 1.9rem; line-height: 1; }
.hero-stats span { font-size: 0.78rem; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; margin-top: 0.35rem; font-weight: 700; }

/* ---------- portrait ---------- */
.hero-visual { display: flex; flex-direction: column; align-items: center; gap: 0.9rem; }
.portrait {
  width: min(370px, 100%); padding: 6px; border: var(--border); border-radius: 50%;
  background: linear-gradient(140deg, var(--pink), var(--lav) 50%, var(--sky));
  box-shadow: 8px 8px 0 var(--ink); transform: rotate(-1.5deg);
}
.portrait-inner {
  position: relative; aspect-ratio: 1 / 1; border-radius: 50%; overflow: hidden;
  border: 3px solid var(--ink); background: radial-gradient(circle at 50% 30%, #fff, #f3edff);
}
.portrait-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 30%; display: block; }
.portrait-fallback {
  position: absolute; inset: 0; display: none; place-items: center;
  font-family: "Fredoka", sans-serif; font-size: 4rem; font-weight: 700; color: var(--purple);
  background: radial-gradient(circle at 50% 40%, rgba(255, 143, 177, 0.7), rgba(205, 192, 255, 0.7), #fff);
}
.portrait.is-missing .portrait-fallback { display: grid; }
.portrait-tag {
  position: absolute; left: 12px; bottom: 12px; z-index: 2; font-size: 0.76rem; font-weight: 700;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 999px; padding: 0.24rem 0.7rem;
}
.portrait-caption { font-size: 0.82rem; color: var(--muted); font-weight: 700; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block; padding: 0.7rem 1.4rem; border-radius: 999px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  border: var(--border); box-shadow: var(--shadow-sm);
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}
.btn:hover { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn-primary { background: var(--pink); color: #fff; }
.btn-ghost { background: var(--paper); color: var(--ink); }
.btn-small { padding: 0.42rem 0.9rem; font-size: 0.84rem; box-shadow: 3px 3px 0 var(--ink); }

/* ---------- puzzle ---------- */
.puzzle-section { max-width: var(--maxw); margin: 0 auto; padding: 3rem 1.1rem 4rem; }
.adventure-head { text-align: center; max-width: 660px; margin: 0 auto 2.2rem; }
.adventure-head h2 { font-size: clamp(1.7rem, 3.8vw, 2.5rem); margin-bottom: 0.6rem; }
.adventure-head p { color: var(--muted); }
.progress-pill {
  display: inline-block; margin-left: 0.4rem; font-family: "Fredoka", sans-serif; font-weight: 600;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 999px; padding: 0.1rem 0.7rem; font-size: 0.85rem;
}

.puzzle { position: relative; width: min(760px, 100%); margin: 0 auto; aspect-ratio: 720 / 440; }
.puzzle-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

.puzzle-piece {
  stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; cursor: pointer;
  transition: transform 0.18s ease, filter 0.18s ease;
  transform-box: fill-box; transform-origin: center;
}
.puzzle-piece:hover { filter: brightness(1.05); transform: translateY(-6px); }
.puzzle-piece.is-found { stroke-width: 5; filter: saturate(1.25) brightness(1.03); }

.puzzle-icons { position: absolute; inset: 0; pointer-events: none; }

.piece-btn {
  position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  background: none; border: none; cursor: pointer; font: inherit; color: inherit;
  pointer-events: auto;
}
.piece-art {
  position: relative; width: 104px; height: 104px; display: grid; place-items: center;
  filter: drop-shadow(0 6px 0 rgba(47, 43, 69, 0.16));
  transition: transform 0.18s ease, filter 0.18s ease;
}
.piece-art svg { width: 104px; height: 104px; display: block; }
.piece-btn:hover .piece-art,
.piece-btn:focus-visible .piece-art {
  transform: translateY(-6px) scale(1.06);
  filter: drop-shadow(0 10px 0 rgba(47, 43, 69, 0.18));
}
.piece-btn:focus-visible { outline: none; }

.piece-label {
  background: var(--paper); border: 3px solid var(--ink); border-radius: 999px;
  padding: 0.14rem 0.72rem; font-size: 0.82rem; font-family: "Fredoka", sans-serif;
  font-weight: 600; box-shadow: 3px 3px 0 var(--ink); white-space: nowrap;
}
.piece-check {
  position: absolute; top: -10px; right: -10px; width: 30px; height: 30px;
  display: none; place-items: center; background: var(--green); color: #fff;
  border: 3px solid var(--ink); border-radius: 50%; font-weight: 700; font-size: 0.95rem;
}
.piece-btn.is-found .piece-check { display: grid; animation: check-pop 0.35s ease; }
@keyframes check-pop {
  0% { transform: scale(0) rotate(-25deg); }
  70% { transform: scale(1.25) rotate(6deg); }
  100% { transform: scale(1) rotate(0); }
}
.puzzle-note { text-align: center; margin-top: 1.4rem; color: var(--muted); font-weight: 700; }

.progress-pill.is-complete { background: var(--green); color: #fff; }

.reset-btn {
  display: inline-block; margin-left: 0.5rem; font-family: "Fredoka", sans-serif; font-weight: 600;
  font-size: 0.82rem; cursor: pointer; background: var(--paper); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 999px; padding: 0.12rem 0.7rem;
  box-shadow: 3px 3px 0 var(--ink); transition: transform 0.14s ease, box-shadow 0.14s ease;
}
.reset-btn:hover { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

.puzzle-toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--green); color: #fff; border: 3px solid var(--ink);
  border-radius: 999px; padding: 0.5rem 1.1rem;
  font-family: "Fredoka", sans-serif; font-weight: 600; box-shadow: var(--shadow-sm);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.puzzle-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.puzzle-complete {
  text-align: center; margin: 0 auto 1.6rem; max-width: 640px;
  background: var(--green); color: #fff; border: 3px solid var(--ink);
  border-radius: 999px; padding: 0.6rem 1.2rem; font-family: "Fredoka", sans-serif;
  font-weight: 600; box-shadow: var(--shadow-sm); animation: check-pop 0.4s ease;
}
.confetti {
  position: fixed; top: -40px; z-index: 70; pointer-events: none;
  animation: confetti-fall 3s linear forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(360deg); opacity: 0.85; }
}

/* ---------- contact strip ---------- */
.contact-strip { max-width: var(--maxw); margin: 0 auto; padding: 1rem 1.1rem 5rem; }
.cta-card {
  text-align: center; background: var(--yellow); border: var(--border); border-radius: 30px;
  padding: 3rem 2rem; box-shadow: 10px 10px 0 var(--ink);
}
.cta-card h2 { font-size: clamp(1.7rem, 3.8vw, 2.5rem); margin-bottom: 0.8rem; }
.cta-card p { max-width: 52ch; margin: 0 auto 1.9rem; font-weight: 600; }
.cta-actions { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; }
.contact-meta { list-style: none; display: flex; gap: 1.6rem; justify-content: center; flex-wrap: wrap; margin-top: 1.8rem; font-size: 0.9rem; font-weight: 700; }

/* ---------- footer ---------- */
.footer { text-align: center; padding: 2.4rem 1.1rem 3rem; border-top: var(--border); background: rgba(255, 253, 246, 0.85); font-weight: 700; }
.footer-sub { font-size: 0.82rem; color: var(--muted); margin-top: 0.3rem; font-weight: 600; }

/* ---------- reveal ---------- */
.reveal { opacity: 0; transform: translateY(20px); transition: opacity 0.6s ease, transform 0.6s ease; }
.reveal.is-visible { opacity: 1; transform: none; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 1.2rem; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(27, 27, 47, 0.5); backdrop-filter: blur(4px); }
.modal-panel {
  position: relative; z-index: 1; width: min(880px, 100%); max-height: 88vh;
  display: flex; flex-direction: column; background: var(--paper);
  border: var(--border); border-radius: 26px; box-shadow: 10px 10px 0 var(--ink);
  animation: pop 0.25s ease;
}
@keyframes pop { from { transform: translateY(18px) scale(0.97); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-close {
  position: absolute; top: 14px; right: 14px; z-index: 3; width: 42px; height: 42px;
  display: grid; place-items: center; font-size: 1.5rem; line-height: 1; cursor: pointer;
  background: var(--paper); border: var(--border); border-radius: 50%; box-shadow: 3px 3px 0 var(--ink);
}
.modal-close:hover { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.modal-body { overflow: auto; padding: 2.4rem 2rem 2rem; }
.modal-title { font-size: clamp(1.6rem, 3.6vw, 2.3rem); margin-bottom: 1rem; }
.modal-lead { color: var(--muted); margin-bottom: 1.4rem; }
body.modal-open { overflow: hidden; }

/* ---------- shared content ---------- */
.timeline { list-style: none; position: relative; padding-left: 2rem; display: flex; flex-direction: column; gap: 1.3rem; }
.timeline::before {
  content: ""; position: absolute; left: 7px; top: 10px; bottom: 10px; width: 4px; border-radius: 4px;
  background: linear-gradient(180deg, var(--teal), var(--purple), var(--pink));
}
.timeline-item { position: relative; }
.timeline-marker { position: absolute; left: -2rem; top: 1.5rem; width: 18px; height: 18px; border-radius: 50%; background: var(--yellow); border: 3px solid var(--ink); }
.timeline-edu .timeline-marker { background: var(--lav); }
.timeline-card { background: var(--paper); border: var(--border); border-radius: 18px; padding: 1.2rem 1.3rem; box-shadow: var(--shadow-sm); }
.timeline-head { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; flex-wrap: wrap; }
.timeline-head h3 { font-size: 1.08rem; }
.when { background: var(--sky); border: 2px solid var(--ink); border-radius: 999px; padding: 0.08rem 0.65rem; font-size: 0.78rem; white-space: nowrap; }
.timeline-edu .when { background: var(--lav); }
.where { color: var(--purple); font-weight: 800; margin: 0.25rem 0 0.7rem; font-size: 0.92rem; }
.timeline-card ul { margin-left: 1.1rem; display: flex; flex-direction: column; gap: 0.35rem; color: var(--muted); font-size: 0.92rem; }
.note { color: var(--muted); font-size: 0.9rem; }

.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.project-card { background: var(--paper); border: var(--border); border-radius: 18px; padding: 1.2rem; display: flex; flex-direction: column; gap: 0.7rem; box-shadow: var(--shadow-sm); transition: transform 0.16s ease, box-shadow 0.16s ease; }
.project-card:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow); }
.project-top { display: flex; align-items: center; gap: 0.8rem; }
.project-emoji { font-size: 1.3rem; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; border: 3px solid var(--ink); flex: none; }
.project-card h3 { font-size: 1rem; line-height: 1.3; }
.project-card p { color: var(--muted); font-size: 0.9rem; flex-grow: 1; }
.project-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag { font-size: 0.72rem; font-weight: 700; padding: 0.18rem 0.6rem; border: 2px solid var(--ink); border-radius: 999px; background: var(--sky); }
.project-link { align-self: flex-start; font-weight: 800; font-size: 0.88rem; color: var(--purple); }
.project-link:hover { color: var(--pink); }

.skills-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.skill-card { background: var(--paper); border: var(--border); border-radius: 18px; padding: 1.1rem 1.2rem; box-shadow: var(--shadow-sm); }
.skill-card h3 { margin-bottom: 0.7rem; font-size: 1rem; }
.skill-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chip { background: var(--cream); border: 2px solid var(--ink); border-radius: 999px; padding: 0.22rem 0.7rem; font-size: 0.78rem; font-weight: 700; }

.about-tags { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1.2rem 0; }
.facts { list-style: none; display: flex; flex-direction: column; gap: 0.7rem; margin-top: 0.6rem; }
.facts li { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 2px dashed rgba(27, 27, 47, 0.18); padding-bottom: 0.5rem; }
.facts span { color: var(--muted); font-weight: 700; }
.facts strong { font-family: "Fredoka", sans-serif; text-align: right; }

.extras-title { font-size: 1.1rem; margin: 1.6rem 0 0.9rem; }
.extras-title:first-of-type { margin-top: 0.4rem; }
.cert-list { list-style: none; display: flex; flex-direction: column; gap: 0.7rem; }
.cert-list li { display: flex; gap: 0.9rem; align-items: center; background: var(--paper); border: var(--border); border-radius: 16px; padding: 0.75rem 0.9rem; box-shadow: var(--shadow-sm); }
.cert-badge { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 12px; border: 3px solid var(--ink); font-family: "Fredoka", sans-serif; font-weight: 700; color: #fff; }
.cert-list strong { display: block; font-weight: 700; font-size: 0.95rem; }
.cert-list em { color: var(--muted); font-style: normal; font-size: 0.82rem; }
.pub-card { background: var(--paper); border: var(--border); border-radius: 16px; padding: 1rem 1.1rem; margin-bottom: 0.6rem; box-shadow: var(--shadow-sm); }
.pub-year { display: inline-block; font-size: 0.72rem; font-weight: 700; background: var(--yellow); border: 2px solid var(--ink); border-radius: 999px; padding: 0.08rem 0.6rem; margin-bottom: 0.5rem; }
.pub-card h4 { font-size: 0.98rem; margin-bottom: 0.3rem; line-height: 1.35; }
.pub-card p { color: var(--muted); font-size: 0.88rem; }
.pub-card a { color: var(--purple); font-weight: 700; }
.lang-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .toolbar-links {
    position: absolute; top: 100%; left: 0; right: 0; flex-direction: column;
    align-items: flex-start; gap: 0.35rem; background: var(--paper);
    border: var(--border); border-radius: 0 0 18px 18px; padding: 0.9rem 1.1rem 1.2rem; display: none;
  }
  .toolbar-links.open { display: flex; }
  .toolbar-toggle { display: block; }
  .hero { grid-template-columns: 1fr; gap: 2rem; min-height: auto; padding-top: 2rem; }
  .hero-visual { order: -1; }
  .portrait { width: min(250px, 62vw); }
}

@media (max-width: 760px) {
  .piece-art { width: 64px; height: 64px; }
  .piece-art svg { width: 64px; height: 64px; }
  .piece-label { font-size: 0.72rem; padding: 0.1rem 0.55rem; box-shadow: 2px 2px 0 var(--ink); }
  .piece-check { width: 24px; height: 24px; top: -8px; right: -8px; }
}

@media (max-width: 520px) {
  .hero-stats { gap: 1.4rem; }
  .contact-meta { flex-direction: column; gap: 0.4rem; }
  .portrait { width: min(185px, 54vw); }
  .portrait-caption { font-size: 0.76rem; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

/* ---------- print ---------- */
@media print {
  #scene-container, .bg-doodles, .toolbar-actions, .hero-visual, .puzzle, .puzzle-note, .adventure-head, .footer, .reveal { display: none !important; }
  body { background: #fff; color: #000; }
  .toolbar { position: static; border: none; background: #fff; }
  .contact-strip { padding: 0.5rem 0; }
  .cta-card, .timeline-card, .project-card, .cert-list li, .pub-card, .skill-card { box-shadow: none; border-color: #bbb; background: #fff; break-inside: avoid; }
  .hl::after { display: none; }
  a { text-decoration: underline; color: #000; }
}
