:root {
  /* Fixed accents — the same in both themes */
  --yellow: #ffd23f;
  --pink: #ff6b9d;
  --blue: #58a6ff;
  --green: #3ddc97;
  --orange: #ff8a3d;
  --purple: #b69cff;
  --coral: #ff9b73;
  --periwinkle: #8fa8ff;
  --ink: #1a1a1a;

  /* Dark theme (default) */
  --bg: #15111f;
  --surface: #211b33;
  --line: #f4efff;
  --text: #f4efff;
  --muted: #b3a9cc;
  --card-muted: var(--muted);
  --glass: rgba(33, 27, 51, 0.5);

  --radius: 18px;
  --border: 2.5px;
  --max: 960px;
  --font: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

:root[data-theme="light"] {
  --bg: #fff6e5;
  --surface: #ffffff;
  --line: #1a1a1a;
  --text: #1a1a1a;
  --muted: #5c5546;
  --card-muted: rgba(26, 26, 26, 0.78);
  --glass: rgba(255, 255, 255, 0.5);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background .25s ease, color .25s ease;
}
/* Keep the hero vertically centred and the footer at the bottom, whatever the view height. */
main { flex: 1; display: flex; flex-direction: column; justify-content: center; }

/* Subtle dotted background */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(var(--line) 1px, transparent 1.4px);
  background-size: 26px 26px;
  opacity: .1;
}

a { color: inherit; }
.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding-left: 24px; padding-right: 24px; }

button:focus-visible, a:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
  border-radius: 8px;
}

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 24px;
  padding-bottom: 24px;
}
.brand {
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: -0.04em;
  text-decoration: none;
}
.brand span { color: var(--pink); }
.brand:hover { transform: rotate(-3deg); }
.brand { display: inline-block; transition: transform .2s; }

.controls { display: flex; align-items: center; gap: 10px; }

.lang {
  display: inline-flex;
  background: var(--surface);
  border: var(--border) solid var(--line);
  border-radius: 999px;
  padding: 2px;
  box-shadow: 3px 3px 0 var(--line);
}
.lang button {
  font: inherit;
  font-size: .8rem;
  font-weight: 800;
  color: var(--text);
  background: none;
  border: 0;
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.lang button[aria-pressed="true"] { background: var(--yellow); color: var(--ink); }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--ink);
  background: var(--blue);
  border: var(--border) solid var(--line);
  border-radius: 50%;
  box-shadow: 3px 3px 0 var(--line);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.theme-toggle:hover { transform: translate(-1px, -1px) rotate(15deg); box-shadow: 4px 4px 0 var(--line); }
.theme-toggle:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--line); }
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

/* ---------- Hero ---------- */
.hero { position: relative; padding-top: 40px; padding-bottom: 40px; }
.eyebrow {
  display: inline-block;
  margin: 0 0 20px;
  padding: 4px 14px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--green);
  border: var(--border) solid var(--line);
  border-radius: 999px;
  transform: rotate(-2deg);
}
.hero h1 {
  margin: 0;
  font-size: clamp(2.1rem, 8vw, 5rem);
  text-wrap: balance;
  line-height: 1.02;
  font-weight: 800;
  letter-spacing: -0.045em;
}
.hero mark {
  display: inline-block;
  padding: 0 .12em;
  color: var(--ink);
  background: var(--purple);
  border: var(--border) solid var(--line);
  border-radius: .18em;
  transform: rotate(-2deg);
  box-shadow: 5px 5px 0 var(--line);
}
.wave { display: inline-block; transform-origin: 70% 70%; animation: wave 2.6s ease-in-out infinite; }
@keyframes wave {
  0%, 60%, 100% { transform: rotate(0); }
  10%, 30% { transform: rotate(16deg); }
  20%, 40% { transform: rotate(-10deg); }
  50% { transform: rotate(8deg); }
}
.lead {
  margin: 28px auto 32px;
  max-width: 46ch;
  font-size: 1.2rem;
  color: var(--muted);
}

