/* ================= app shell (iOS conventions) =================
   safe areas, 44pt touch targets, bottom tab bar, bottom sheets, system font */
:root {
  --safeT: env(safe-area-inset-top, 0px);
  --safeB: env(safe-area-inset-bottom, 0px);
  --tabH: 56px;
  --accent: #1f8a63;
  --af: #ffd60a;
  --sys: -apple-system, "PingFang TC", "Noto Sans TC", "Noto Sans JP", "Microsoft JhengHei", sans-serif;
}
body.app { font-family: var(--sys); -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
body.app button, body.app select, body.app .cchip { touch-action: manipulation; -webkit-user-select: none; user-select: none; }
body.app #hud-l { top: calc(var(--safeT) + 14px); }
body.app #hud-r { top: calc(var(--safeT) + 14px); }
body.app #bar { bottom: calc(var(--tabH) + var(--safeB) + 10px); }
body.app #list { padding-bottom: calc(var(--tabH) + var(--safeB) + 40px); }
.item.got b::after { content: " ●"; color: var(--accent); font-size: 9px; vertical-align: 2px; }

/* ---------- tab bar ---------- */
#tabbar {
  position: fixed; z-index: 6; left: 0; right: 0; bottom: 0;
  height: calc(var(--tabH) + var(--safeB)); padding-bottom: var(--safeB);
  display: flex; background: rgba(251, 250, 246, 0.88);
  -webkit-backdrop-filter: blur(20px) saturate(1.6); backdrop-filter: blur(20px) saturate(1.6);
  border-top: 0.5px solid rgba(28, 26, 30, 0.25);
}
#tabbar button {
  flex: 1; border: 0; background: none; cursor: pointer; min-height: 49px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: #8e8a82; font: 600 10.5px var(--sys);
}
#tabbar svg, #camAlbum svg, .cchip svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#tabbar button.on { color: var(--accent); }
#tabbar button.on svg { stroke-width: 2.1; }
@media (min-width: 900px) and (min-height: 500px) {
  :root { --tabH: 64px; }
  #tabbar { left: 50%; right: auto; bottom: 14px; transform: translateX(-50%); width: 400px; height: 62px; padding: 0;
    border-radius: 20px; border: 1.5px solid var(--ink); box-shadow: 0 4px 0 var(--ink); }
  body.app #bar { bottom: 92px; }
}
body.quiz #tabbar { display: none; }

/* ---------- photo tab ---------- */
#camTop, #camBar, #vf, #chalHud, #missions, #camExit { display: none; }
body.photo #camTop, body.photo #camBar, body.photo #vf { display: flex; }
body.photo #vf { display: block; }
body.photo.chal #chalHud { display: flex; }
body.photo #missions.open { display: block; }
body.photo #hud-l, body.photo #hud-r, body.photo #bar, body.photo #drawer { display: none !important; }

/* ---------- top bar (觀賞): toolbar row + now-playing row ---------- */
body.app #hud-l .shows { overflow-x: auto; scrollbar-width: none; padding: 1px 1px 3px; }
body.app #hud-l .shows::-webkit-scrollbar { display: none; }
body.app #hud-l .shows .pill { flex: none; height: 34px; display: inline-flex; align-items: center; gap: 4px; padding: 0 11px; font-size: 13px; font-weight: 700; box-shadow: 0 2px 0 var(--ink); }
body.app #hud-l .shows .pill:active { transform: translateY(2px); box-shadow: none; }
body.app #hud-l .shows .pill i { font-style: normal; font-size: 15px; }
body.app #hud-l .shows .pill.off { opacity: .45; }
#showWho { margin-top: 5px; font-size: 12px; color: #4a463f; pointer-events: none; text-shadow: 0 0 4px var(--paper), 0 0 8px var(--paper); }
#showWho:empty { display: none; }
#showWho span { color: var(--dim); font-size: 11px; margin-left: 4px; }
#showMark { position: fixed; z-index: 5; display: none; transform: translate(-50%, -100%); pointer-events: none; font-size: 20px; color: #e0574a;
  text-shadow: 0 0 0 var(--ink), 1px 1px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink); animation: markBob 1s ease-in-out infinite; }
#showMark.show { display: block; }
body.title #showMark, body.quiz #showMark { display: none !important; }
@keyframes markBob { 50% { margin-top: -6px; } }
.show-bubble { position: fixed; z-index: 6; transform: translate(-50%, calc(-100% - 10px)); pointer-events: none; white-space: nowrap;
  background: #fffdf6; border: 1.5px solid var(--ink); border-radius: 14px; padding: 4px 12px; font: 800 15px var(--sys); color: var(--ink);
  box-shadow: 0 3px 0 var(--ink); animation: bubblePop .25s ease-out; }
.show-bubble::after { content: ''; position: absolute; left: 50%; bottom: -7px; width: 10px; height: 10px; background: #fffdf6;
  border-right: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); transform: translateX(-50%) rotate(45deg); }
@keyframes bubblePop { from { transform: translate(-50%, calc(-100% - 10px)) scale(.4); opacity: 0; } }
body.photo .show-bubble, body.quiz .show-bubble, body.title .show-bubble { display: none; }
body.app #hud-l .row { margin-top: 8px; gap: 6px; flex-wrap: nowrap; align-items: center; }
body.app #hud-l .tb > * { flex: none; height: 36px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
body.app #hud-l .tb #mode { flex: 0 1 auto; min-width: 0; max-width: 200px; overflow: hidden; text-overflow: ellipsis; display: block; line-height: 33px; }
body.app #hud-l .tb .ts-home, body.app #hud-l .more, body.app #hud-l .np > .pill { width: 36px; height: 36px; padding: 0; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
body.app #hud-l .more { font-size: 18px; letter-spacing: 1px; }
body.app #hud-l .np { align-items: flex-start; }
body.app #hud-l .np #card { flex: 1 1 auto; min-width: 0; margin-top: 0; }
body.app #hud-l .np #card.mini { min-height: 36px; display: flex; align-items: center; }
body.app #hud-l > #hud-r { position: static; display: flex; align-items: baseline; gap: 4px; margin-top: 6px; text-align: left; pointer-events: none; }
body.app #hud-l > #hud-r .big { font-size: 15px; margin: 0 10px 0 0; }
#morePop { position: fixed; z-index: 11; display: none; flex-direction: column; gap: 6px; min-width: 168px; padding: 8px; border-radius: 16px;
  background: rgba(251, 250, 246, 0.97); border: 1.5px solid var(--ink); box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }
