/* VARLEN - pixel farm UI */
@font-face {
  font-family: 'Press Start 2P';
  src: url('../fonts/PressStart2P-Regular.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'Fusion Pixel TC';
  src: url('../fonts/fusion-pixel/fusion-pixel-12px-proportional-zh_hant.woff2') format('woff2');
  font-display: swap;
}

:root {
  --cream: #fbf0d3;
  --cream2: #f3ddac;
  --wood: #c98a4b;
  --wood2: #8f5b2b;
  --wood3: #a9743c;
  --border: #6b4423;
  --ink: #3d2410;
  --soft: #6b4423;
  --red: #d24a34;
  --gold: #f5c542;
  --gray: #8e8e8e;
  --pixel-en: 'Press Start 2P', 'Fusion Pixel TC', monospace;
  --pixel-cjk: 'Fusion Pixel TC', 'Press Start 2P', 'Microsoft JhengHei', 'PingFang TC', sans-serif;
  --body: 'Microsoft JhengHei', 'PingFang TC', 'Noto Sans TC', 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  font-family: var(--body);
  background: #8fd0ee;
  -webkit-font-smoothing: none;
}
body[data-page="about"] { background: #2f3563; }
body[data-page="skills"] { background: #e8d29a; }
body[data-page="contact"] { background: #1b2340; }

canvas.bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.pixicon, canvas.pixicon { image-rendering: pixelated; }
canvas.overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 20;
  pointer-events: none;
  image-rendering: pixelated;
}

/* ------------------ one-page deck ------------------ */
.deck {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  z-index: 5;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  overscroll-behavior: none;
  scrollbar-width: none;
}
.deck::-webkit-scrollbar { width: 0; height: 0; }
.page {
  position: relative;
  height: 100%;
  overflow: hidden;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}
.page-body {
  position: relative;
  z-index: 10;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}
.page-body::-webkit-scrollbar { width: 10px; }
.page-body::-webkit-scrollbar-thumb { background: rgba(61, 36, 16, .45); }

/* side dots */
.dots {
  position: fixed;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 26;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dots a {
  display: block;
  width: 15px;
  height: 15px;
  background: rgba(251, 240, 211, .55);
  border: 3px solid var(--border);
  box-shadow: 0 2px 0 rgba(61, 36, 16, .45);
}
.dots a i { display: block; width: 100%; height: 100%; }
.dots a:hover { background: var(--gold); }
.dots a.active { background: var(--red); }

/* always-on name tags (Bubu / LuLu) */
.nametag {
  position: fixed;
  transform: translate(-50%, -100%);
  z-index: 34;
  background: rgba(61, 36, 16, .88);
  color: var(--cream);
  border: 3px solid rgba(251, 240, 211, .6);
  padding: 1px 8px;
  font-family: var(--pixel-cjk);
  font-size: 12.5px;
  line-height: 1.6;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity .18s;
}
.nametag.below { transform: translate(-50%, 0); }
.nametag.hide { opacity: 0; }

/* scroll hint on the first section */
.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: 16px;
  z-index: 12;
  font-family: var(--pixel-cjk);
  font-size: 13px;
  color: var(--ink);
  background: rgba(251, 240, 211, .94);
  border: 3px solid var(--border);
  box-shadow: 0 3px 0 rgba(61, 36, 16, .6);
  padding: 4px 12px;
  pointer-events: none;
  animation: bounceDownX 1.7s infinite;
}
@keyframes bounceDownX {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, 5px); }
}

/* ------------------ nav ------------------ */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  z-index: 30;
  background: linear-gradient(#b57f3f, #8f5b2b 60%, #7a4a22);
  border-bottom: 4px solid var(--border);
  box-shadow: 0 4px 0 rgba(0, 0, 0, .25);
}
.brand {
  font-family: var(--pixel-en);
  font-size: 15px;
  color: var(--cream);
  text-decoration: none;
  text-shadow: 2px 2px 0 var(--ink);
  background: #a9743c;
  border: 3px solid var(--border);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .35), inset 0 3px 0 rgba(255, 255, 255, .18);
  padding: 5px 9px;
  margin-right: 6px;
  flex: none;
}
.brand:hover { filter: brightness(1.1); }
.nav-links { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.nav-links a {
  font-family: var(--pixel-cjk);
  font-size: 15px;
  line-height: 1;
  color: var(--cream);
  text-decoration: none;
  text-shadow: 2px 2px 0 var(--ink);
  padding: 8px 10px;
  border: 3px solid transparent;
}
.nav-links a:hover { color: #ffe9a8; }
.nav-links a.active {
  background: #7a4a22;
  border-color: var(--border);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .3), 0 2px 0 rgba(255, 255, 255, .12);
}
.nav-tools { margin-left: auto; display: flex; gap: 8px; flex: none; }
.pill {
  font-family: var(--pixel-cjk);
  font-size: 13px;
  color: var(--ink);
  background: var(--gold);
  border: 3px solid var(--border);
  box-shadow: 0 3px 0 var(--border);
  padding: 5px 10px;
  min-width: 42px;
  cursor: pointer;
}
.pill:hover { transform: translateY(-1px); filter: brightness(1.06); }
.pill:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--border); }
.pill.off { background: var(--gray); color: #f0f0f0; }

/* ------------------ HUD ------------------ */
.hud {
  position: fixed;
  top: 68px; right: 12px;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  font-family: var(--pixel-cjk);
  font-size: 13px;
  pointer-events: none;
}
.hud .panel {
  background: var(--cream);
  border: 3px solid var(--border);
  box-shadow: 0 3px 0 var(--border);
  padding: 4px 9px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.hud .coin {
  width: 10px; height: 10px;
  background: var(--gold);
  border: 2px solid #c99a2e;
}
.hud.ping .panel.gold { animation: ping .45s steps(3); }
@keyframes ping { 50% { transform: scale(1.12); background: #fff3c0; } }

/* ------------------ layout ------------------ */
.wrap {
  position: relative;
  z-index: 10;
  flex: 1 0 auto;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 96px 16px 72px;
}
.sign {
  display: inline-block;
  font-family: var(--pixel-cjk);
  font-size: 24px;
  color: var(--cream);
  background: var(--wood);
  border: 4px solid var(--border);
  box-shadow: 0 6px 0 var(--border), inset 0 4px 0 rgba(255, 255, 255, .2);
  padding: 8px 18px;
  text-shadow: 2px 2px 0 var(--border);
  margin: 0 0 14px;
}
.card {
  position: relative;
  background: var(--cream);
  border: 4px solid var(--border);
  box-shadow: 7px 7px 0 rgba(61, 36, 16, .5);
  padding: 22px 24px;
  margin-bottom: 24px;
}
.card.tight { padding: 16px 18px; }
.para {
  font-size: 15.5px;
  line-height: 1.95;
  color: #4a3320;
  margin: 0 0 12px;
}
.note {
  display: inline-block;
  margin: 4px 8px 4px 0;
  font-family: var(--pixel-cjk);
  font-size: 13px;
  line-height: 1.6;
  color: var(--soft);
  background: var(--cream2);
  border: 3px dashed #c98a4b;
  padding: 7px 12px;
}
.para-en { color: #6b5540; font-size: 14px; font-style: italic; }
.hr { height: 4px; margin: 18px 0; background: repeating-linear-gradient(90deg, var(--wood) 0 10px, transparent 10px 18px); }

/* ------------------ hero ------------------ */
.hero {
  position: relative;
  z-index: 10;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
  padding: 96px 16px 190px;
}
.hero-journal {
  font-family: var(--pixel-cjk);
  font-size: 15px;
  color: var(--ink);
  background: var(--cream);
  border: 3px solid var(--border);
  box-shadow: 0 3px 0 var(--border);
  padding: 5px 14px;
}
.hero-title {
  font-family: var(--pixel-en);
  font-size: clamp(42px, 9vw, 86px);
  letter-spacing: 6px;
  color: var(--cream);
  margin: 0;
  text-shadow: 5px 5px 0 var(--border), 9px 9px 0 rgba(61, 36, 16, .28);
}
.hero-tag {
  font-family: var(--pixel-cjk);
  font-size: 16px;
  color: var(--ink);
  background: rgba(251, 240, 211, .92);
  border: 3px solid var(--border);
  box-shadow: 0 3px 0 rgba(61, 36, 16, .55);
  padding: 8px 16px;
  max-width: 620px;
}
.hero-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.hero-hint {
  font-family: var(--pixel-cjk);
  font-size: 14px;
  color: var(--ink);
  background: rgba(251, 240, 211, .94);
  border: 3px solid var(--border);
  box-shadow: 0 3px 0 rgba(61, 36, 16, .6);
  padding: 5px 12px;
  animation: bounceDown 1.6s infinite;
}
@keyframes bounceDown { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(4px); } }
.hero-hover {
  position: absolute;
  left: 14px; bottom: 14px;
  z-index: 12;
}

/* ------------------ buttons ------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--pixel-cjk);
  font-size: 18px;
  color: var(--cream);
  background: var(--wood);
  border: 4px solid var(--border);
  box-shadow: 0 6px 0 var(--border), inset 0 4px 0 rgba(255, 255, 255, .2);
  padding: 12px 22px;
  text-decoration: none;
  text-shadow: 2px 2px 0 var(--border);
  cursor: pointer;
  transform: rotate(-.4deg);
}
.btn:hover {
  transform: rotate(-.4deg) translateY(-3px);
  box-shadow: 0 9px 0 var(--border), inset 0 4px 0 rgba(255, 255, 255, .3);
  filter: brightness(1.07);
}
.btn:active {
  transform: rotate(-.4deg) translateY(3px);
  box-shadow: 0 2px 0 var(--border), inset 0 2px 0 rgba(0, 0, 0, .15);
}
.btn.primary { background: var(--red); }
.btn.alt { background: #4a7ab8; }
.btn.big { font-size: 21px; padding: 15px 28px; }
.btn .pixicon { display: block; }
.btn.shake { animation: shake .4s steps(2) 2; }
@keyframes shake {
  0% { transform: rotate(-.4deg) translateX(0); }
  50% { transform: rotate(-.4deg) translateX(4px); }
  100% { transform: rotate(-.4deg) translateX(0); }
}
.btn-row { display: flex; flex-wrap: wrap; gap: 14px; }

/* ------------------ tags / timeline ------------------ */
.tags { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 2px; }
.tag {
  font-family: var(--pixel-cjk);
  font-size: 15px;
  color: var(--ink);
  background: var(--cream2);
  border: 3px solid var(--border);
  box-shadow: 0 3px 0 var(--border);
  padding: 5px 13px;
}
.tag:hover { transform: translateY(-2px) rotate(-1.2deg); }
.tl { position: relative; margin: 10px 0 0; padding-left: 30px; }
.tl::before {
  content: '';
  position: absolute;
  left: 9px; top: 8px; bottom: 10px;
  border-left: 4px dashed var(--wood2);
}
.tl-item { position: relative; margin-bottom: 20px; }
.tl-item::before {
  content: '';
  position: absolute;
  left: -27px; top: 6px;
  width: 10px; height: 10px;
  background: var(--gold);
  border: 3px solid var(--border);
}
.tl-item .year {
  font-family: var(--pixel-en);
  font-size: 12px;
  color: var(--cream);
  background: var(--wood2);
  border: 2px solid var(--border);
  padding: 3px 6px;
  margin-right: 8px;
  display: inline-block;
  vertical-align: 2px;
}
.tl-item p { margin: 6px 0 0; font-size: 15px; line-height: 1.8; color: #4a3320; }

/* ------------------ skills ------------------ */
.skill {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px 18px;
  align-items: center;
  background: var(--cream2);
  border: 4px solid var(--border);
  box-shadow: 5px 5px 0 rgba(61, 36, 16, .45);
  padding: 14px 18px;
  margin-bottom: 22px;
  transform: rotate(-.5deg);
}
.skill:nth-child(even) { transform: rotate(.5deg); }
.skill-head { display: flex; align-items: center; gap: 10px; }
.skill-name { font-family: var(--pixel-cjk); font-size: 20px; }
.bar { display: flex; gap: 4px; flex-wrap: wrap; }
.sp {
  width: 21px; height: 21px;
  background: var(--gray);
  border: 3px solid var(--border);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18);
}
.sp.on { background: var(--red); }
.sp.on:hover { filter: brightness(1.15); }
.skill .lv { font-family: var(--pixel-en); font-size: 24px; color: var(--ink); }
.skill .desc { grid-column: 1 / -1; margin: 4px 0 0; font-size: 14.5px; line-height: 1.8; color: #5a4028; }
.skill .desc .muted { display: block; color: #7a6448; font-size: 13.5px; }

/* ------------------ contact ------------------ */
.contact-card { text-align: left; }
.lead { font-size: 17px; line-height: 1.9; }
.mail-hint { font-family: var(--pixel-cjk); font-size: 14px; color: var(--cream); text-shadow: 2px 2px 0 var(--border); }

/* ------------------ counters / toast / bubbles ------------------ */
.counters {
  position: absolute;
  left: 12px; bottom: 12px;
  z-index: 22;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--pixel-cjk);
  font-size: 13px;
  color: var(--ink);
  background: var(--cream);
  border: 3px solid var(--border);
  box-shadow: 0 3px 0 var(--border);
  padding: 4px 10px;
}
.chip .n { font-family: var(--pixel-en); font-size: 12px; }
.chip .x { font-family: var(--pixel-en); font-size: 10px; opacity: .7; }
.toast {
  position: fixed;
  left: 50%; bottom: 88px;
  transform: translate(-50%, 20px);
  opacity: 0;
  max-width: min(720px, 92vw);
  background: var(--cream);
  border: 4px solid var(--border);
  box-shadow: 0 6px 0 rgba(61, 36, 16, .6);
  padding: 13px 20px;
  font-family: var(--pixel-cjk);
  font-size: 15px;
  line-height: 1.7;
  z-index: 40;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.bubble {
  position: fixed;
  transform: translate(-50%, -100%);
  background: var(--cream);
  border: 3px solid var(--border);
  box-shadow: 0 3px 0 rgba(61, 36, 16, .6);
  padding: 5px 10px;
  font-family: var(--pixel-cjk);
  font-size: 13.5px;
  white-space: nowrap;
  z-index: 35;
  pointer-events: none;
  animation: bubbleBob 1.2s ease-in-out infinite;
}
.bubble::after {
  content: '';
  position: absolute;
  left: 50%; bottom: -7px;
  width: 8px; height: 8px;
  margin-left: -4px;
  background: var(--cream);
  border-right: 3px solid var(--border);
  border-bottom: 3px solid var(--border);
  transform: rotate(45deg);
}
.bubble.out { opacity: 0; transition: opacity .3s; }
@keyframes bubbleBob {
  0%, 100% { transform: translate(-50%, -100%); }
  50% { transform: translate(-50%, -112%); }
}
.floater {
  position: fixed;
  transform: translate(-50%, -50%);
  font-family: var(--pixel-en);
  font-size: 13px;
  color: var(--gold);
  text-shadow: 2px 2px 0 var(--ink);
  z-index: 36;
  pointer-events: none;
  animation: floatUp .95s ease-out forwards;
}
@keyframes floatUp {
  from { transform: translate(-50%, -50%); opacity: 1; }
  to { transform: translate(-50%, -240%); opacity: 0; }
}

/* ------------------ footer ------------------ */
.footer {
  position: relative;
  z-index: 10;
  margin-top: auto;
  text-align: center;
  padding: 16px 16px 30px;
}
.footer .line {
  display: inline-block;
  font-family: var(--pixel-cjk);
  font-size: 13px;
  color: var(--ink);
  background: rgba(251, 240, 211, .94);
  border: 3px solid var(--border);
  box-shadow: 0 3px 0 rgba(61, 36, 16, .6);
  padding: 5px 14px;
}

/* ------------------ responsive ------------------ */
@media (max-width: 760px) {
  .nav { height: 52px; gap: 2px; overflow-x: auto; }
  .nav-links a { font-size: 13px; padding: 7px 7px; }
  .brand { font-size: 12px; padding: 4px 6px; }
  .hud { top: 62px; font-size: 11px; }
  .wrap { padding: 84px 12px 64px; }
  .card { padding: 16px 14px; box-shadow: 5px 5px 0 rgba(61, 36, 16, .5); }
  .sign { font-size: 19px; padding: 6px 12px; }
  .skill { grid-template-columns: 1fr; }
  .skill .bar { justify-content: flex-start; }
  .sp { width: 16px; height: 16px; border-width: 2px; }
  .hero { padding-bottom: 240px; }
  .hero-title { letter-spacing: 3px; }
  .counters { bottom: 8px; left: 8px; }
  .chip { font-size: 11px; padding: 3px 7px; }
  .toast { font-size: 13px; bottom: 92px; }
  .btn { font-size: 15px; padding: 10px 16px; }
  .btn.big { font-size: 17px; padding: 12px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-hint, .scroll-hint, .bubble, .floater, .hud.ping .panel.gold, .btn.shake { animation: none !important; }
  html { scroll-behavior: auto; }
}

/* ------------------ one-page deck (small screens) ------------------ */
@media (max-width: 760px) {
  .dots { right: 6px; gap: 8px; }
  .dots a { width: 12px; height: 12px; border-width: 2px; }
  .nametag { font-size: 11px; padding: 1px 6px; border-width: 2px; }
  .scroll-hint { font-size: 11px; bottom: 10px; }
  .hero-hover { display: none; }
  .hud { top: 58px; }
}
@media (hover: none) {
  .hero-hover { display: none; }
}



