/* Pixel 仔嘅遊戲百科 · hand-drawn, kid-made style */
@font-face {
  font-family: "Iansui";
  src: url("fonts/iansui-subset.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "Caveat";
  src: url("fonts/caveat-subset.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Patrick Hand";
  src: url("fonts/patrickhand-subset.woff2") format("woff2");
  font-display: swap;
}

:root {
  --bg: #fefef9;
  --ink: #3d2c28;
  --coral: #e45b3f;
  --coral-dark: #c8452b;
  --coral-soft: #fff1ec;
  --muted: #7a6560;
  --mint: #7ec8b0;
  --mint-soft: #e8f6f0;
  --gold: #efc15a;
  --gold-soft: #fff6d9;
  --line: #f0dcd2;
  --zh: "Iansui", "PingFang HK", "PingFang TC", "Microsoft JhengHei", "Noto Sans CJK TC", "Noto Sans TC", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  --en: "Patrick Hand", "Comic Sans MS", "Chalkboard SE", var(--zh);
  --hand: "Caveat", "Patrick Hand", cursive, var(--zh);
  --wobble: 255px 18px 225px 18px / 18px 225px 18px 255px;
  --wobble2: 18px 225px 18px 255px / 255px 18px 225px 18px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(#f3e3d9 1.1px, transparent 1.2px);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: var(--zh);
  font-size: 17px;
  line-height: 1.45;
  overflow-x: hidden;
}
body.locked { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.en, [lang="en"] { font-family: var(--en); }
.en { display: block; color: var(--muted); font-size: 0.92em; line-height: 1.2; }

:focus-visible { outline: 3px dashed var(--coral); outline-offset: 3px; }

.skip {
  position: absolute; left: 8px; top: -60px; z-index: 50;
  background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 12px;
}
.skip:focus { top: 8px; }

/* ---------- hero ---------- */
.hero {
  position: relative;
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 18px 8px;
  text-align: center;
}
.hello {
  display: inline-block;
  font-size: 15px;
  color: var(--muted);
  background: #fff;
  border: 2px dashed var(--line);
  border-radius: 999px;
  padding: 3px 14px;
  transform: rotate(-2deg);
}
h1 { margin-top: 10px; font-weight: 400; }
h1 .zh {
  display: block;
  font-size: clamp(30px, 8.6vw, 72px);
  white-space: nowrap;
  line-height: 1.12;
  color: var(--coral);
  letter-spacing: 0.03em;
  text-shadow: 3px 3px 0 #ffd9cd;
}
h1 .en {
  font-family: var(--hand);
  font-weight: 700;
  font-size: clamp(28px, 7.5vw, 46px);
  color: var(--ink);
  line-height: 1.05;
}
.swoosh {
  width: 230px; height: 14px; margin: 4px auto 12px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 280 14' fill='none'><path d='M4 9 C 60 2, 120 13, 176 7 S 250 3, 276 8' stroke='%23efc15a' stroke-width='3.5' stroke-linecap='round'/></svg>") no-repeat center / contain;
}
.demo-note {
  display: inline-block;
  background: var(--mint-soft);
  border: 2px dashed var(--mint);
  border-radius: 18px;
  padding: 6px 16px;
  font-size: 15px;
}
.demo-note .en { font-size: 15px; }

.about {
  display: flex; align-items: center; gap: 12px;
  max-width: 420px;
  margin: 18px auto 0;
  text-align: left;
  background: var(--gold-soft);
  border: 2.5px solid var(--gold);
  border-radius: var(--wobble2);
  padding: 10px 16px 10px 12px;
  transform: rotate(1.2deg);
  box-shadow: 3px 4px 0 #f3dca0;
  font-size: 15px;
}
.avatar {
  flex: none;
  width: 54px; height: 54px;
  display: grid; place-items: center;
  font-size: 32px;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 50% 46% 52% 48%;
}

.doodle { position: absolute; pointer-events: none; }
.d-star { width: 34px; top: 22px; left: 6%; transform: rotate(-12deg); }
.d-heart { width: 30px; top: 130px; right: 5%; transform: rotate(14deg); }
.d-pad { width: 56px; top: 34px; right: 8%; transform: rotate(10deg); }
@media (max-width: 520px) {
  .d-star { left: 4px; top: 70px; width: 26px; }
  .d-heart { right: 6px; top: 150px; width: 24px; }
  .d-pad { right: 4px; top: 14px; width: 44px; }
}

/* ---------- main layout ---------- */
main { max-width: 1080px; margin: 0 auto; padding: 0 14px; }

.intro { margin-top: 26px; text-align: center; }
.intro h2 { font-weight: 400; font-size: 26px; }
.intro h2 .en { font-family: var(--hand); font-weight: 700; font-size: 26px; color: var(--muted); }

.cats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 14px;
}
@media (min-width: 720px) { .cats { grid-template-columns: repeat(4, 1fr); } }
.cat {
  position: relative;
  min-height: 92px;
  padding: 10px 8px 10px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: var(--wobble);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 20px;
  line-height: 1.15;
  transition: transform .15s, box-shadow .15s, background .15s;
}
.cat:nth-child(2) { border-radius: var(--wobble2); }
.cat:nth-child(4) { border-radius: var(--wobble2); }
.cat .zh { display: block; }
.cat .en { font-size: 16px; }
.cat-emoji { display: block; font-size: 28px; line-height: 1.1; margin-bottom: 2px; }
.cat-num {
  position: absolute; top: -9px; right: -6px;
  min-width: 26px; height: 26px; padding: 0 6px;
  display: grid; place-items: center;
  font-family: var(--en); font-size: 15px;
  background: var(--gold); border: 2px solid var(--ink); border-radius: 999px;
  transform: rotate(8deg);
}
.cat:hover { transform: translate(-1px, -2px); box-shadow: 5px 6px 0 var(--ink); }
.cat:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.cat[aria-pressed="true"] {
  background: var(--coral);
  color: #fff;
  border-color: var(--coral-dark);
  box-shadow: 4px 4px 0 var(--coral-dark);
}
.cat[aria-pressed="true"] .en { color: #fff3ee; }

/* ---------- filters ---------- */
.filters {
  margin-top: 22px;
  background: #fff;
  border: 2.5px dashed #e8c4b8;
  border-radius: 22px;
  padding: 12px 12px 6px;
}
.filters-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.filters-head h2 { font-weight: 400; font-size: 20px; }
.filters-head h2 .en { display: inline; font-size: 18px; }
.reset {
  min-height: 44px;
  padding: 6px 14px;
  background: var(--coral-soft);
  border: 2px solid var(--coral);
  color: var(--coral-dark);
  border-radius: 999px;
  font-size: 15px;
}
.reset .en { display: inline; color: inherit; font-size: 15px; }
.reset:disabled { opacity: .45; cursor: default; border-style: dashed; }
.reset.big { font-size: 18px; padding: 8px 22px; margin-top: 14px; background: var(--coral); color: #fff; border-color: var(--coral-dark); box-shadow: 3px 3px 0 var(--coral-dark); }
.reset.big .en { color: #fff; font-size: 18px; }

.frow { padding: 10px 0 8px; border-top: 1.5px dashed var(--line); margin-top: 6px; }
.filters-head + .frow { border-top: 0; }
@media (min-width: 900px) {
  .filters { display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px; }
  .filters-head { grid-column: 1 / -1; }
  .frow:nth-of-type(3) { border-top: 0; }
}
.flabel { font-size: 16px; margin-bottom: 6px; }
.flabel .en { display: inline; font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px;
  padding: 6px 14px;
  background: var(--bg);
  border: 2px solid #d9c3b9;
  border-radius: 999px;
  font-size: 16px;
  transition: background .12s, border-color .12s, transform .12s;
}
.chip span { font-size: 14px; color: var(--muted); }
.chip:hover { border-color: var(--coral); }
.chip[aria-pressed="true"] {
  background: var(--mint);
  border-color: #3aa884;
  color: #123d30;
  box-shadow: 2px 2px 0 #3aa884;
}
.chip[aria-pressed="true"] span { color: #1f5a47; }
.chip[aria-pressed="true"]::before { content: "✓ "; }

/* ---------- bar: count + random ---------- */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
  margin: 18px 0 6px;
}
.count { font-size: 17px; }
.count b { color: var(--coral); font-size: 22px; }
.count span { font-size: 15px; color: var(--muted); margin-left: 4px; }
.random {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 56px;
  padding: 8px 20px 8px 14px;
  background: var(--gold);
  border: 3px solid var(--ink);
  border-radius: var(--wobble2);
  box-shadow: 4px 4px 0 var(--ink);
  text-align: left;
  font-size: 20px;
  line-height: 1.1;
  transition: transform .15s, box-shadow .15s;
}
.random .zh { display: block; }
.random .en { font-size: 15px; color: #6b4d1c; }
.random .dice { font-size: 30px; display: inline-block; }
.random:hover { transform: rotate(-1.5deg) translateY(-2px); }
.random:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.random.rolling .dice { animation: roll .5s linear infinite; }
@keyframes roll { to { transform: rotate(360deg); } }
@media (max-width: 480px) { .random { width: 100%; justify-content: center; } }

.favs {
  font-size: 15px; margin: 4px 0 6px;
  background: #fff0f3; border: 2px dashed #f2a7b6; border-radius: 14px; padding: 6px 12px;
}
.favs span { font-size: 14px; color: var(--muted); }

/* ---------- cards ---------- */
.games { outline: none; padding-bottom: 10px; }
.grid {
  list-style: none; margin: 10px 0 0; padding: 0;
  display: grid; grid-template-columns: 1fr; gap: 20px;
}
@media (min-width: 640px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 640px) { .art { height: 116px; } .big { font-size: 66px; } }
@media (min-width: 980px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 24px; } }

.card {
  position: relative;
  transform: rotate(var(--tilt, 0deg));
  transition: transform .2s;
  animation: pop-in .35s ease both;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(10px) rotate(var(--tilt)); } }
.card:hover { transform: rotate(0deg) translateY(-3px); }
.card-open {
  display: flex; flex-direction: column; align-items: flex-start;
  width: 100%; height: 100%;
  text-align: left;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: var(--wobble);
  box-shadow: 5px 6px 0 var(--card, #ffe3dc);
  padding: 14px 16px 14px;
}
.card:nth-child(even) .card-open { border-radius: var(--wobble2); }
.card-open:hover { box-shadow: 7px 8px 0 var(--card); }

.art {
  position: relative;
  display: grid; place-items: center;
  width: 100%; height: 96px;
  margin-bottom: 8px;
}
.blob {
  position: absolute; inset: 6px 18%;
  background: var(--card);
  border-radius: 58% 42% 51% 49% / 46% 56% 44% 54%;
  border: 2px dashed rgba(61, 44, 40, .25);
}
.big { position: relative; font-size: 58px; line-height: 1; filter: drop-shadow(2px 3px 0 rgba(61,44,40,.12)); }

.tag {
  display: inline-block;
  font-size: 13px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1.5px solid currentColor;
  margin-bottom: 4px;
}
.tag span { font-size: 13px; }
.c-board .tag { color: #c8452b; background: #fff1ec; }
.c-sports .tag { color: #237a5e; background: #e8f6f0; }
.c-video .tag { color: #6b47b8; background: #f3ecff; }

.name { font-size: 28px; line-height: 1.15; }
.name-en { font-family: var(--hand); font-weight: 700; font-size: 24px; line-height: 1; color: var(--muted); }
.blurb { margin-top: 6px; font-size: 16px; }
.blurb .en { font-size: 15px; }

.meta {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px;
  width: 100%;
  margin-top: 10px; padding-top: 10px;
  border-top: 2px dashed var(--line);
  font-size: 14px; line-height: 1.25;
}
.m { display: flex; gap: 6px; align-items: flex-start; }
.m .en { font-size: 13px; }
.m.wide { grid-column: 1 / -1; }
.me { font-size: 17px; line-height: 1.1; flex: none; }

.go {
  align-self: flex-end;
  margin-top: 12px;
  font-size: 15px;
  color: var(--coral-dark);
  background: var(--coral-soft);
  border-radius: 999px;
  padding: 4px 12px;
}
.go span { font-size: 14px; margin-left: 2px; }

.fav {
  position: absolute; top: 10px; right: 10px;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  font-size: 22px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 50%;
}
.fav[aria-pressed="true"] { border-color: #f2a7b6; background: #fff0f3; }
.fav.pop span { animation: heart .4s ease; }
@keyframes heart { 50% { transform: scale(1.45); } }

/* random-pick shuffle highlight */
.card.shuffle { transform: rotate(0) scale(1.03); z-index: 2; }
.card.shuffle .card-open { background: var(--gold-soft); border-color: var(--coral); box-shadow: 0 0 0 6px var(--gold), 6px 8px 0 var(--card); }
.card.picked .card-open { animation: wiggle .5s ease; }
@keyframes wiggle { 25% { transform: rotate(-2deg); } 75% { transform: rotate(2deg); } }

.pick-bubble {
  position: fixed; left: 50%; top: calc(16px + env(safe-area-inset-top)); z-index: 30;
  transform: translateX(-50%) rotate(-2deg);
  display: flex; align-items: center; gap: 10px;
  background: var(--gold); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink);
  border-radius: 999px; padding: 8px 22px 8px 12px;
  font-size: 22px; white-space: nowrap;
}
.b-emoji { font-size: 32px; line-height: 1; }

/* empty state */
.empty {
  text-align: center;
  margin: 16px auto 0;
  max-width: 460px;
  background: #fff;
  border: 3px dashed var(--coral);
  border-radius: var(--wobble);
  padding: 22px 18px 24px;
  font-size: 19px;
}
.empty-emoji { font-size: 54px; }
.empty .small { font-size: 16px; margin-top: 8px; }
.empty p.en.small { margin-top: 0; }

/* ---------- footer ---------- */
.foot {
  max-width: 1080px;
  margin: 34px auto 0;
  padding: 10px 16px 40px;
  text-align: center;
}
.cta {
  display: block;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 20px;
  background: var(--coral);
  color: #fff;
  text-decoration: none;
  border: 3px solid var(--coral-dark);
  border-radius: var(--wobble2);
  box-shadow: 5px 6px 0 #f3b3a3;
  transform: rotate(-1deg);
  transition: transform .15s;
}
.cta:hover { transform: rotate(0) scale(1.02); }
.cta .zh { display: block; font-size: 26px; line-height: 1.2; }
.cta .en { color: #fff3ee; font-size: 19px; }
.made { margin-top: 18px; font-size: 17px; color: var(--ink); }
.tiny { margin-top: 8px; font-size: 12px; color: var(--muted); }
.tiny span { display: block; font-size: 12px; }

/* ---------- explainer sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 40; }
.backdrop {
  position: absolute; inset: 0;
  background: rgba(61, 44, 40, .45);
  opacity: 0; transition: opacity .2s;
}
.panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 92vh; max-height: 92dvh;
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg);
  border: 3px solid var(--ink); border-bottom: 0;
  border-radius: 28px 28px 0 0;
  padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform .22s ease-out;
}
.sheet.open .backdrop { opacity: 1; }
.sheet.open .panel { transform: none; }
.grab { width: 54px; height: 6px; background: #e3cfc6; border-radius: 9px; margin: 0 auto 6px; }
@media (min-width: 760px) {
  .panel {
    left: 50%; top: 50%; bottom: auto; right: auto;
    width: min(640px, 92vw);
    max-height: 88vh;
    border: 3px solid var(--ink);
    border-radius: var(--wobble);
    border-radius: 28px;
    padding: 20px 26px 24px;
    transform: translate(-50%, -46%) scale(.96);
    opacity: 0;
    transition: transform .2s, opacity .2s;
    box-shadow: 8px 10px 0 var(--card, #ffe3dc);
  }
  .sheet.open .panel { transform: translate(-50%, -50%); opacity: 1; }
  .grab { display: none; }
}

.close {
  position: absolute; top: 10px; right: 12px;
  width: 46px; height: 46px;
  font-size: 22px;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  box-shadow: 2px 2px 0 var(--ink);
}
.p-head { display: flex; align-items: center; gap: 14px; padding-right: 52px; }
.p-emoji {
  flex: none;
  width: 76px; height: 76px;
  display: grid; place-items: center;
  font-size: 44px;
  background: var(--card, #ffe3dc);
  border: 2.5px solid var(--ink);
  border-radius: 58% 42% 51% 49% / 46% 56% 44% 54%;
}
.p-tag { font-size: 13px; color: var(--muted); }
.p-tag span { font-size: 13px; }
.p-head h2 { font-weight: 400; font-size: 30px; line-height: 1.1; color: var(--coral); }
.p-en { font-family: var(--hand); font-weight: 700; font-size: 24px; line-height: 1; color: var(--muted); }

.how { margin-top: 16px; font-weight: 400; font-size: 20px; }
.how .zh { background: linear-gradient(transparent 60%, #ffe39a 60%); }
.how .en { display: inline; font-size: 18px; }

.show {
  margin-top: 8px;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: var(--wobble2);
  padding: 10px 10px 12px;
}
.viewport { overflow: hidden; touch-action: pan-y; border-radius: 16px; }
.track {
  list-style: none; margin: 0; padding: 0;
  display: flex;
  transition: transform .35s ease;
}
.slide {
  flex: 0 0 100%;
  min-width: 0;
  text-align: center;
  padding: 6px 12px 4px;
}
.s-art {
  display: grid; place-items: center;
  height: 112px;
  margin: 0 auto 4px;
  width: min(220px, 80%);
  font-size: 62px; line-height: 1;
  background: var(--card, #ffe3dc);
  border-radius: 46% 54% 50% 50% / 55% 45% 55% 45%;
  letter-spacing: 0.04em;
}
.slide.on .s-art { animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-5px) rotate(-2deg); } }
.s-num { font-size: 14px; color: var(--coral-dark); }
.s-num span { font-size: 14px; }
.s-zh { font-size: 20px; line-height: 1.4; margin-top: 2px; }
.s-en { font-family: var(--en); font-size: 17px; color: var(--muted); line-height: 1.25; margin-top: 4px; }

.controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.nav {
  width: 48px; height: 48px; flex: none;
  font-size: 18px;
  background: var(--coral-soft);
  border: 2.5px solid var(--coral);
  color: var(--coral-dark);
  border-radius: 50%;
}
.nav:active { transform: scale(.94); }
.dots { display: flex; gap: 4px; }
.dot {
  width: 44px; height: 44px;
  background: none; border: 0; padding: 0;
  display: grid; place-items: center;
}
.dot::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2.5px solid var(--ink); background: #fff;
  transition: transform .2s, background .2s;
}
.dot[aria-current="step"]::before { background: var(--coral); border-color: var(--coral-dark); transform: scale(1.25); }
.play {
  display: block; margin: 6px auto 0;
  min-height: 44px; padding: 4px 16px;
  font-size: 15px;
  background: none; border: 2px dashed #d9c3b9; border-radius: 999px;
  color: var(--muted);
}
.play span[lang] { font-size: 14px; }

.extras { display: grid; gap: 12px; margin-top: 14px; }
@media (min-width: 520px) { .extras { grid-template-columns: 1fr 1fr; } }
.box { border-radius: 18px; padding: 10px 14px 12px; font-size: 16px; }
.box h3 { font-weight: 400; font-size: 18px; margin-bottom: 4px; }
.box h3 .en { display: inline; font-size: 16px; }
.box .en { font-size: 15px; margin-top: 2px; }
.tip { background: var(--gold-soft); border: 2px dashed var(--gold); transform: rotate(-.6deg); }
.bring { background: var(--mint-soft); border: 2px dashed var(--mint); transform: rotate(.6deg); }

/* ---------- motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