#morePop.open { display: flex; }
#morePop > * { height: 38px; width: 100%; font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: flex-start; padding: 0 14px; border-radius: 12px; }
#morePop select.pill { padding-right: 28px; }
#morePop .check { gap: 8px; }
body.photo #morePop .check { display: none; }
.cchip.more { font-size: 18px; letter-spacing: 1px; padding: 0; width: 38px; justify-content: center; }

#camTop {
  position: fixed; z-index: 5; top: calc(var(--safeT) + 10px); left: 12px; right: 12px;
  gap: 8px; align-items: center; flex-wrap: wrap;
}
.cchip, #camStation {
  height: 38px; min-width: 44px; border-radius: 19px; padding: 0 14px; display: inline-flex; align-items: center; gap: 6px;
  background: rgba(251, 250, 246, 0.94); border: 1.5px solid var(--ink); font: 700 14px var(--sys); color: var(--ink); cursor: pointer;
}
.cchip svg { width: 18px; height: 18px; }
#camStation { appearance: none; -webkit-appearance: none; padding-right: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; line-height: 35px;
  background: rgba(251, 250, 246, 0.94) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%231c1a1e'/%3E%3C/svg%3E") no-repeat right 12px center; }
body.chal #chalBtn { background: #e0574a; color: #fff; }
.cchip.lv { margin-left: auto; cursor: default; gap: 8px; }
.cchip.lv i { display: block; width: 46px; height: 6px; border-radius: 3px; background: #e2ddd2; overflow: hidden; }
.cchip.lv em { display: block; height: 100%; background: var(--accent); }

#missions {
  position: fixed; z-index: 5; top: calc(var(--safeT) + 58px); right: 12px; width: min(300px, calc(100vw - 24px));
  background: rgba(251, 250, 246, 0.97); border: 1.5px solid var(--ink); border-radius: 14px; padding: 10px 12px; font-size: 13px; line-height: 1.55;
  box-shadow: 0 4px 0 var(--ink);
}
#missions b { display: block; margin-bottom: 4px; }
#missions div, .mission-list div { display: flex; gap: 8px; align-items: baseline; }
#missions i, .mission-list i { flex: none; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid #b9b3a6; font-style: normal; font-size: 11px; display: grid; place-items: center; color: #fff; }
#missions .done i, .mission-list .done i { background: var(--accent); border-color: var(--accent); }
#missions .done, .mission-list .done { color: #8e8a82; text-decoration: line-through; }

#chalHud {
  position: fixed; z-index: 5; top: calc(var(--safeT) + 58px); left: 50%; transform: translateX(-50%);
  gap: 14px; align-items: baseline; padding: 6px 16px; border-radius: 16px; background: rgba(20, 20, 22, 0.86); color: #fff;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}
#chalTime { font-size: 26px; font-weight: 700; min-width: 3.2em; text-align: right; }
#chalTime.low { color: #ff6b5e; }
#chalScore { font-size: 18px; }
#chalMult { font-size: 14px; color: #bbb; }
#chalMult.hot { color: var(--af); }