.stickers { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.sticker {
  position: absolute;
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  font-size: 2.6rem;
  background: var(--surface);
  border: var(--border) solid var(--line);
  border-radius: 24px;
  box-shadow: 5px 5px 0 var(--line);
  animation: bob 4s ease-in-out infinite;
}
.s1 { left: 6px; top: 40px; --r: -8deg; background: var(--coral); }
.s2 { right: 6px; top: 70px; --r: 10deg; background: var(--blue); animation-delay: -1.3s; }
.s3 { left: 30px; top: 250px; --r: 5deg; background: var(--purple); animation-delay: -2.6s; }

/* Decorative emoji floating behind the whole page (fixed to the viewport) */
.floaters { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.floater {
  position: absolute;
  left: var(--x);
  top: var(--y);
  font-size: var(--s, 2.2rem);
  opacity: .55;
  animation: bob var(--t, 5s) ease-in-out var(--d, 0s) infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(var(--r)); }
  50% { transform: translateY(-14px) rotate(calc(var(--r) * -0.6)); }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 10px 22px;
  font-weight: 800;
  color: var(--ink);
  text-decoration: none;
  background: var(--yellow);
  border: var(--border) solid var(--line);
  border-radius: 999px;
  box-shadow: 4px 4px 0 var(--line);
  transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--line); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--line); }
.btn-pink { background: var(--pink); }
.btn-blue { background: var(--blue); }
.btn-green { background: var(--green); }
.btn-orange { background: var(--orange); }
button.btn { font: inherit; font-weight: 800; cursor: pointer; }
.btn-small { padding: 5px 16px; font-size: .88rem; box-shadow: 3px 3px 0 var(--line); }

.hero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }

/* ---------- Marquee ---------- */
/* Full-bleed tilted bar anchored to the middle of the glass panel, drawn behind it. */
/* --bar-y: where the bar crosses the panel. main.js aligns it to the title / panel header. */
.hero { --bar-y: 33%; }
.hero-stage { position: relative; width: 100%; }
.marquee {
  position: absolute;
  z-index: 0;
  top: var(--bar-y);
  transition: top .45s ease;
  left: 50%;
  width: 100vw;
  overflow: hidden;
  padding: 12px 0;
  color: var(--ink);
  background: var(--periwinkle);
  border-block: var(--border) solid var(--line);
  transform: translate(-50%, -50%) rotate(-4deg);
}

/* Frosted-glass panel: the bar shows through it, blurred. */
.hero-glass {
  position: relative;
  z-index: 1;
  width: fit-content;
  max-width: 720px;
  margin: 0 auto;
  padding: 38px 40px;
  text-align: center;
  background: var(--glass);
  border: var(--border) solid var(--line);
  border-radius: 28px;
  box-shadow: 8px 8px 0 var(--line);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
}
.marquee-track { display: flex; width: max-content; animation: scroll 32s linear infinite; }
.marquee-group { display: flex; flex-shrink: 0; }
.marquee-item { padding: 0 28px; font-size: 1.15rem; font-weight: 800; white-space: nowrap; }
.marquee-item::after { content: "✦"; margin-left: 56px; }
@keyframes scroll { to { transform: translateX(-50%); } }

/* ---------- Views inside the glass panel ---------- */
.view:not([hidden]) { animation: pop .35s ease-out; }
.view[hidden] { display: none; }
.view:focus { outline: none; }
@keyframes pop {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.view-panel { text-align: left; }
.hero:not([data-view="home"]) .hero-glass { min-width: min(100%, 540px); }
.hero[data-view="projects"] .hero-glass { width: 100%; max-width: none; }
.hero:not([data-view="home"]) .stickers { display: none; }

.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 28px; }
.section-title { margin: 0; font-size: 0; }
.section-title span {
  display: inline-block;
  padding: 6px 20px;
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
  background: var(--blue);
  border: var(--border) solid var(--line);
  border-radius: 14px;
  box-shadow: 4px 4px 0 var(--line);
  transform: rotate(-1.5deg);
}
#about .section-title span { background: var(--orange); transform: rotate(1.2deg); }
#contact .section-title span { background: var(--green); }
.prose { margin: 0; max-width: 56ch; font-size: 1.1rem; }

