/* Layout: one full-screen night-sea map; a floating header, a bottom clue card, and a right-hand admin drawer. */
:root {
  --sea: #0a1c21;
  --sea-line: #12303a;
  --land: #173035;
  --land-hover: #1f3f45;
  --coast: #3b6168;
  --ink: #e9f1ec;
  --muted: #92aaa6;
  --panel: rgba(12, 30, 35, .92);
  --panel-solid: #10262c;
  --line: #2a474d;
  --citrine: #ffc55c;
  --citrine-ink: #2a1c00;
  --amethyst: #c3a1ff;
  --found: #7f9892;
  --danger: #ff8a7a;
  --shadow: 0 10px 34px rgba(0, 0, 0, .45);
  --plane: #f4f8f6;
  --plane-edge: #0a1c21;
  --plane-trail: #ffffff;
  --rail: #6f9aa0;
  --rail-tie: #173035;
  --train-edge: #0a1c21;
  --whale: #5f8796; --whale-belly: #c9dde2; --foam: #e9f6f7;
  --font-display: "Huninn", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --font-body: -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --sea: #d7e6e3; --sea-line: #c6dad6; --land: #f6f3ea; --land-hover: #ece6d6; --coast: #9db3ad;
    --ink: #13292b; --muted: #587170; --panel: rgba(255, 253, 248, .94); --panel-solid: #fffdf8; --line: #d7e0dc;
    --citrine: #d48a00; --citrine-ink: #ffffff; --amethyst: #7a4fd6; --found: #8a9d98; --danger: #c0392b;
    --shadow: 0 10px 30px rgba(20, 50, 50, .18); --plane: #ffffff; --plane-edge: #587170; --plane-trail: #ffffff; color-scheme: light;
    --rail: #7d8f8a; --rail-tie: #f6f3ea;
    --train-edge: #3d5654; --whale: #3f6676; --whale-belly: #dfe9ea; --foam: #ffffff;
  }
}
:root[data-theme="light"] {
  --sea: #d7e6e3; --sea-line: #c6dad6; --land: #f6f3ea; --land-hover: #ece6d6; --coast: #9db3ad;
  --ink: #13292b; --muted: #587170; --panel: rgba(255, 253, 248, .94); --panel-solid: #fffdf8; --line: #d7e0dc;
  --citrine: #d48a00; --citrine-ink: #ffffff; --amethyst: #7a4fd6; --found: #8a9d98; --danger: #c0392b;
  --shadow: 0 10px 30px rgba(20, 50, 50, .18); --plane: #ffffff; --plane-edge: #587170; --plane-trail: #ffffff; color-scheme: light;
    --rail: #7d8f8a; --rail-tie: #f6f3ea;
    --train-edge: #3d5654; --whale: #3f6676; --whale-belly: #dfe9ea; --foam: #ffffff;
}

html, body { height: 100%; margin: 0; }
[hidden] { display: none !important; }
body { background: var(--sea); color: var(--ink); font-family: var(--font-body); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--citrine); }
:focus-visible { outline: 2px solid var(--citrine); outline-offset: 2px; }