/* viewfinder (positioned by JS between the top chips and the camera bar) */
#vf { position: fixed; z-index: 2; pointer-events: none; box-shadow: 0 0 0 200vmax rgba(20, 20, 22, 0.32); border: 1px solid rgba(255, 255, 255, 0.5); }
#vf .c { position: absolute; width: 28px; height: 28px; border: 3px solid #fff; transition: border-color .15s; }
#vf.lock .c { border-color: var(--af); }
#vf .tl { left: -2px; top: -2px; border-right: 0; border-bottom: 0; }
#vf .tr { right: -2px; top: -2px; border-left: 0; border-bottom: 0; }
#vf .bl { left: -2px; bottom: -2px; border-right: 0; border-top: 0; }
#vf .br { right: -2px; bottom: -2px; border-left: 0; border-top: 0; }
#vf .cross { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; transform: translate(-50%, -50%); opacity: .8;
  background: linear-gradient(#fff, #fff) center / 2px 100% no-repeat, linear-gradient(#fff, #fff) center / 100% 2px no-repeat; }
#af { position: absolute; left: 8px; top: 8px; max-width: calc(100% - 16px); padding: 3px 9px; border-radius: 8px; font: 700 12.5px var(--sys);
  background: rgba(20, 20, 22, 0.72); color: var(--af); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#af:empty { display: none; }
#vf .vf-meta { position: absolute; left: 10px; bottom: 8px; color: #fff; font: 500 10.5px "JetBrains Mono", monospace; text-shadow: 0 1px 2px #000; }

/* first-time hint: drag sideways */
#panHint { position: absolute; left: 50%; top: 50%; transform: translate(-50%, 28px); display: none; padding: 5px 12px; border-radius: 10px;
  background: rgba(20, 20, 22, 0.72); color: #fff; font: 700 13px var(--sys); white-space: nowrap; }
#panHint.show { display: block; animation: sway 1.6s ease-in-out infinite; }
@keyframes sway { 25% { transform: translate(calc(-50% - 10px), 28px); } 75% { transform: translate(calc(-50% + 10px), 28px); } }

/* vertical angle slider inside the viewfinder's right edge */
#angle { display: none; position: fixed; z-index: 4; width: 44px; flex-direction: column; align-items: center; gap: 4px; touch-action: none; }
body.photo #angle { display: flex; }
#angle span { font: 700 10px var(--sys); color: #fff; text-shadow: 0 1px 2px #000; }
#angle em { font: 700 11px "JetBrains Mono", monospace; color: var(--af); font-style: normal; background: rgba(20, 20, 22, 0.7); padding: 1px 5px; border-radius: 6px; }
.a-track { position: relative; flex: 1; width: 44px; cursor: ns-resize; touch-action: none; }
.a-track::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 6px; transform: translateX(-50%); border-radius: 3px; background: rgba(20, 20, 22, 0.55); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5); }
.a-fill { position: absolute; left: 50%; bottom: 0; width: 6px; transform: translateX(-50%); border-radius: 3px; background: var(--af); }
.a-thumb { position: absolute; left: 50%; width: 26px; height: 26px; margin-left: -13px; border-radius: 50%; background: #fff; border: 2px solid #1c1a1e; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); }

/* horizontal-angle slider along the viewfinder's bottom edge */
#turn { display: none; position: fixed; z-index: 4; height: 40px; align-items: center; gap: 6px; touch-action: none; }
body.photo #turn { display: flex; }
#turn span { flex: none; font: 700 10px var(--sys); color: #fff; text-shadow: 0 1px 2px #000; }
#turn em { flex: none; font: 700 11px "JetBrains Mono", monospace; color: var(--af); font-style: normal; background: rgba(20, 20, 22, 0.7); padding: 1px 5px; border-radius: 6px; cursor: pointer; min-width: 34px; text-align: center; }
.t-track { position: relative; flex: 1; height: 40px; cursor: ew-resize; touch-action: none; }
.t-track::before { content: ""; position: absolute; top: 50%; left: 0; right: 0; height: 6px; transform: translateY(-50%); border-radius: 3px; background: rgba(20, 20, 22, 0.55); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5); }
.t-mid { position: absolute; left: 50%; top: 50%; width: 2px; height: 14px; transform: translate(-50%, -50%); background: var(--af); }
.t-thumb { position: absolute; top: 50%; width: 26px; height: 26px; margin-top: -13px; border-radius: 50%; background: #fff; border: 2px solid #1c1a1e; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); }
body.photo #vf .vf-meta { display: none; }

/* camera control bar: zoom chips, last photo, shutter, album */
#camBar {
  position: fixed; z-index: 5; left: 0; right: 0; bottom: calc(var(--tabH) + var(--safeB));
  flex-direction: column; align-items: center; gap: 6px; padding: 8px 0 12px;
  background: rgba(20, 20, 22, 0.84); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
@media (min-width: 900px) and (min-height: 500px) {
  #camBar { left: 50%; right: auto; width: 440px; transform: translateX(-50%); bottom: 92px; border-radius: 26px; }
}
#zoomChips { display: flex; gap: 8px; padding: 3px; border-radius: 20px; background: rgba(255, 255, 255, 0.08); }
#zoomChips button { width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.45); color: #fff; font: 700 12px var(--sys); cursor: pointer; }
#zoomChips button.on { color: var(--af); background: rgba(0, 0, 0, 0.7); transform: scale(1.08); }
.cam-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; width: min(440px, 100%); padding: 0 22px; }
#lastShot { justify-self: start; width: 52px; height: 52px; border-radius: 10px; border: 2px solid #fff; background: #3a3a3e; padding: 0; overflow: hidden; cursor: pointer; }
#lastShot img { width: 100%; height: 100%; object-fit: cover; display: none; }
#lastShot.has img { display: block; }
#camAlbum { justify-self: end; width: 52px; height: 52px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.14); color: #fff; display: grid; place-items: center; cursor: pointer; }
.shutter-wrap { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; }
#camMode { font: 800 12px var(--sys); letter-spacing: 0.2em; color: var(--af); }
#shutter {
  width: 80px; height: 80px; border-radius: 50%; padding: 5px; cursor: pointer;
  border: 5px solid #fff; background: transparent; box-shadow: none;
}
#shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: transform .08s; }
#shutter:active span { transform: scale(0.86); }
#shutter.press span { animation: press .22s ease-out; }
@keyframes press { 40% { transform: scale(0.82); background: #ddd; } }
body.chal #shutter span { background: #ff453a; }
#shutterHint { display: none; white-space: nowrap; padding: 2px 10px; border-radius: 8px; background: var(--af); color: #1c1a1e; font: 800 12.5px var(--sys); }
#shutterHint.show { display: block; animation: bob 1.2s ease-in-out infinite; }
#shutterHint.show + #camMode { display: none; }
@keyframes bob { 50% { transform: translateY(-4px); } }

/* last-shot pop-up card */
#shotPop {
  position: fixed; z-index: 6; right: 14px; bottom: calc(var(--tabH) + var(--safeB) + 182px);
  display: flex; gap: 10px; align-items: center; padding: 6px 12px 6px 6px; border-radius: 14px; cursor: pointer;
  background: #fbfaf6; border: 1.5px solid var(--ink); box-shadow: 0 4px 0 var(--ink); font-family: var(--sys);
  opacity: 0; transform: translateY(12px) scale(.96); pointer-events: none; transition: opacity .2s, transform .2s;
}
#shotPop.show { opacity: 1; transform: none; pointer-events: auto; }
#shotPop img { width: 72px; height: 52px; object-fit: cover; border-radius: 8px; }
#shotPop div { display: flex; flex-direction: column; text-align: left; font-size: 12px; }
#shotPop b { font-size: 14px; }
#shotPop span { color: #c98a00; }
#shotPop em { font: 700 18px "JetBrains Mono", monospace; color: var(--accent); font-style: normal; }
@media (min-width: 900px) and (min-height: 500px) { #shotPop { right: calc(50% - 220px); bottom: 290px; } }

#flash { position: fixed; inset: 0; z-index: 7; background: #fff; opacity: 0; pointer-events: none; }
#flash.on { animation: flash .4s ease-out; }
@keyframes flash { from { opacity: .85; } to { opacity: 0; } }
#countdown { position: fixed; z-index: 7; left: 50%; top: 45%; transform: translate(-50%, -50%) scale(.6); opacity: 0; pointer-events: none;
  font: 900 96px var(--sys); color: #fff; text-shadow: 0 4px 0 var(--ink), 0 0 24px rgba(0, 0, 0, .4); }
#countdown.pop { animation: cd .75s ease-out; }
@keyframes cd { 0% { opacity: 0; transform: translate(-50%, -50%) scale(1.6); } 25% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(.9); } }

/* ---------- title screen ---------- */
#titleScreen { display: none; position: fixed; inset: 0; z-index: 12; align-items: center; justify-content: center; padding: calc(var(--safeT) + 16px) 16px calc(var(--safeB) + 16px);
  background: radial-gradient(ellipse at 50% 45%, rgba(236, 231, 220, 0.25), rgba(236, 231, 220, 0.82) 70%); font-family: var(--sys); }