/* ---------- Project cards ---------- */
/* Two columns on desktop (a 2x2 grid with four cards), one on small screens. */
.grid { display: grid; gap: 28px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.card {
  --c: var(--yellow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 24px;
  color: var(--ink);
  text-decoration: none;
  background: var(--c);
  border: var(--border) solid var(--line);
  border-radius: var(--radius);
  box-shadow: 6px 6px 0 var(--line);
  transition: transform .2s ease, box-shadow .2s ease;
}
.card:nth-child(odd) { transform: rotate(-1.3deg); }
.card:nth-child(even) { transform: rotate(1.1deg); }
.card:hover { transform: rotate(0) translate(-3px, -5px); box-shadow: 10px 10px 0 var(--line); }
:root[data-theme="dark"] .card { color: var(--text); background: var(--surface); box-shadow: 6px 6px 0 var(--c); }
:root[data-theme="dark"] .card:hover { box-shadow: 10px 10px 0 var(--c); }

.card-emoji {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  font-size: 1.8rem;
  background: var(--surface);
  border: var(--border) solid var(--line);
  border-radius: 16px;
  transform: rotate(-6deg);
}
:root[data-theme="dark"] .card-emoji { background: var(--c); }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tag {
  padding: 1px 10px;
  font-size: .72rem;
  font-weight: 600;
  border: 1.5px solid currentColor;
  border-radius: 999px;
}
.card h3 { margin: 4px 0 0; font-size: 1.4rem; font-weight: 800; letter-spacing: -0.02em; }
.card p { flex: 1; margin: 0; font-size: .96rem; color: var(--card-muted); }
.card-cta { margin-top: 8px; font-weight: 800; }
.card-cta::after { content: " \2192"; display: inline-block; transition: transform .2s; }
.card:hover .card-cta::after { transform: translateX(6px); }

/* ---------- About ---------- */
.about-box {
  max-width: 640px;
  padding: 28px;
  background: var(--surface);
  border: var(--border) solid var(--line);
  border-radius: var(--radius);
  box-shadow: 6px 6px 0 var(--orange);
}
.about-box p { margin: 0 0 20px; font-size: 1.1rem; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; padding: 0; list-style: none; }
.chips li {
  padding: 4px 14px;
  font-weight: 600;
  color: var(--ink);
  border: var(--border) solid var(--line);
  border-radius: 999px;
}
.chips li:nth-child(1) { background: var(--blue); }
.chips li:nth-child(2) { background: var(--pink); }
.chips li:nth-child(3) { background: var(--green); }
.chips li:nth-child(4) { background: var(--yellow); }
.chips li:nth-child(5) { background: var(--orange); }

/* ---------- Contact ---------- */
.links { display: flex; flex-wrap: wrap; gap: 20px; margin: 28px 0 0; padding: 0; list-style: none; }

.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  padding: 0;
  color: var(--ink);
  background: var(--c, var(--yellow));
  border: var(--border) solid var(--line);
  border-radius: 20px;
  box-shadow: 4px 4px 0 var(--line);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.icon-btn svg { width: 30px; height: 30px; }
.icon-btn:hover, .icon-btn:focus-visible { transform: translate(-2px, -2px) rotate(-4deg); box-shadow: 6px 6px 0 var(--line); }
.icon-btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--line); }
.c-pink { --c: var(--pink); }
.c-coral { --c: var(--coral); }
.c-yellow { --c: var(--yellow); }
.c-green { --c: var(--green); }
.c-blue { --c: var(--blue); }
.c-purple { --c: var(--purple); }

/* Tooltip */
.icon-btn::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  padding: 3px 10px;
  font: 600 .78rem var(--font);
  white-space: nowrap;
  color: var(--bg);
  background: var(--text);
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity .15s, transform .15s;
}
.icon-btn:hover::after, .icon-btn:focus-visible::after, .icon-btn.tip-open::after { opacity: 1; transform: translate(-50%, 0); }

/* Live region for screen readers only; the visible "copied" feedback is the button's tooltip. */
.copy-status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Footer ---------- */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-top: 24px;
  padding-top: 24px;
  padding-bottom: 36px;
  color: var(--muted);
  font-size: .9rem;
  border-top: var(--border) dashed var(--line);
}

