:root {
  --night: #1C2041;
  --night-2: #262B55;      /* raised surfaces on the night background */
  --night-3: #343A6E;      /* borders on the night background */
  --red: #E5432F;
  --amber: #FFB648;
  --sign: #FFF9F0;
  --teal: #2B9C8E;
  --dusk: #A7ADD0;
  --ink: #1C2041;          /* text on signboard white */
  --ink-soft: #565C86;

  --display: "Dela Gothic One", "Noto Sans TC", system-ui, sans-serif;
  --body: "Noto Sans TC", system-ui, -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;

  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.5625rem;
  --step-3: 2.4rem;

  --gutter: 16px;
  --max: 1120px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--sign);
  font-family: var(--body);
  font-size: var(--step-0);
  line-height: 1.6;
}
img { max-width: 100%; display: block; }
a { color: var(--amber); }
a:hover { color: var(--sign); }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; border-radius: 4px; }
button, input, select, textarea { font: inherit; }

.visually-hidden, .skip:not(:focus) {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.skip { position: absolute; top: 8px; left: 8px; z-index: 50; background: var(--amber); color: var(--ink); padding: 8px 12px; }

/* ---------- Header: the one loud element ---------- */
.site-head { padding-bottom: 28px; }
.awning {
  height: 46px;
  background: repeating-linear-gradient(90deg, var(--red) 0 48px, var(--sign) 48px 96px);
  -webkit-mask:
    linear-gradient(#000 0 0) 0 0 / 100% 22px no-repeat,
    radial-gradient(circle at 24px 22px, #000 23.5px, transparent 24px) 0 0 / 48px 46px repeat-x;
          mask:
    linear-gradient(#000 0 0) 0 0 / 100% 22px no-repeat,
    radial-gradient(circle at 24px 22px, #000 23.5px, transparent 24px) 0 0 / 48px 46px repeat-x;
}
.head-inner {
  max-width: var(--max); margin: 0 auto; padding: 18px var(--gutter) 0;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
}
.signboard { display: inline-block; text-decoration: none; }
.lang-toggle {
  flex: none; margin-top: 8px;
  background: transparent; color: var(--sign);
  border: 2px solid var(--night-3); border-radius: 999px;
  padding: 4px 14px; cursor: pointer; font-weight: 700;
}
.lang-toggle:hover { border-color: var(--amber); }

.search { max-width: var(--max); margin: 18px auto 0; padding: 0 var(--gutter); }
.search input {
  width: 100%; max-width: 640px;
  background: var(--sign); color: var(--ink);
  border: 0; border-radius: 12px;
  padding: 14px 18px; font-size: 1.0625rem;
}
.search input::placeholder { color: var(--ink-soft); }

body:not(.is-home) .site-head { padding-bottom: 12px; }
body:not(.is-home) .awning {
  height: 30px;
  background: repeating-linear-gradient(90deg, var(--red) 0 32px, var(--sign) 32px 64px);
  -webkit-mask:
    linear-gradient(#000 0 0) 0 0 / 100% 14px no-repeat,
    radial-gradient(circle at 16px 14px, #000 15.5px, transparent 16px) 0 0 / 32px 30px repeat-x;
          mask:
    linear-gradient(#000 0 0) 0 0 / 100% 14px no-repeat,
    radial-gradient(circle at 16px 14px, #000 15.5px, transparent 16px) 0 0 / 32px 30px repeat-x;
}

/* ---------- Page body ---------- */
main { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter) 48px; outline: none; }
.section { margin-top: 40px; }
.section h2 {
  font-family: var(--display); font-weight: 400;
  font-size: var(--step-2); line-height: 1.2; margin: 0 0 6px;
}
html[lang="zh-Hant"] .section h2, html[lang="zh-Hant"] h1 { font-family: var(--body); font-weight: 900; }
.section .lede { color: var(--dusk); margin: 0 0 16px; max-width: 60ch; }

.grid {
  display: grid; gap: 18px 14px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
@media (min-width: 720px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* A stall card: signboard-white body hanging under the thumbnail */
.stall {
  display: flex; flex-direction: column;
  color: var(--ink); text-decoration: none;
  background: var(--sign); border-radius: 10px; overflow: hidden;
  position: relative;
}
.stall:hover { color: var(--ink); outline: 3px solid var(--amber); outline-offset: 0; }
.stall-thumb { aspect-ratio: 40 / 21; background: var(--night-2); overflow: hidden; }
.stall-thumb img { width: 100%; height: 100%; object-fit: cover; }
.stall-body { padding: 10px 12px 12px; }
.stall-body h3 { margin: 0; font-size: 1rem; line-height: 1.35; font-weight: 700; }
.stall-tags { margin: 4px 0 0; font-size: var(--step--1); color: var(--ink-soft); }
.rank {
  position: absolute; top: 8px; left: 8px;
  min-width: 34px; height: 34px; padding: 0 8px;
  display: grid; place-items: center;
  background: var(--night); color: var(--amber);
  font-family: var(--display); font-size: 1.05rem; border-radius: 8px;
}
.rank.pin { color: var(--sign); background: var(--red); }

/* Placeholder thumbnail: the title's first character as a stall sign */
.ph {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-weight: 900; font-size: clamp(2.6rem, 9vw, 4rem); line-height: 1;
  color: var(--sign);
}
.ph.c0 { background: var(--red); }
.ph.c1 { background: var(--amber); color: var(--ink); }
.ph.c2 { background: var(--teal); }
.ph.c3 { background: #8E4B9E; }
.ph.c4 { background: #4F6BD8; }

/* Tag chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; list-style: none; }
.chip {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 6px 14px; border-radius: 999px;
  background: var(--night-2); color: var(--sign);
  border: 2px solid var(--night-3); text-decoration: none; font-weight: 700;
}
.chip:hover, .chip[aria-current="page"] { border-color: var(--amber); color: var(--amber); }
.chip small { color: var(--dusk); font-weight: 400; }
.chip.light { background: transparent; }

.empty { color: var(--dusk); padding: 24px 0; }
.notice {
  background: var(--night-2); border-left: 4px solid var(--amber);
  padding: 14px 16px; border-radius: 6px; margin-top: 24px;
}
.notice.error { border-left-color: var(--red); }
.notice.ok { border-left-color: var(--teal); }

.submit-cta {
  margin-top: 48px; padding: 22px; border-radius: 12px;
  border: 2px dashed var(--night-3);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
}
.submit-cta p { margin: 0; max-width: 52ch; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 10px; border: 0; cursor: pointer;
  background: var(--red); color: var(--sign); font-weight: 900; text-decoration: none;
  font-size: 1.0625rem;
}
.btn:hover { background: #F25A47; color: var(--sign); }
.btn.secondary { background: transparent; border: 2px solid var(--night-3); color: var(--sign); font-weight: 700; }
.btn.secondary:hover { border-color: var(--amber); }
.btn.small { padding: 7px 14px; font-size: var(--step--1); }
.btn[disabled] { opacity: 0.55; cursor: progress; }

/* ---------- Game page ---------- */
.back { display: inline-block; margin-top: 8px; }
.game {
  margin-top: 16px;
  display: grid; gap: 24px;
}
@media (min-width: 820px) { .game { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; } }
.game-thumb { border-radius: 12px; overflow: hidden; aspect-ratio: 40 / 21; background: var(--night-2); }
.game-thumb img { width: 100%; height: 100%; object-fit: cover; }
.game h1 { font-family: var(--display); font-weight: 400; font-size: var(--step-3); line-height: 1.1; margin: 0; }
.alt-title { color: var(--dusk); margin: 6px 0 0; font-size: var(--step-1); }
.game-desc { font-size: 1.0625rem; max-width: 60ch; margin: 16px 0; }
.byline { color: var(--dusk); margin: 0 0 16px; }
.play-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin: 20px 0 8px; }
.play-hint { color: var(--dusk); font-size: var(--step--1); }

/* In-page player */
.player {
  position: fixed; inset: 0; z-index: 40; background: var(--night);
  display: flex; flex-direction: column;
}
.player[hidden] { display: none; }
.player-bar {
  display: flex; align-items: center; gap: 14px; padding: 10px var(--gutter);
  border-bottom: 2px solid var(--night-3);
}
.player-bar strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-bar button { background: var(--red); color: var(--sign); border: 0; border-radius: 8px; padding: 6px 14px; font-weight: 700; cursor: pointer; }
.player iframe { flex: 1; width: 100%; border: 0; background: #fff; }

/* ---------- Forms ---------- */
.form { max-width: 640px; display: grid; gap: 18px; margin-top: 16px; }
.field { display: grid; gap: 6px; }
.field label, .field legend { font-weight: 700; }
.field .help { color: var(--dusk); font-size: var(--step--1); margin: 0; }
.field input[type="text"], .field input[type="url"], .field input[type="email"],
.field input[type="password"], .field textarea {
  width: 100%; background: var(--sign); color: var(--ink);
  border: 2px solid transparent; border-radius: 8px; padding: 10px 12px;
}
.field input:focus-visible, .field textarea:focus-visible { outline: none; border-color: var(--amber); }
.field textarea { min-height: 90px; resize: vertical; }
.field input[type="file"] { color: var(--dusk); }
fieldset.field { border: 0; padding: 0; margin: 0; }
.tag-picks { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-picks label {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 5px 12px; border-radius: 999px; border: 2px solid var(--night-3); font-weight: 400;
}
.tag-picks input { accent-color: var(--red); }
.tag-picks label:has(input:checked) { border-color: var(--amber); color: var(--amber); }
.hp { position: absolute; left: -9999px; }
.warn { color: var(--amber); font-size: var(--step--1); margin: 0; }

/* ---------- Admin ---------- */
.admin-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.admin-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.admin-row {
  display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  background: var(--night-2); border-radius: 10px; padding: 10px;
  color: var(--sign); text-decoration: none;
}
.admin-row:hover { outline: 2px solid var(--amber); color: var(--sign); }
.admin-row .mini { width: 72px; aspect-ratio: 40 / 21; border-radius: 6px; overflow: hidden; }
.admin-row .mini .ph { font-size: 1.6rem; }
.admin-row p { margin: 0; color: var(--dusk); font-size: var(--step--1); overflow-wrap: anywhere; }
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 0.75rem; font-weight: 700;
  background: var(--amber); color: var(--ink); margin-right: 6px; vertical-align: 2px;
}
.badge.red { background: var(--red); color: var(--sign); }
.admin-edit { display: grid; gap: 24px; margin-top: 16px; }
@media (min-width: 900px) { .admin-edit { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }
.preview { border-radius: 10px; overflow: hidden; background: var(--night-2); }
.preview iframe { width: 100%; height: 420px; border: 0; background: #fff; display: block; }
.preview p { margin: 0; padding: 10px 12px; color: var(--dusk); font-size: var(--step--1); }
.two-col { display: grid; gap: 14px; }
@media (min-width: 560px) { .two-col { grid-template-columns: 1fr 1fr; } }
.switches { display: grid; gap: 8px; }
.switches label { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.switches input { accent-color: var(--red); width: 18px; height: 18px; margin-top: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.site-foot {
  max-width: var(--max); margin: 0 auto; padding: 24px var(--gutter) 40px;
  border-top: 2px solid var(--night-2); color: var(--dusk); font-size: var(--step--1);
}
.site-foot p { margin: 4px 0; }


/* ---------- Logo ---------- */
.signboard img { display: block; height: clamp(64px, 14vw, 96px); width: auto; }
body:not(.is-home) .signboard img { height: clamp(48px, 10vw, 64px); }

/* ---------- Search with category dropdown ---------- */
.combo { position: relative; max-width: 640px; }
.search .combo input { max-width: none; padding-right: 54px; }
.search input::-webkit-search-cancel-button { display: none; }
.combo-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 44px; height: 44px; display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 8px; color: var(--ink); cursor: pointer;
}
.combo-toggle:hover { background: rgba(28, 32, 65, 0.08); }
.combo-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.combo-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 6px);
  margin: 0; padding: 6px; list-style: none;
  background: var(--sign); color: var(--ink); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(10, 12, 30, 0.45);
  max-height: min(60vh, 420px); overflow-y: auto;
}
.combo-list[hidden] { display: none; }
.combo-list li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 10px 12px; border-radius: 8px; cursor: pointer; font-weight: 700;
}
.combo-list li small { color: var(--ink-soft); font-weight: 400; }
.combo-list li[aria-selected="true"], .combo-list li:hover { background: #FFE9C4; }
.combo-list .combo-head { cursor: default; font-weight: 400; color: var(--ink-soft); font-size: var(--step--1); padding: 6px 12px 4px; }
.combo-list .combo-head:hover { background: none; }

/* ---------- Home: categories + submit right under the search ---------- */
.quickbar {
  margin-top: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
}
.quickbar .chips { flex: 1 1 420px; }
.quickbar .btn { flex: none; }
@media (max-width: 719px) {
  .quickbar { flex-wrap: nowrap; gap: 10px; }
  .quickbar .chips {
    flex: 1 1 auto; min-width: 0; flex-wrap: nowrap; overflow-x: auto;
    scrollbar-width: none; padding: 2px 24px 4px 2px;
    -webkit-mask-image: linear-gradient(90deg, #000 82%, transparent);
            mask-image: linear-gradient(90deg, #000 82%, transparent);
  }
  .quickbar .chips::-webkit-scrollbar { display: none; }
  .quickbar .chip { white-space: nowrap; }
  .quickbar .btn { padding: 8px 14px; font-size: 0.9375rem; }
}

/* ---------- Add to home screen ---------- */
.linklike { background: none; border: 0; padding: 0; color: var(--amber); text-decoration: underline; cursor: pointer; font-size: inherit; }
.linklike:hover { color: var(--sign); }
.a2hs {
  position: fixed; z-index: 35; left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  max-width: 520px; margin: 0 auto;
  background: var(--sign); color: var(--ink);
  border-radius: 16px; padding: 16px 16px 14px;
  box-shadow: 0 16px 40px rgba(10, 12, 30, 0.55);
  animation: a2hs-in 0.35s ease-out both;
}
.a2hs[hidden] { display: none; }
@keyframes a2hs-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .a2hs { animation: none; } }
.a2hs-top { display: grid; grid-template-columns: 52px minmax(0, 1fr) 36px; gap: 12px; align-items: start; }
.a2hs-top img { width: 52px; height: 52px; border-radius: 12px; }
.a2hs h2 { margin: 2px 0 2px; font-size: 1.0625rem; line-height: 1.3; font-weight: 900; font-family: var(--body); }
.a2hs p { margin: 0; font-size: 0.9375rem; line-height: 1.5; color: var(--ink-soft); }
.a2hs .steps { margin: 10px 0 0; color: var(--ink); }
.a2hs .steps svg { width: 18px; height: 18px; vertical-align: -3px; color: #2F6BDB; }
.a2hs .steps b { color: var(--ink); }
.a2hs-close {
  width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent;
  color: var(--ink-soft); font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.a2hs-close:hover { background: rgba(28, 32, 65, 0.08); color: var(--ink); }
.a2hs-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.a2hs .btn { padding: 10px 16px; font-size: 0.9375rem; }
.a2hs .btn.secondary { color: var(--ink); border-color: #D9D4CB; }
.a2hs .btn.secondary:hover { border-color: var(--ink); }
.a2hs-arrow { position: fixed; z-index: 36; top: 6px; right: 14px; color: var(--amber); font-size: 2rem; line-height: 1; pointer-events: none; animation: a2hs-bob 1.2s ease-in-out infinite alternate; }
@keyframes a2hs-bob { from { transform: translateY(0); } to { transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .a2hs-arrow { animation: none; } }

/* ---------- Hero submit button (home) ---------- */
.hero-cta {
  margin: 18px auto 0; max-width: 640px;
  display: flex; align-items: center; justify-content: center; gap: 14px; text-align: center;
  padding: 16px 20px; border-radius: 14px;
  background: var(--red); color: var(--sign); text-decoration: none;
}
.hero-cta:hover { background: #F25A47; color: var(--sign); }
.hero-cta strong { display: block; font-size: 1.375rem; line-height: 1.25; font-weight: 900; }
.hero-cta small { display: block; font-size: 0.9375rem; line-height: 1.4; opacity: 0.92; }
.hero-cta svg { flex: none; }

/* ---------- Show more ---------- */
.more-row { display: flex; justify-content: center; margin-top: 18px; }
.stall[hidden] { display: none; }
.hero-cta + .section { margin-top: 22px; }