body.title #titleScreen { display: flex; }
body.title #hud-l, body.title #hud-r, body.title #bar, body.title #tabbar, body.title #drawer, body.title #trainTag, body.title #pins { display: none !important; }
.ts-corner { position: absolute; top: calc(var(--safeT) + 12px); right: calc(env(safe-area-inset-right, 0px) + 12px); display: flex; gap: 8px; }
.ts-card { width: min(440px, 100%); display: flex; flex-direction: column; gap: 12px; animation: tsIn .6s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes tsIn { from { transform: translateY(-30px) rotate(-3deg); opacity: 0; } }
.ts-ticket { position: relative; padding: 18px 22px 16px; border-radius: 14px; border: 2px solid var(--ink); box-shadow: 0 6px 0 var(--ink); text-align: center; overflow: hidden;
  background:
    repeating-linear-gradient(45deg, rgba(31, 138, 99, 0.07) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(-45deg, rgba(31, 138, 99, 0.07) 0 2px, transparent 2px 7px),
    #e3f2e6; transform: rotate(-1.2deg); }
.ts-punch { position: absolute; left: -14px; top: 50%; width: 28px; height: 28px; margin-top: -14px; border-radius: 50%; background: var(--paper); border: 2px solid var(--ink); }
.ts-top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.ts-kind { background: var(--ink); color: #e3f2e6; padding: 2px 10px; border-radius: 4px; font-weight: 800; letter-spacing: .2em; }
.ts-no { color: #4a6b58; }
.ts-logo { margin: 10px 0 0; font: 900 clamp(40px, 11vw, 62px)/1.05 "Noto Sans TC", "Noto Sans JP", var(--sys); letter-spacing: .04em; color: var(--ink);
  text-shadow: 3px 3px 0 #9fd3b4; }
.ts-en { font-size: 14px; letter-spacing: .5em; color: #1f8a63; margin-top: 4px; }
.ts-route { display: flex; justify-content: center; align-items: center; gap: 14px; margin: 12px 0 4px; font-size: 22px; }
.ts-route b { border-bottom: 3px solid var(--ink); padding: 0 6px; }
.ts-route span { color: #d7141a; font-weight: 900; }
.ts-sub { font-size: 14px; font-weight: 700; }
.ts-meta { font-size: 12.5px; color: #4a6b58; margin-top: 2px; }
.ts-corner .cchip.lang-sel { max-width: none; padding-right: 24px; }
.ts-legal { position: absolute; left: 0; right: 0; bottom: calc(var(--safeB) + 8px); display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 14px; font-size: 12px; }
.ts-legal a, .more-links a { color: #6a655c; text-decoration: none; }
.ts-legal a:hover, .more-links a:hover { text-decoration: underline; }
#morePop .more-links { height: auto; display: flex; flex-wrap: wrap; gap: 2px 10px; padding: 6px 6px 2px; border-top: 1px solid #e3ddd0; border-radius: 0; font-size: 12px; font-weight: 400; max-width: 190px; }
/* faint date stamp printed under the text, like a real ticket */
.ts-ticket > :not(.ts-stamp):not(.ts-punch) { position: relative; z-index: 1; }
.ts-stamp { position: absolute; z-index: 0; right: 14px; bottom: 10px; width: 70px; height: 70px; border-radius: 50%; border: 3px double #d7141a; color: #d7141a; display: grid; place-items: center;
  transform: rotate(14deg); font: 700 11px/1.15 "JetBrains Mono", monospace; opacity: .4; }
.ts-player { display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: center; align-items: baseline; font-size: 13px; padding: 8px 12px; border-radius: 12px; background: rgba(251, 250, 246, 0.92); border: 1.5px solid var(--ink); }
.ts-player b { font: 700 16px "JetBrains Mono", monospace; color: var(--accent); }
.ts-player span { color: #4a463f; }
.ts-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ts-actions .btn { min-height: 50px; font-size: 15px; box-shadow: 0 3px 0 var(--ink); }
.ts-actions .btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.ts-start { grid-column: 1 / -1; min-height: 58px !important; font-size: 18px !important; }
.ts-stations { display: none; position: absolute; inset: 0; padding: calc(var(--safeT) + 16px) 16px calc(var(--safeB) + 16px); background: rgba(236, 231, 220, 0.96); overflow-y: auto; }
.ts-stations.open { display: block; animation: up .25s ease-out; }
.ts-st-head { display: flex; justify-content: space-between; align-items: center; max-width: 760px; margin: 0 auto 12px; font-size: 20px; }
.ts-st-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; max-width: 760px; margin: 0 auto; }
.ts-st { display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto auto; column-gap: 10px; text-align: left; padding: 12px; border-radius: 14px; cursor: pointer;
  background: #fbfaf6; border: 2px solid var(--ink); border-left: 8px solid var(--c); box-shadow: 0 3px 0 var(--ink); font-family: var(--sys); }
.ts-st i { grid-row: span 3; font-size: 28px; font-style: normal; align-self: center; }
.ts-st b { font-size: 16px; }
.ts-st span { font-size: 12px; color: #4a463f; }
.ts-st em { font-style: normal; font-size: 11px; color: #8e8a82; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-st:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.ts-home { font-size: 16px !important; }
@media (max-height: 500px) {
  /* landscape phone: ticket left, buttons right */
  .ts-card { width: min(760px, 100%); display: grid; grid-template-columns: 1.1fr 1fr; grid-template-rows: auto auto; gap: 10px 14px; align-items: start; }
  .ts-ticket { grid-row: span 2; padding: 12px 18px; }
  .ts-logo { font-size: 40px; margin-top: 6px; }
  .ts-route { margin: 6px 0 2px; font-size: 18px; }
  .ts-stamp { width: 54px; height: 54px; font-size: 9.5px; }
  .ts-actions .btn { min-height: 42px; font-size: 13.5px; }
  .ts-start { min-height: 48px !important; font-size: 16px !important; }
  .ts-player { font-size: 12px; padding: 6px 10px; }
  #titleScreen { padding-left: calc(env(safe-area-inset-left, 0px) + 16px); padding-right: calc(env(safe-area-inset-right, 0px) + 16px); }
}

/* tapped-train bubble */
#trainTag { position: fixed; z-index: 7; left: 0; top: 0; width: min(300px, calc(100vw - 16px)); padding: 10px 12px; border-radius: 14px;
  background: rgba(251, 250, 246, 0.97); border: 1.5px solid var(--ink); box-shadow: 0 4px 0 var(--ink); font: 13px/1.45 var(--sys);
  opacity: 0; pointer-events: none; transform: translateY(6px); transition: opacity .15s, transform .15s; }
#trainTag.show { opacity: 1; pointer-events: auto; transform: none; cursor: pointer; }
#trainTag b { font-size: 15px; }
#trainTag .tt-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; margin-top: 3px; font-size: 12px; color: #4a463f; }
#trainTag .chip { background: var(--c); color: #fff; border-radius: 4px; padding: 0 6px; font-weight: 700; }
#trainTag .tt-rare { background: #d7141a; color: #fff; border-radius: 4px; padding: 0 6px; font-weight: 700; }
#trainTag .tt-sub { font: 500 11.5px "JetBrains Mono", monospace; color: #8e8a82; margin-top: 2px; }
#trainTag p { margin: 5px 0 0; font-size: 12.5px; color: #3a3630; }
#trainTag::after { content: ""; position: absolute; left: 50%; bottom: -9px; width: 14px; height: 14px; background: inherit; border: 1.5px solid var(--ink);
  border-top: 0; border-left: 0; transform: translateX(-50%) rotate(45deg); }
#trainTag.below::after { bottom: auto; top: -9px; transform: translateX(-50%) rotate(225deg); }

/* toasts */
#toasts { position: fixed; z-index: 9; top: calc(var(--safeT) + 104px); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: max-content; max-width: 92vw; }
.toast { background: rgba(251, 250, 246, 0.97); border: 1.5px solid var(--ink); border-radius: 14px; padding: 8px 14px; font-size: 13.5px; box-shadow: 0 3px 0 var(--ink); transition: opacity .5s, transform .5s; }
.toast.out { opacity: 0; transform: translateY(-8px); }
.toast.good { background: #e6f5ec; }
.toast.gold { background: #fff4c7; }
.toast.rare { background: #16171a; color: #ffd36b; border-color: #16171a; }
.toast .led { background: #d7141a; color: #fff; padding: 0 6px; border-radius: 4px; margin-right: 4px; font-weight: 900; }

/* rare-train pins */
#pins { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.pin { position: absolute; left: 0; top: 0; }
.pin span { position: absolute; transform: translate(-50%, -100%); margin-top: -10px; white-space: nowrap; padding: 4px 10px; border-radius: 10px;
  background: #16171a; color: #ffd36b; font: 700 12.5px var(--sys); box-shadow: 0 0 0 2px #ffd36b; animation: blink 1s steps(2) infinite; }
.pin span b { background: #d7141a; color: #fff; padding: 0 5px; border-radius: 3px; margin-right: 4px; }
.pin small { color: #fff; margin-left: 4px; }
.pin .arrow { position: absolute; display: none; left: -9px; top: -9px; width: 18px; height: 18px;
  background: #ffd36b; clip-path: polygon(100% 50%, 0 0, 25% 50%, 0 100%); }
.pin.edge .arrow { display: block; }
@keyframes blink { 50% { box-shadow: 0 0 0 2px #d7141a; } }

/* ---------- sheets ---------- */
.modal { position: fixed; inset: 0; z-index: 8; display: none; align-items: center; justify-content: center; background: rgba(20, 20, 22, 0.4); padding: 16px; }
.modal.open { display: flex; }
.sheet { position: relative; background: #fbfaf6; border: 1.5px solid var(--ink); border-radius: 18px; padding: 14px 16px 16px; width: min(620px, 100%); max-height: 100%; overflow: auto;
  box-shadow: 0 6px 0 var(--ink); font-family: var(--sys); animation: up .28s cubic-bezier(.2, .9, .3, 1); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet.wide { width: min(1080px, 100%); height: min(860px, 100%); display: flex; flex-direction: column; }
.grab { display: block; width: 100%; height: 18px; margin: -8px 0 4px; cursor: grab; touch-action: none; position: relative; }
.grab::before { content: ""; position: absolute; left: 50%; top: 6px; width: 38px; height: 5px; border-radius: 3px; background: #c9c3b7; transform: translateX(-50%); }
.sheet-title { font-size: 19px; font-weight: 800; }
.actions { display: flex; gap: 10px; margin-top: 12px; }
.btn { flex: 1; min-height: 46px; border-radius: 13px; border: 1.5px solid var(--ink); background: #fff; font: 700 15px var(--sys); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--accent); color: #fff; }
.round { width: 36px; height: 36px; border-radius: 50%; border: 0; background: #e9e5dc; font-size: 15px; cursor: pointer; }
.muted { color: #8e8a82; font-size: 13px; }
.badge { background: #e0574a; color: #fff; font-size: 11px; padding: 1px 8px; border-radius: 999px; vertical-align: middle; font-weight: 700; }
.badge.alt { background: #2f6fb4; }
.big { font: 700 52px "JetBrains Mono", monospace; text-align: center; }
@media (max-width: 720px), (max-height: 500px) {
  .modal { align-items: flex-end; padding: 0; }
  /* dvh = the height Safari actually shows (vh includes the area under its toolbars) */
  .sheet, .sheet.wide { width: 100%; max-height: 94vh; max-height: 94dvh; border-radius: 18px 18px 0 0; border-bottom: 0; box-shadow: none; padding-bottom: calc(var(--safeB) + 16px); }
  .sheet.wide { height: 94vh; height: 94dvh; }
}

/* share */
.btn.share { background: #2f6fb4; color: #fff; }
.btn.share::before { content: ""; width: 16px; height: 16px; margin-right: 6px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12M7 8l5-5 5 5M5 13v7h14v-7'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12M7 8l5-5 5 5M5 13v7h14v-7'/%3E%3C/svg%3E") center / contain no-repeat; }
.btn.sm { flex: none; min-height: 36px; padding: 0 12px; font-size: 13px; }
.row-r { display: flex; gap: 8px; align-items: center; }
#shareSheet { z-index: 11; }
#shareSheet .sheet { width: min(460px, 100%); }
.share-prev { display: block; max-width: 100%; max-height: 34vh; max-height: 34dvh; margin: 8px auto 4px; border-radius: 10px; border: 1.5px solid var(--ink); }
.share-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 8px; margin: 12px 0 4px; }
.share-grid a, .share-grid button { display: flex; flex-direction: column; align-items: center; gap: 6px; background: none; border: 0; color: var(--ink); text-decoration: none; font: 600 12.5px var(--sys); cursor: pointer; min-height: 44px; }
.share-grid b { width: 54px; height: 54px; border-radius: 15px; display: grid; place-items: center; color: #fff; font: 900 18px var(--sys); }
.share-tip { text-align: center; margin: 4px 0 0; }

/* result */
#resImg { width: 100%; display: block; border-radius: 10px; }
.res-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 10px 2px 0; }
#resTitle { font-size: 17px; }
.tag { display: inline-block; font-size: 11.5px; border-radius: 999px; padding: 1px 8px; margin: 5px 4px 0 0; background: #ece7dc; }
#resScore { text-align: right; line-height: 1.05; }
#resScore .st { display: block; color: #f2a516; font-size: 20px; letter-spacing: 2px; }
#resScore .sc { font: 700 36px "JetBrains Mono", monospace; }

/* challenge result */
#chalSummary { text-align: center; margin: 6px 0 10px; font-size: 14px; }
#chalShots { display: flex; flex-direction: column; gap: 4px; max-height: 38vh; overflow: auto; }
#chalShots div { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; padding: 6px 10px; background: #fff; border-radius: 10px; font-size: 13.5px; }
#chalShots span { color: #c98a00; }
#chalShots em { font: 700 14px "JetBrains Mono", monospace; color: var(--accent); font-style: normal; }

/* album */
.alb-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
#albCount { font-size: 12px; color: #8e8a82; margin-top: 2px; }
#albLevel { margin: 10px 0; }
.lvrow { display: flex; gap: 8px; align-items: baseline; font-size: 14px; }
.lvrow b { font: 700 18px "JetBrains Mono", monospace; color: var(--accent); }
.lvrow small { margin-left: auto; color: #8e8a82; }
.bar { height: 8px; border-radius: 4px; background: #e2ddd2; overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--accent); }
.seg { display: flex; padding: 3px; border-radius: 11px; background: #e6e1d6; margin-bottom: 10px; flex: none; }
.seg button { flex: 1; min-height: 34px; border: 0; border-radius: 9px; background: none; font: 600 13.5px var(--sys); color: #5c574e; cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .18); }
#albBody { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.chips button { flex: none; min-height: 32px; border: 0; background: #ece7dc; border-radius: 16px; padding: 0 12px; font: 600 12.5px var(--sys); cursor: pointer; }
.chips button.on { background: var(--ink); color: #fff; }
.chips small { opacity: .65; }
#albGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding-bottom: 12px; }
.card { border-radius: 12px; background: #fff; padding: 6px; font-size: 12.5px; display: flex; flex-direction: column; gap: 1px; cursor: pointer; border: 1.5px solid var(--ink); }
.card img, .card .ph { width: 100%; aspect-ratio: 3 / 2.2; object-fit: cover; border-radius: 8px; background: #ece7dc; }
.card .ph { display: grid; place-items: center; font-size: 30px; color: #c3bdb0; font-weight: 900; }
.card span { color: #6a655c; }
.card em { font-style: normal; font-size: 11px; color: #8e8a82; }
.card .st { font-style: normal; color: #f2a516; }
.card.lock { border-style: dashed; border-color: #c3bdb0; cursor: default; }
.card.lock b, .card.lock span { color: #a9a396; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; padding-bottom: 12px; }
.ach { display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center; padding: 10px; border-radius: 12px; background: #fff; border: 1.5px dashed #c3bdb0; opacity: .7; }
.ach i { grid-row: span 2; font-size: 26px; font-style: normal; filter: grayscale(1); }
.ach b { font-size: 14px; }
.ach span { font-size: 12px; color: #8e8a82; }
.ach em { grid-column: 2; font-size: 11px; color: var(--accent); font-style: normal; }
.ach.got { opacity: 1; border: 1.5px solid var(--ink); background: #fff8dc; }
.ach.got i { filter: none; }
.sec-t { font-weight: 800; font-size: 15px; margin: 6px 0; }
.sec-t small { color: #8e8a82; font-weight: 400; }
#stamps { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 14px; }
.stamp { width: 60px; height: 60px; border-radius: 50%; border: 2px dashed #c3bdb0; display: grid; place-items: center; font-size: 12px; font-weight: 900; color: #c3bdb0; transform: rotate(-8deg); text-align: center; line-height: 1.1; }
.stamp.got { border: 3px double var(--c, #d7141a); color: var(--c, #d7141a); background: #fff; }
.stamp.daily.got { --c: #d7141a; }
.mission-list { display: flex; flex-direction: column; gap: 6px; font-size: 14px; background: #fff; border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; }
.best-list { display: flex; flex-direction: column; gap: 4px; padding-bottom: 12px; }
.best-list div { display: flex; justify-content: space-between; background: #fff; border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.best-list b { font-family: "JetBrains Mono", monospace; }
#lightbox { z-index: 10; }
/* ---------- 全線通行證 ---------- */
#unlock { z-index: 13; }
#unlock .sheet { width: min(480px, 100%); }
.ul-perks { display: grid; gap: 8px; margin: 12px 0; }
.ul-perks div { display: grid; grid-template-columns: 32px 1fr; column-gap: 10px; align-items: center; background: #fff; border: 1px solid #e3ddd0; border-radius: 12px; padding: 9px 12px; }
.ul-perks i { grid-row: span 2; font-style: normal; font-size: 22px; text-align: center; }
.ul-perks b { font-size: 14.5px; }
.ul-perks span { font-size: 12px; color: #6a655c; line-height: 1.45; }
#ulBuy { width: 100%; min-height: 48px; font-size: 16px; }
.ul-note { font-size: 11.5px; margin: 8px 2px; line-height: 1.5; }
.ul-key { display: flex; gap: 8px; }
.ul-key input { flex: 1; min-width: 0; height: 40px; border: 1.5px solid var(--ink); border-radius: 10px; padding: 0 10px; font: 600 14px "JetBrains Mono", monospace; background: #fff; }
.ul-msg { min-height: 18px; font-size: 12.5px; color: #c0392b; margin: 6px 2px 0; }
.ul-ok { margin: 14px 0 4px; padding: 14px; border-radius: 12px; background: #e9f6ee; font-weight: 700; text-align: center; }
.ul-ok small { display: block; font-weight: 400; color: #6a655c; margin-top: 4px; }
/* locked = shown 「反黑」: dark tile, light text, 🔒 未解鎖 */
#list .item.locked { background: #2b2a2e; color: #d8d3c8; border-color: #2b2a2e; }
#list .item.locked span, #list .item.locked em { color: #a9a49a; }
#list .item.locked i { filter: grayscale(1) brightness(.5); }
#list .item.locked:hover { background: #3a393e; }
.card.pass { cursor: pointer; background: #2b2a2e; color: #d8d3c8; border-color: #2b2a2e; }
.card.pass .ph { background: #1c1b1f; color: #e8e3d8; }
.card.pass span, .card.pass em { color: #a9a49a; }
.lockb { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 999px; background: #2b2a2e; color: #f2efe6; font-size: 10.5px; vertical-align: middle; }
#trainTag .tt-lock { background: #2b2a2e; color: #f2efe6; border-radius: 999px; padding: 0 8px; cursor: pointer; }
.ach .pass-tag { color: #b8860b; cursor: pointer; }
.stamp.locked { opacity: .35; }
.ts-st.locked { background: #2b2a2e !important; color: #d8d3c8; }
.ts-st.locked span, .ts-st.locked em { color: #a9a49a; }
.ts-st.locked i { filter: none; }
.toast .tbtn { margin-left: 6px; border: 1.5px solid currentColor; background: none; color: inherit; border-radius: 999px; padding: 0 8px; font: inherit; cursor: pointer; pointer-events: auto; }
#lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }

/* ---------- quiz ---------- */
#quiz { display: none; }
body.quiz #quiz { display: block; }
body.quiz #hud-l, body.quiz #hud-r, body.quiz #bar, body.quiz #drawer { display: none !important; }
.q-top { position: fixed; z-index: 4; top: calc(var(--safeT) + 12px); left: 50%; transform: translateX(-50%); display: flex; gap: 14px; align-items: center;
  background: rgba(251, 250, 246, 0.95); border: 1.5px solid var(--ink); border-radius: 22px; padding: 4px 4px 4px 16px; font: 700 14px "JetBrains Mono", monospace; white-space: nowrap; }
#qTime.low { color: #e0574a; }
.q-ask { position: fixed; z-index: 4; top: calc(var(--safeT) + 64px); left: 50%; transform: translateX(-50%); font: 800 21px var(--sys); text-shadow: 0 0 6px var(--paper), 0 0 14px var(--paper); white-space: nowrap; }
#qChoices { position: fixed; z-index: 4; left: 50%; bottom: calc(var(--safeB) + 18px); transform: translateX(-50%); width: min(760px, calc(100vw - 24px)); display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#qChoices button { min-height: 60px; background: #fbfaf6; border: 2px solid var(--ink); border-radius: 16px; padding: 8px 12px; text-align: left; cursor: pointer; box-shadow: 0 4px 0 var(--ink);
  display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; font-family: var(--sys); }
#qChoices button small { grid-row: span 2; width: 24px; height: 24px; border-radius: 50%; background: #ece7dc; display: grid; place-items: center; font: 700 12px "JetBrains Mono", monospace; }
#qChoices button b { font-size: 16px; }
#qChoices button span { font-size: 12.5px; color: #6a655c; }
#qChoices button:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--ink); }
#qChoices button.right { background: #c9efd8; }
#qChoices button.wrong { background: #f6cfc9; }
#qSummary { text-align: center; margin: 8px 0; font-size: 14px; }
.q-rank { margin-top: 6px; font-weight: 700; color: var(--accent); }
.big small { font-size: 20px; margin-left: 4px; }
.q-lives { letter-spacing: -2px; font-family: var(--sys); }
#qScore.hit { animation: qhit .45s; }
@keyframes qhit { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }

/* ---------- quiz lobby ---------- */
#qLobby .sheet { width: min(560px, 100%); display: flex; flex-direction: column; }
#qlSub { font-size: 12.5px; margin-top: 2px; }
#qlStats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; flex: none; }
#qlStats div { background: #fff; border: 1.5px solid var(--ink); border-radius: 12px; padding: 8px 6px; text-align: center; }
#qlStats b { display: block; font: 700 22px "JetBrains Mono", monospace; }
#qlStats span { font-size: 11.5px; color: #6a655c; }
#qlBody { flex: 1 1 auto; min-height: 0; overflow: auto; }
.ql-rules { display: grid; gap: 8px; }
.ql-rules div { display: grid; grid-template-columns: 34px 1fr; column-gap: 10px; align-items: center; background: #fff; border-radius: 12px; padding: 10px 12px; border: 1px solid #e3ddd0; }
.ql-rules i { grid-row: span 2; font-size: 24px; font-style: normal; text-align: center; }
.ql-rules b { font-size: 14.5px; }
.ql-rules span { font-size: 12.5px; color: #6a655c; line-height: 1.45; }
.ql-rank div { display: grid; grid-template-columns: 34px auto 1fr auto; align-items: center; gap: 10px; padding: 9px 10px; border-bottom: 1px solid #e6e1d6; }
.ql-rank div:first-child { border-top: 1px solid #e6e1d6; }
.ql-rank i { font-style: normal; font-size: 22px; text-align: center; }
.ql-rank i small { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #ece7dc; font: 700 12px "JetBrains Mono", monospace; }
.ql-rank b { font: 700 20px "JetBrains Mono", monospace; }
.ql-rank span { font-size: 12px; color: #6a655c; }
.ql-rank em { font: 11px "JetBrains Mono", monospace; color: #8e8a82; font-style: normal; }
.ql-rank div.new { background: #fff3c4; border-radius: 10px; }
.ql-note { font-size: 11.5px; text-align: center; margin: 8px 0; }
.ql-boards { padding-bottom: 6px; }
.ql-rank span strong { color: var(--ink); font-weight: 700; margin-right: 2px; }
.ql-rank .gap { display: block; text-align: center; color: #8e8a82; padding: 2px; border: 0; }
.ql-nick { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12.5px; color: #6a655c; }
.ql-nick input, .q-nick input { flex: 1; min-width: 0; height: 36px; border: 1.5px solid var(--ink); border-radius: 10px; padding: 0 10px; font: 600 14px var(--sys); background: #fff; }
#qGlobal { text-align: center; margin: 4px 0 10px; font-size: 14px; font-weight: 700; }
.q-nick { display: flex; gap: 8px; max-width: 360px; margin: 0 auto; }
.ql-miss { display: grid; gap: 6px; }
.ql-miss div { display: grid; grid-template-columns: 1fr auto; padding: 8px 12px; background: #fff; border-radius: 10px; border: 1px solid #e3ddd0; }
.ql-miss span { grid-row: 2; font-size: 12px; color: #6a655c; }
.ql-miss em { grid-row: span 2; align-self: center; font: 700 14px "JetBrains Mono", monospace; color: #e0574a; font-style: normal; }
.ql-empty { text-align: center; padding: 26px 10px; color: #6a655c; }
.ql-empty i { font-size: 40px; font-style: normal; }
#qlStart { margin-top: 12px; min-height: 50px; font-size: 16px; width: 100%; flex: none; }

/* ---------- phones ---------- */
@media (max-width: 720px) {
  #camTop { gap: 6px; flex-wrap: nowrap; }
  body.app #hud-l { right: 14px; max-width: none; }
  body.app #hud-l > #fig, body.app #hud-l > .dim { display: none; }
  body.app #hud-l .tb { margin-top: 0; }
  #camStation { max-width: none !important; }
  body.app #hud-l .shows { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; overflow: visible; }
  body.app #hud-l .shows .pill { height: 46px; flex-direction: column; justify-content: center; gap: 0; padding: 2px 0; font-size: 11.5px; border-radius: 12px; }
  body.app #hud-l .shows .pill i { font-size: 17px; line-height: 1.1; }
  #camTop .cchip.lv, #missionCount .mw { display: none !important; }
  .cchip, #camStation { height: 36px; font-size: 13px; padding: 0 10px; flex: none; }
  #camStation { padding-right: 24px; min-width: 0; flex: 1 1 auto; max-width: 38vw; }
  #chalBtn span { display: none; }
  .cchip.lv i { display: none; }
  .cchip.lv { margin-left: 0; }
  #shotPop { left: 14px; right: 14px; bottom: calc(var(--tabH) + var(--safeB) + 176px); }
  #albGrid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .q-ask { font-size: 17px; }
  #qChoices button b { font-size: 14.5px; }
}
@media (max-height: 500px) {
  /* ---- landscape phone ---- */
  /* menu becomes a left-hand rail that is always visible (camera and album included) */
  :root { --tabH: 0px; --rail: calc(64px + env(safe-area-inset-left, 0px)); }
  #tabbar { top: 0; bottom: 0; left: 0; right: auto; width: var(--rail); height: auto; z-index: 9; flex-direction: column; justify-content: center; gap: 2px;
    padding: calc(var(--safeT) + 4px) 0 calc(var(--safeB) + 4px) env(safe-area-inset-left, 0px); border-top: 0; border-right: 0.5px solid rgba(28, 26, 30, 0.25); }
  #tabbar button { flex: none; min-height: 58px; gap: 2px; font-size: 11px; }
  #tabbar svg { width: 23px; height: 23px; }
  /* the atlas slider bar is secondary: hidden here to keep the scene clear */
  body.app #bar { display: none; }
  body.app #hud-l { left: calc(var(--rail) + 12px); top: calc(var(--safeT) + 8px); max-width: min(460px, calc(100vw - var(--rail) - 24px)); }
  body.app #hud-l > #fig, body.app #hud-l > .dim { display: none; }
  body.app #hud-l .row { margin-top: 6px; }
  body.app #hud-l .tb { margin-top: 0; }
  body.app #hud-l .tb > *, body.app #hud-l .tb .ts-home, body.app #hud-l .more, body.app #hud-l .np > .pill { height: 32px; }
  body.app #hud-l .tb .ts-home, body.app #hud-l .more, body.app #hud-l .np > .pill { width: 32px; }
  body.app #hud-l .shows .pill { height: 30px; font-size: 12px; padding: 0 9px; }
  body.app #hud-l .tb #mode { line-height: 29px; }
  body.app #hud-l .np #card.mini { min-height: 32px; }
  body.app #hud-l > #hud-r .big { font-size: 13px; }
  body.app #hud-r { right: calc(env(safe-area-inset-right, 0px) + 12px); top: calc(var(--safeT) + 8px); }
  body.app #drawer { left: var(--rail); width: min(312px, 50vw); }
  /* sheets sit beside the rail and fit the visible height */
  .modal { left: var(--rail); padding: 8px; align-items: center; }
  .sheet, .sheet.wide { border-radius: 16px; border-bottom: 1.5px solid var(--ink); max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); padding-bottom: 14px; }
  .sheet.wide { height: calc(100vh - 16px); height: calc(100dvh - 16px); }
  #lightbox { left: 0; }
  #toasts { left: calc(50% + var(--rail) / 2); }

  /* camera controls in a right-hand column like the iOS Camera app */
  #camBar { left: auto; right: 0; top: 0; bottom: 0; width: calc(116px + env(safe-area-inset-right, 0px)); flex-direction: column; justify-content: center; gap: 10px;
    padding: calc(var(--safeT) + 6px) env(safe-area-inset-right, 0px) calc(var(--safeB) + 6px) 0; border-radius: 0; transform: none; }
  #zoomChips { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border-radius: 14px; }
  #zoomChips button { width: 34px; height: 34px; }
  /* shutter on top, thumbnail + album side by side underneath */
  .cam-row { display: grid; grid-template-columns: 40px 40px; gap: 10px 12px; width: auto; padding: 0; justify-items: center; position: relative; }
  .shutter-wrap { order: 1; grid-column: 1 / span 2; }
  #lastShot { order: 2; width: 40px; height: 40px; justify-self: center; }
  #camAlbum { order: 3; width: 40px; height: 40px; justify-self: center; }
  #shutter { width: 68px; height: 68px; border-width: 4px; padding: 4px; }
  #camMode { display: none; }
  #shutterHint { position: absolute; right: calc(100% + 8px); top: 50%; transform: translateY(-50%); animation: none !important; }
  #camTop { top: calc(var(--safeT) + 8px); left: calc(var(--rail) + 10px); right: calc(116px + env(safe-area-inset-right, 0px) + 10px); flex-wrap: nowrap; gap: 6px; }
  .cchip, #camStation { height: 32px; font-size: 12.5px; padding: 0 10px; flex: none; }
  #camStation { padding-right: 24px; max-width: 26vw; }
  /* compact top bar: icons + counts only; the rail already offers navigation and the album shows the level */
  #camTop { overflow-x: auto; scrollbar-width: none; }
  #camTop::-webkit-scrollbar { display: none; }
  #chalBtn span, #missionCount .mw, .cchip.lv { display: none !important; }
  #camExit { display: none !important; }
  .cchip.lang-sel { padding: 0 20px 0 8px; max-width: 78px; }
  #missions { top: calc(var(--safeT) + 46px); right: calc(116px + env(safe-area-inset-right, 0px) + 10px); }
  #chalHud { top: calc(var(--safeT) + 46px); padding: 3px 12px; }
  #chalTime { font-size: 20px; }
  #shotPop { right: calc(116px + env(safe-area-inset-right, 0px) + 10px); bottom: calc(var(--safeB) + 10px); left: auto; }
  #panHint { font-size: 12px; }
  #chalHud { left: calc(50% + var(--rail) / 2); }
  #qChoices { grid-template-columns: repeat(4, 1fr); bottom: calc(var(--safeB) + 8px); }
  #qChoices button { min-height: 52px; }
  #qChoices button span { display: none; }
  #qLobby .sheet { width: min(760px, 100%); }
  #qlSub { display: none; }
  #qlStats { margin: 6px 0; }
  #qlStats div { display: flex; justify-content: center; align-items: baseline; gap: 6px; padding: 3px 6px; }
  #qlStats b { display: inline; font-size: 16px; }
  #qLobby .seg { margin-bottom: 4px; }
  #qLobby .seg button { min-height: 28px; }
  #qlStart { margin-top: 6px; min-height: 38px; }
  #resImg { max-height: 50vh; max-height: 50dvh; object-fit: contain; }
  #chalShots { max-height: 30dvh; }
}