/* ---------- Easter egg: 8-bit spaceship (see js/ship.js) ---------- */
.ship {
  --px: 4px;
  position: fixed;
  left: 0;
  top: 0;
  z-index: -1; /* drifts behind the page; raised while the player flies it */
  width: calc(15 * var(--px));
  height: calc(11 * var(--px));
  pointer-events: none;
  will-change: transform;
}
.ship[hidden] { display: none; }
.ship.flying { z-index: 40; }
.ship svg { display: block; width: 100%; height: 100%; }
.flame { animation: flame .24s steps(1) infinite; }
@keyframes flame { 50% { opacity: 0; } }

html.playing, html.playing body { touch-action: none; user-select: none; -webkit-user-select: none; }

.hud {
  position: fixed;
  top: 10px;
  left: 50%;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-family: "Press Start 2P", ui-monospace, "Courier New", monospace;
  line-height: 1;
  color: var(--text);
  background: var(--surface);
  border: var(--border) solid var(--line);
  border-radius: 10px;
  box-shadow: 4px 4px 0 var(--line);
  transform: translateX(-50%);
  pointer-events: none;
}
.hud[hidden] { display: none; }
.hud-time { font-size: .85rem; }
.hud-best { font-size: .55rem; color: var(--muted); }
.hud-hint { font-size: .5rem; color: var(--muted); }
.hud-best:empty, .hud-hint:empty { display: none; }
.hud.dead .hud-time { color: var(--pink); }

.boom { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; }
.boom i {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--sz);
  height: var(--sz);
  margin: calc(var(--sz) / -2) 0 0 calc(var(--sz) / -2);
  background: var(--col);
  animation: boom-bit .75s steps(8) forwards;
}
@keyframes boom-bit { to { transform: translate(var(--dx), var(--dy)) scale(.15); opacity: 0; } }
/* Chunky 8-bit starburst: a plus-shaped block that spins in steps while changing colour. */
.boom .boom-flash {
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  background: #fff;
  clip-path: polygon(35% 0, 65% 0, 65% 35%, 100% 35%, 100% 65%, 65% 65%, 65% 100%, 35% 100%, 35% 65%, 0 65%, 0 35%, 35% 35%);
  animation: boom-flash .55s steps(1) forwards;
}
@keyframes boom-flash {
  0% { transform: scale(1) rotate(0); background: #fff; }
  15% { transform: scale(3) rotate(45deg); background: #ffd23f; }
  35% { transform: scale(5) rotate(0); background: #ff8a3d; }
  55% { transform: scale(6) rotate(45deg); background: #ff6b9d; }
  80% { transform: scale(6) rotate(0); background: #ff6b9d; opacity: .5; }
  100% { transform: scale(6) rotate(45deg); opacity: 0; }
}

/* ---------- Responsive / motion ---------- */
@media (max-width: 1000px) {
  .stickers { display: none; }
}
@media (max-width: 760px) {
  .hero { padding-top: 32px; padding-bottom: 28px; }
  .hero-glass { padding: 26px 20px; }
  .view-head { margin-bottom: 20px; }
  .eyebrow { margin-bottom: 14px; font-size: .75rem; padding: 3px 12px; }
  .lead { margin: 18px auto 22px; font-size: 1.05rem; }
  .hero-actions { gap: 10px; }
  .hero-glass .btn { padding: 8px 16px; }
  .hero-glass .btn-small { padding: 4px 12px; }
  .grid { gap: 22px; }
  .about-box { padding: 20px; }
  .floater { opacity: .35; }
  .ship { --px: 3px; }
  /* Keep the HUD clear of the language / theme controls in the header. */
  .hud { top: 68px; left: 12px; align-items: flex-start; gap: 6px; padding: 8px 10px; transform: none; }
  .hud-time { font-size: .7rem; }
  .hud-best { font-size: .5rem; }
  .hud-hint { font-size: .45rem; }
  .floater:nth-child(n+5) { display: none; }
}

@media (max-width: 520px) {
  /* Five contact icons must share one row on narrow screens. */
  .links { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
  .icon-btn { width: 100%; height: auto; aspect-ratio: 1; border-radius: 16px; }
  .icon-btn svg { width: 55%; height: 55%; }
}
@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr; }
  .brand { font-size: 1.4rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