#app { position: relative; height: 100%; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#map3d { position: absolute; inset: 0; }
#map3d .maplibregl-ctrl-attrib { font-size: 10px; }
#map3d .maplibregl-ctrl-bottom-right { bottom: calc(env(safe-area-inset-bottom, 0px)); right: 64px; }
.county { fill: var(--land); stroke: var(--coast); stroke-width: .6; vector-effect: non-scaling-stroke; transition: fill .2s; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.county.active { fill: var(--land-hover); stroke: var(--citrine); stroke-opacity: .7; stroke-width: 1.2; }
.plane .body { fill: var(--plane); stroke: var(--plane-edge); stroke-width: .6; }
.plane .shadow { fill: #000; opacity: .22; }
.plane .trail { fill: none; stroke-width: 2; stroke-linecap: round; }
.rail-bed { fill: none; stroke: var(--rail); stroke-width: 1.8; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.rail-ties { fill: none; stroke: var(--rail-tie); stroke-width: .7; stroke-dasharray: 2 3; vector-effect: non-scaling-stroke; }
.train .body { stroke: var(--train-edge); stroke-width: .5; stroke-opacity: .7; }
.train .stripe, .train .stripe2 { fill: none; stroke-linecap: round; }
.rail-hsr { fill: none; stroke: var(--rail); stroke-width: 1.4; stroke-dasharray: 6 2; vector-effect: non-scaling-stroke; }
.station.hsr rect { fill: var(--panel-solid); stroke: #f26a21; stroke-width: 1.4; }
.train .roof-unit { fill: rgba(0, 0, 0, .16); }
.train .glass { fill: #1d2a33; opacity: .85; }
.train .head { fill: #fff3b0; }
.train .tail { fill: #ff4b3a; }
:root:not([data-theme="light"]) .train .head { filter: drop-shadow(0 0 2px #ffe7a0); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .train .head { filter: none; } }
.station circle { fill: var(--panel-solid); stroke: var(--rail); stroke-width: 1.4; }
.station text { font-size: 10px; fill: var(--muted); paint-order: stroke; stroke: var(--land); stroke-width: 3px; stroke-linejoin: round; letter-spacing: .05em; }
.whale-body { fill: var(--whale); }
.whale-belly { fill: var(--whale-belly); opacity: .9; }
.whale-eye { fill: #0a1c21; }
.whale-ripple { fill: none; stroke: var(--foam); stroke-width: 1.2; }
.whale-drop { fill: var(--foam); }
.attrib { position: absolute; left: 16px; bottom: calc(4px + env(safe-area-inset-bottom, 0px)); font-size: 10px; color: var(--muted); opacity: .8; z-index: 3; }
.attrib a { color: inherit; }
.county-label { fill: var(--muted); font-family: var(--font-display); text-anchor: middle; pointer-events: none; letter-spacing: .1em; }
.graticule { fill: none; stroke: var(--sea-line); stroke-width: 1; vector-effect: non-scaling-stroke; }

.area { fill: var(--citrine); fill-opacity: .08; stroke: var(--citrine); stroke-opacity: .55; stroke-dasharray: 4 4; pointer-events: none; }
.area.found { fill: var(--found); stroke: var(--found); fill-opacity: .06; }
.marker { cursor: pointer; outline: none; }
.marker:focus-visible .core { stroke: var(--ink); stroke-width: 3; }
.marker .hit { fill: transparent; }
.marker .core { fill: var(--citrine); stroke: var(--sea); stroke-width: 2; animation: blink 1.1s ease-in-out infinite; }
.marker.found .core { animation: none; }
.marker .ring { fill: none; stroke: var(--citrine); stroke-width: 2; transform-box: fill-box; transform-origin: center; animation: pulse 1.8s ease-out infinite; }
.marker .ring.r2 { animation-delay: .9s; }
.marker .glow { fill: var(--citrine); opacity: .35; filter: blur(4px); transform-box: fill-box; transform-origin: center; animation: breathe 1.8s ease-in-out infinite; }
.marker.found .core { fill: var(--found); }
.marker.found .ring, .marker.found .glow { display: none; }
.marker.found .tick { display: block; }
.marker .tick { display: none; stroke: var(--sea); stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.marker.selected .core { fill: var(--amethyst); }
.marker.selected .ring { stroke: var(--amethyst); }
.exact-pin { fill: var(--danger); stroke: var(--panel-solid); stroke-width: 2; }
@keyframes pulse { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(3.4); opacity: 0; } }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.5); } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .15; } }
@media (prefers-reduced-motion: reduce) { .marker .ring, .marker .glow { animation: none; } .marker .ring.r2 { display: none; } }

/* Header */
.top { position: absolute; top: 12px; left: 16px; right: 16px; display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; pointer-events: none; z-index: 5; }
.top > * { pointer-events: auto; }
.brand { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; box-shadow: var(--shadow); backdrop-filter: blur(8px); min-width: 0; max-width: min(420px, 100%); box-sizing: border-box; }
.brand h1 { margin: 0; font-family: var(--font-display); font-size: 22px; font-weight: 400; letter-spacing: .12em; display: flex; align-items: center; gap: 8px; }
.brand h1 .gem { width: 14px; height: 14px; flex: none; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.brand p b { color: var(--citrine); font-weight: 600; }
.brand .tagline { color: var(--ink); font-size: 13px; line-height: 1.5; margin-top: 6px; white-space: pre-wrap; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; box-shadow: var(--shadow); backdrop-filter: blur(8px); }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 999px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--citrine); color: var(--citrine-ink); }
.seg button .n { font-family: var(--font-mono); font-size: 11px; margin-left: 4px; opacity: .8; }
.pill-btn { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font-size: 13px; box-shadow: var(--shadow); backdrop-filter: blur(8px); }
select.pill-btn { appearance: none; padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.pill-btn.view[aria-pressed="true"] { background: var(--ink); color: var(--panel-solid); border-color: var(--ink); }
.pill-btn.admin[aria-pressed="true"] { background: var(--amethyst); color: var(--panel-solid); border-color: var(--amethyst); }

/* Zoom buttons */
.zoom { position: absolute; right: 16px; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 6px; z-index: 4; }
.zoom button { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); font-size: 18px; }

/* Toast / notices */
.notice { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(28px + env(safe-area-inset-bottom, 0px)); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; box-shadow: var(--shadow); max-width: min(420px, calc(100% - 32px)); width: max-content; box-sizing: border-box; font-size: 14px; line-height: 1.55; z-index: 6; text-align: center; }
.notice strong { font-family: var(--font-display); font-weight: 400; font-size: 16px; display: block; margin-bottom: 2px; }

/* Clue card */
.card { position: absolute; left: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); width: min(380px, calc(100% - 32px)); max-height: 62%; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); backdrop-filter: blur(10px); padding: 18px; z-index: 7; box-sizing: border-box; }
.card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.card-head > div { min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.chip.item { color: var(--amethyst); border-color: color-mix(in srgb, var(--amethyst) 45%, transparent); }
.chip.status-hidden { color: var(--citrine); border-color: color-mix(in srgb, var(--citrine) 45%, transparent); }
.chip.status-found { color: var(--found); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.card h2 { font-family: var(--font-display); font-weight: 400; font-size: 22px; margin: 10px 0 4px; letter-spacing: .04em; text-wrap: balance; }
.meta { color: var(--muted); font-size: 13px; }
.close { border: 0; background: none; width: 32px; height: 32px; border-radius: 10px; font-size: 20px; color: var(--muted); flex: none; }
.clue { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 12px; }
.clue .label { font-size: 11px; letter-spacing: .14em; color: var(--muted); }
.clue p { margin: 6px 0 0; line-height: 1.75; font-size: 15px; white-space: pre-wrap; }
.hint-btn { margin-top: 10px; border: 1px dashed var(--line); background: none; border-radius: 10px; padding: 8px 12px; font-size: 13px; color: var(--citrine); width: 100%; }
.found-note { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--found) 16%, transparent); font-size: 14px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* Buttons */
.btn { border: 1px solid var(--line); background: none; border-radius: 10px; padding: 8px 14px; font-size: 14px; text-decoration: none; color: inherit; display: inline-block; }
.btn.primary { background: var(--citrine); color: var(--citrine-ink); border-color: var(--citrine); }
.btn.violet { background: var(--amethyst); color: var(--panel-solid); border-color: var(--amethyst); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: default; }

/* Admin drawer */
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(380px, 100%); background: var(--panel-solid); border-left: 1px solid var(--line); box-shadow: var(--shadow); z-index: 8; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); box-sizing: border-box; }
.drawer header { display: flex; justify-content: space-between; align-items: center; padding: 16px 16px 10px; border-bottom: 1px solid var(--line); }
.drawer header h3 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 19px; letter-spacing: .08em; }
.drawer .body { overflow: auto; padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 12px; min-height: 0; flex: 1; }
.account { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 12px; color: var(--muted); }
.account .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.summary div { border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.summary b { display: block; font-family: var(--font-mono); font-size: 18px; font-weight: 500; }
.summary span { font-size: 11px; color: var(--muted); }
.list { display: flex; flex-direction: column; gap: 6px; }
.row { display: grid; grid-template-columns: 12px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: none; text-align: left; }
.row .d { width: 10px; height: 10px; border-radius: 50%; background: var(--citrine); }
.row.found .d { background: var(--found); }
.row .t { min-width: 0; }
.row .t b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .t span { color: var(--muted); font-size: 12px; }
.row .c { color: var(--muted); font-size: 12px; }
.help { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0; }
form { display: flex; flex-direction: column; gap: 12px; margin: 0; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); letter-spacing: .06em; }
.field input, .field select, .field textarea { background: var(--sea); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font-size: 15px; width: 100%; box-sizing: border-box; }
.field textarea { min-height: 84px; resize: vertical; line-height: 1.6; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.coord { font-family: var(--font-mono); font-size: 12px; color: var(--muted); background: var(--sea); border: 1px dashed var(--line); border-radius: 10px; padding: 9px 11px; }
.coord.missing { color: var(--danger); }
.err { color: var(--danger); font-size: 13px; }
.ok { color: var(--citrine); font-size: 13px; }

/* Admin login */
.login { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: color-mix(in srgb, var(--sea) 70%, transparent); backdrop-filter: blur(6px); }
.login form { width: min(360px, 100%); background: var(--panel-solid); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 22px; box-sizing: border-box; }
.login h2 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 22px; letter-spacing: .1em; }

@media (max-width: 560px) {
  .drawer { top: auto; height: 78%; border-left: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; }
  .card { left: 16px; right: 16px; width: auto; }
  .brand h1 { font-size: 19px; }
}

/* Countdown lock: a blurred grey layer over the whole map with the time left */
.lock { position: absolute; inset: 0; z-index: 15; display: grid; place-items: center; padding: 20px; background: rgba(86, 92, 94, .78); }
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .lock { background: rgba(96, 102, 104, .42); -webkit-backdrop-filter: blur(9px) grayscale(1); backdrop-filter: blur(9px) grayscale(1); }
}
.lock-box { text-align: center; color: #fff; text-shadow: 0 2px 14px rgba(0, 0, 0, .45); max-width: 520px; }
.lock-title { font-family: var(--font-display); font-size: clamp(22px, 5.5vw, 34px); letter-spacing: .2em; }
.lock-time { display: flex; justify-content: center; gap: clamp(8px, 2.5vw, 18px); margin: 22px 0 6px; font-size: 13px; letter-spacing: .2em; }
.lock-time span { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: clamp(56px, 16vw, 84px); padding: 12px 6px; border-radius: 14px; background: rgba(0, 0, 0, .28); border: 1px solid rgba(255, 255, 255, .22); }
.lock-time b { font-family: var(--font-mono); font-weight: 500; font-size: clamp(30px, 9vw, 52px); line-height: 1; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.lock-text { margin: 18px 0 0; font-size: 15px; line-height: 1.9; white-space: pre-line; }

/* 列表打開時像捲軸一樣由上往下展開，項目依序出現 */
@keyframes ck-unroll { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes ck-item { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.unroll { animation: ck-unroll .55s cubic-bezier(.3, .7, .2, 1) both; }
.unroll > * { animation: ck-item .35s ease both; animation-delay: .62s; }
.unroll > :nth-child(1) { animation-delay: 0.080s; }
.unroll > :nth-child(2) { animation-delay: 0.125s; }
.unroll > :nth-child(3) { animation-delay: 0.170s; }
.unroll > :nth-child(4) { animation-delay: 0.215s; }
.unroll > :nth-child(5) { animation-delay: 0.260s; }
.unroll > :nth-child(6) { animation-delay: 0.305s; }
.unroll > :nth-child(7) { animation-delay: 0.350s; }
.unroll > :nth-child(8) { animation-delay: 0.395s; }
.unroll > :nth-child(9) { animation-delay: 0.440s; }
.unroll > :nth-child(10) { animation-delay: 0.485s; }
.unroll > :nth-child(11) { animation-delay: 0.530s; }
.unroll > :nth-child(12) { animation-delay: 0.575s; }
