:root {
  --bg: #15110e;
  --card: #211a15;
  --card2: #2c231c;
  --accent: #ff7a3d;
  --accent2: #ffd23d;
  --text: #f5ede4;
  --muted: #a79786;
  --line: #3a2f26;
  --hot: #ff4d4d;
  /* one radius scale, applied consistently */
  --r-xs: 10px;
  --r-sm: 14px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-pill: 999px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #2a1d12, #120e0b) no-repeat;
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
}

/* Mobile-first: the app fills the screen (no fake phone bezel), page scrolls if tall. */
.phone {
  flex: 1;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 28px 20px calc(24px + env(safe-area-inset-bottom));
}

/* Desktop: show it as a centered rounded card with its own scroll. */
@media (min-width: 560px) {
  body { justify-content: center; padding: 24px; }
  .phone {
    flex: none;
    height: min(820px, calc(100dvh - 48px));
    border-radius: 28px;
    border: 1px solid var(--line);
    box-shadow: 0 30px 80px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(255, 255, 255, .03);
    overflow-y: auto;
  }
}

/* Screens */
.screen { display: none; }
.screen.active { display: flex; flex-direction: column; flex: 1; }
@media (prefers-reduced-motion: no-preference) {
  .screen.active { animation: screen-in .32s cubic-bezier(.16, 1, .3, 1); }
  @keyframes screen-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}

/* Brand */
.brand { display: flex; align-items: center; gap: 8px; justify-content: center; margin: 4px 0 2px; }
.brand .logo { font-size: 26px; }
.brand .name { font-size: 19px; font-weight: 800; letter-spacing: .5px; }
.tagline { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }

/* Section labels */
.label { font-size: 13px; color: var(--muted); margin: 0 2px 8px; }

/* Chip rows */
.chips { display: grid; gap: 8px; margin-bottom: 18px; }
#dist-chips { grid-template-columns: 1fr 1fr; }                                   /* 4 rich chips → 2×2 */
#price-chips, #rating-chips, #review-chips { grid-auto-flow: column; grid-auto-columns: 1fr; } /* single even row */

.chip {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 11px 8px;
  text-align: center;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .05s;
}
.chip small { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.chip:hover { border-color: var(--accent); }
.chip:active { transform: scale(.97); }
.chip.sel {
  border-color: var(--accent);
  background: linear-gradient(180deg, #3a2417, #241812);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.chip.sel small { color: var(--accent2); }

/* Advanced filters (native collapsible — no JS) */
.advanced { margin-bottom: 18px; border-top: 1px solid var(--line); }
.advanced > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 2px 0;
  font-size: 13px;
  color: var(--muted);
  user-select: none;
}
.advanced > summary::-webkit-details-marker { display: none; }
.advanced .chev { transition: transform .2s; }
.advanced[open] .chev { transform: rotate(180deg); }
.advanced-body { padding-top: 14px; }
.advanced-body .chips:last-of-type { margin-bottom: 14px; }

/* Toggle switch row */
.switch { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 14px; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

/* Buttons */
.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: var(--r-md);
  padding: 16px;
  font-size: 17px;
  font-weight: 800;
  color: #1a1109;
  cursor: pointer;
  background: linear-gradient(180deg, var(--accent2), var(--accent));
  box-shadow: 0 8px 20px rgba(255, 122, 61, .35);
  transition: transform .05s, box-shadow .15s, filter .15s;
}
.btn.big { font-size: 19px; padding: 18px; margin-top: 4px; }
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: translateY(1px) scale(.99); box-shadow: 0 4px 12px rgba(255, 122, 61, .3); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); box-shadow: none; font-weight: 700; }
.btn.ghost:hover { border-color: var(--accent); filter: none; }
.btn-row { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }

.footlink { text-align: center; color: var(--muted); font-size: 12px; margin-top: 16px; cursor: pointer; }
.footlink:hover { color: var(--text); }

/* Shared focus ring for keyboard users */
.chip:focus-visible, .btn:focus-visible, .advanced > summary:focus-visible,
.peek:focus-visible, .switch input:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 2px;
}

/* Centered screens (rolling / mystery / arrived / empty / error) */
.center { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }

/* Rolling dice */
.dice-roll { font-size: 90px; line-height: 1; display: inline-block; }
@media (prefers-reduced-motion: no-preference) {
  .dice-roll { animation: dice-roll .8s ease-in-out infinite; }
  @keyframes dice-roll {
    0%   { transform: translateY(0) rotate(0deg); }
    50%  { transform: translateY(-22px) rotate(180deg) scale(1.08); }
    100% { transform: translateY(0) rotate(360deg); }
  }
}

/* Mystery card */
.mystery {
  width: 200px; height: 260px; border-radius: var(--r-lg); margin-bottom: 16px;
  background: repeating-linear-gradient(135deg, #2c231c, #2c231c 14px, #332921 14px, #332921 28px);
  border: 2px solid var(--accent);
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, .45);
}
.mystery .q { font-size: 78px; line-height: 1; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .4)); }
.mystery .dice { font-size: 30px; }

.meta { color: var(--text); font-size: 15px; font-weight: 700; margin-bottom: 2px; }
.meta b { color: var(--accent2); }
.status { font-size: 14px; font-weight: 700; margin: 6px 0 10px; }
.hint { color: var(--muted); font-size: 12px; margin-bottom: 16px; }

.peek {
  margin-top: 16px; font-size: 13px; color: var(--muted); cursor: pointer;
  border-bottom: 1px dashed var(--line); padding-bottom: 2px;
  transition: color .15s, border-color .15s;
}
.peek:hover { color: var(--text); border-color: var(--accent); }

/* Nav (尋寶導航) */
.navtop { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.navtop b { color: var(--accent2); font-size: 15px; }
.arrowbox { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.arrow { width: 150px; height: 150px; display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
@media (prefers-reduced-motion: no-preference) { .arrow { transition: transform .3s; } }
.arrow svg { filter: drop-shadow(0 6px 14px rgba(255, 122, 61, .5)); }
.instr { font-size: 26px; font-weight: 800; margin-bottom: 2px; }
.instr .dist { color: var(--accent2); }
.road { font-size: 14px; color: var(--muted); margin-bottom: 14px; }
.road b { color: var(--text); }
.next { font-size: 12px; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: var(--r-xs); padding: 8px 12px; margin-bottom: 14px; }
.hotbar { width: 100%; height: 8px; border-radius: var(--r-xs); background: #2c231c; overflow: hidden; margin-bottom: 8px; }
.hotbar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent2), var(--hot)); transition: width .4s ease; }
@media (prefers-reduced-motion: reduce) { .hotbar > span { transition: none; } }
.hotlabel { font-size: 12px; font-weight: 700; }
.hotlabel.warm { color: var(--accent); }
.hotlabel.hot { color: var(--hot); }
.navfoot { display: flex; gap: 10px; margin-top: 14px; }
.navfoot .btn { font-size: 14px; padding: 12px; }

/* Reveal card */
.reveal {
  width: 200px; min-height: 240px; border-radius: var(--r-lg); margin-bottom: 12px;
  background: linear-gradient(180deg, #2e2118, #241a13); border: 2px solid var(--accent2);
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 8px; padding: 20px 16px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, .45);
}
.reveal .emoji { font-size: 60px; }
.reveal .rname { font-size: 22px; font-weight: 800; line-height: 1.2; }
.reveal .rtag { font-size: 13px; color: var(--muted); }
.reveal .rtag b { color: var(--accent2); }
.celebrate { font-size: 50px; margin-bottom: 8px; }

/* Reveal flourish — fires each time the arrived screen activates */
@media (prefers-reduced-motion: no-preference) {
  #screen-arrived.active .reveal {
    animation: reveal-flip .7s cubic-bezier(.2, .8, .2, 1.05) both;
    backface-visibility: hidden;
  }
  #screen-arrived.active .celebrate {
    animation: celebrate-pop .6s cubic-bezier(.2, .8, .2, 1.2) both;
  }
  @keyframes reveal-flip {
    0%   { opacity: 0; transform: perspective(900px) rotateY(85deg) scale(.85); }
    60%  { opacity: 1; transform: perspective(900px) rotateY(-8deg) scale(1.03); }
    100% { opacity: 1; transform: perspective(900px) rotateY(0deg) scale(1); }
  }
  @keyframes celebrate-pop {
    0%   { opacity: 0; transform: scale(.3); }
    60%  { opacity: 1; transform: scale(1.25); }
    100% { transform: scale(1); }
  }
}

/* Empty / error */
.empty .emoji { font-size: 64px; margin-bottom: 10px; }
.empty .t { font-size: 17px; font-weight: 800; margin-bottom: 6px; }
.empty .s { font-size: 13px; color: var(--muted); margin-bottom: 22px; max-width: 260px; }
