/* 8-bit 像素风 UI —— 硬边框、无圆角、无模糊，最近邻放大 */
/* 字体为站内实际用字的子集，由 scripts/build-fonts.mjs 生成并写回文件名。
   unicode-range 必须与该脚本里的 RANGES 保持一致。 */
@font-face {
  font-family: 'PixelZH';
  src: url('../fonts/pixel-zh.99a91f2f.woff2') format('woff2');
  font-display: swap;
  unicode-range: U+2E80-2FFF, U+3000-30FF, U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF, U+FF00-FFEF;
}
@font-face {
  font-family: 'PixelLatin';
  src: url('../fonts/pixel-latin.8c9710a7.woff2') format('woff2');
  font-display: swap;
  unicode-range: U+0000-02FF, U+0400-04FF, U+2000-2BFF;
}

:root {
  --bg: #0b0c14;
  --panel: #1a1c2c;
  --panel2: #141522;
  --fg: #f4f4f4;
  --muted: #94a0c8;
  --accent: #41a6f6;
  --accent2: #ef7d9d;
  --gold: #ffcd75;
  --green: #38b764;
  --red: #ef7d57;
  --border: #f4f4f4;
  --shadow: #000000;
  font-size: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'PixelLatin', 'PixelZH', 'Courier New', monospace;
  image-rendering: pixelated;
  -webkit-font-smoothing: none;
  font-smooth: never;
}

#scene {
  position: fixed; inset: 0; width: 100%; height: 100%;
  display: block; cursor: grab; touch-action: none;
}
#scene:active { cursor: grabbing; }

/* ---------- iPhone 拍摄取景框 ---------- */
#phone-hud {
  position: fixed; inset: 82px 12px 12px; z-index: 6;
  display: none; pointer-events: none;
  border: 1px solid rgba(255,255,255,0.34);
  box-shadow: inset 0 0 80px rgba(0,0,0,0.2);
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
}
body.phone-mode #phone-hud { display: block; }
.phone-hud-top, .phone-hud-bottom {
  position: absolute; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  padding: 6px 11px; border-radius: 14px;
  background: rgba(0,0,0,0.58); color: #fff;
  font-size: 12px; letter-spacing: 0.02em;
  backdrop-filter: blur(6px);
}
.phone-hud-top { top: 12px; }
.phone-hud-bottom { bottom: 12px; }
.phone-hud-bottom b {
  display: grid; place-items: center; min-width: 42px; height: 30px;
  border-radius: 15px; background: #f6d14a; color: #111; font-size: 14px;
}
.phone-corner { position: absolute; width: 34px; height: 34px; border-color: rgba(255,255,255,0.8); }
.phone-corner.tl { top: 14px; left: 14px; border-top: 2px solid; border-left: 2px solid; }
.phone-corner.tr { top: 14px; right: 14px; border-top: 2px solid; border-right: 2px solid; }
.phone-corner.bl { bottom: 14px; left: 14px; border-bottom: 2px solid; border-left: 2px solid; }
.phone-corner.br { bottom: 14px; right: 14px; border-bottom: 2px solid; border-right: 2px solid; }
.phone-reticle {
  position: absolute; top: 50%; left: 50%; width: 54px; height: 54px;
  transform: translate(-50%, -50%); border: 1px solid rgba(255,215,64,0.75);
  border-radius: 50%;
}
.phone-reticle span { position: absolute; inset: 50%; width: 4px; height: 4px; transform: translate(-50%,-50%); background: #ffd740; border-radius: 50%; }

/* 像素面板：双层硬边框 */
.pixel-panel {
  background: var(--panel);
  border: 2px solid var(--border);
  box-shadow: 0 0 0 2px var(--shadow), 4px 4px 0 2px var(--shadow);
  border-radius: 0;
}

/* ---------- 加载 ---------- */
#loading {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: var(--bg);
  transition: opacity 0.5s, visibility 0.5s;
}
#loading.done { opacity: 0; visibility: hidden; }
#loading p { color: var(--muted); letter-spacing: 0.3em; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.spinner {
  width: 40px; height: 40px;
  background: var(--accent);
  animation: pixelspin 1s steps(8) infinite;
}
@keyframes pixelspin { to { transform: rotate(360deg); } }

/* ---------- 顶栏 ---------- */
#topbar {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 10; display: flex; align-items: center; gap: 20px;
  padding: 10px 16px; max-width: calc(100vw - 24px);
}
.topbar-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.venue-brand {
  display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto;
  min-height: 42px; padding-right: 12px; border-right: 2px solid #34374f;
  color: var(--fg); text-decoration: none; letter-spacing: .12em; font-size: .7rem;
}
.venue-brand:hover { color: var(--gold); }
.venue-brand:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.venue-brand .brand-mark {
  position: relative; display: block; width: 20px; height: 34px; overflow: hidden;
}
.venue-brand .brand-mark img {
  position: absolute; width: 45px; height: 45px; left: -13px; top: -5px; max-width: none;
}
#topbar h1 { font-size: 1.25rem; letter-spacing: 0.05em; white-space: nowrap; text-shadow: 2px 2px 0 var(--shadow); }
#topbar h1 span { color: var(--accent2); margin-left: 6px; font-size: 0.95rem; }
#topbar .title p { font-size: 0.8rem; color: var(--muted); margin-top: 3px; }
.top-actions { display: flex; gap: 10px; }
.venue-data-note { position: fixed; top: 100px; right: 14px; z-index: 31; }
.venue-data-note > summary { list-style: none; }
.venue-data-note > summary::-webkit-details-marker { display: none; }
.venue-data-note[open] > summary { background: var(--gold); color: #0b0c14; }
.venue-data-note-body {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 32;
  width: min(430px, calc(100vw - 28px)); padding: 14px;
  color: var(--muted); font-size: .74rem; line-height: 1.65;
}
.in-seat .venue-data-note { display: none; }
.venue-data-note-body strong { display: block; margin-bottom: 7px; color: var(--gold); letter-spacing: .08em; }
.venue-data-note-body p + p { margin-top: 8px; }
.venue-data-note-body p[lang="en"] { color: #aeb8d8; border-top: 1px solid #34374f; padding-top: 8px; }
.venue-data-note-body .contribute-note { margin-top: 11px; padding-top: 10px; border-top: 1px solid #34374f; }
.venue-data-note-body .contribute-note > strong { margin-bottom: 0; }
.venue-data-note-body .contribute-note p[lang="en"] { border-top: 0; padding-top: 0; }
.contribute-email {
  display: inline-block; margin-top: 9px; padding: 7px 9px;
  color: #0b0c14; background: var(--accent); border: 1px solid var(--border);
  box-shadow: 2px 2px 0 var(--shadow); font-size: .72rem; text-decoration: none;
}
.contribute-email:hover { background: var(--gold); }

#mobile-controls, .panel-close { display: none; }

/* ---------- 像素按钮 ---------- */
.pill {
  border: 2px solid var(--border);
  background: var(--panel2);
  color: var(--fg);
  border-radius: 0;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 3px 3px 0 0 var(--shadow);
  transition: none;
  white-space: nowrap;
}
.pill:hover { background: #26283c; }
.pill:active { transform: translate(3px, 3px); box-shadow: 0 0 0 0 var(--shadow); }
.pill.active { background: var(--accent); color: #0b0c14; }
.pill.primary { background: var(--accent); color: #0b0c14; }
.pill.primary:hover { background: #5ab6ff; }
.pill.back { width: 100%; margin-top: 12px; }

/* ---------- 左侧面板 ---------- */
#panel {
  position: fixed; left: 14px; top: 100px; z-index: 9;
  width: 288px; padding: 14px;
  display: flex; flex-direction: column; gap: 16px;
  max-height: calc(100vh - 130px); overflow-y: auto;
  transition: transform 0.3s steps(6), opacity 0.3s steps(6);
}
body.in-seat #panel { transform: translateX(-120%); opacity: 0; pointer-events: none; }
#panel h2 {
  font-size: 0.85rem; color: var(--gold);
  letter-spacing: 0.15em; margin-bottom: 9px;
}
#panel h2::before { content: '▸ '; }
.zone-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.layout-options { display: grid; gap: 7px; }
.layout-option {
  width: 100%; text-align: left; white-space: normal; line-height: 1.35;
  border-color: var(--muted);
}
.layout-option.active { border-color: var(--gold); background: var(--gold); color: #111; }
.layout-note { margin-top: 7px; color: var(--muted); font-size: .72rem; line-height: 1.45; }
.zone-chip {
  border: 2px solid var(--chip, #888);
  background: var(--panel2);
  color: var(--fg); border-radius: 0;
  padding: 7px 0; font-size: 0.85rem; font-family: inherit; cursor: pointer;
  box-shadow: 2px 2px 0 0 var(--shadow);
}
.zone-chip:hover { background: var(--chip); color: #0b0c14; font-weight: 700; }
.zone-chip:active { transform: translate(2px, 2px); box-shadow: none; }

.search { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.search input {
  grid-column: span 1;
  min-width: 0; width: 100%;
  background: var(--panel2);
  border: 2px solid var(--muted);
  border-radius: 0; color: var(--fg);
  padding: 8px 10px; font-size: 0.9rem; font-family: inherit; outline: none;
}
.search input:focus { border-color: var(--accent); box-shadow: 2px 2px 0 0 var(--shadow); }
.search input#in-zone { grid-column: span 2; }
.search button { grid-column: span 2; }
.err { color: var(--red); font-size: 0.8rem; margin-top: 6px; min-height: 1em; }

.hint p { font-size: 0.8rem; color: var(--muted); line-height: 1.8; }
.hint .muted { opacity: 0.7; margin-top: 4px; }
.site-contact {
  display: grid; gap: 6px; padding-top: 12px; border-top: 1px solid #34374f;
  font-size: .7rem; line-height: 1.45;
}
.site-contact a { color: var(--accent); text-decoration: none; overflow-wrap: anywhere; }
.site-contact a:hover { color: var(--gold); text-decoration: underline; }

/* ---------- 小地图 ---------- */
#minimap-wrap {
  position: fixed; right: 14px; bottom: 14px; z-index: 9;
  padding: 8px; text-align: center;
}
#minimap { display: block; cursor: crosshair; image-rendering: pixelated; }
#minimap-wrap p { font-size: 0.75rem; color: var(--muted); margin-top: 6px; }

/* ---------- 座位卡 ---------- */
#seat-card {
  position: fixed; left: 14px; bottom: 14px; z-index: 9;
  width: 288px; padding: 14px;
  transform: translateY(140%); opacity: 0;
  transition: transform 0.35s steps(7), opacity 0.35s steps(7);
}
#seat-card.show { transform: translateY(0); opacity: 1; }
.sc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sc-head h3 { font-size: 1.15rem; text-shadow: 2px 2px 0 var(--shadow); }
.badge {
  font-size: 0.72rem; padding: 4px 9px; border-radius: 0;
  background: var(--panel2); color: var(--accent);
  border: 2px solid var(--accent);
}
.tag { font-size: 0.85rem; color: var(--accent2); margin-top: 6px; }
.tag::before { content: '★ '; color: var(--gold); }
.sc-stats { display: flex; gap: 8px; margin-top: 12px; }
.sc-stats > div {
  flex: 1; background: var(--panel2);
  border: 2px solid #2a2c44;
  border-radius: 0; padding: 7px 9px;
}
.sc-stats label { font-size: 0.72rem; color: var(--muted); display: block; }
.sc-stats b { font-size: 1.05rem; color: var(--gold); }
.sc-stats em { display: block; margin-top: 2px; font-style: normal; font-size: .64rem; color: var(--muted); line-height: 1.35; }
.sc-aim { display: flex; gap: 8px; margin-top: 12px; }
.sc-aim .pill { flex: 1; font-size: 0.8rem; padding: 8px 4px; }

.phone-camera {
  margin-top: 12px; padding-top: 12px;
  border-top: 2px solid #2a2c44;
}
.phone-toggle { width: 100%; }
.phone-zooms {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  max-height: 0; margin-top: 0; overflow: hidden; opacity: 0;
  transition: max-height 0.22s steps(4), margin-top 0.22s steps(4), opacity 0.22s steps(4);
  visibility: hidden; pointer-events: none;
}
.phone-zooms.show { max-height: 42px; margin-top: 9px; opacity: 1; visibility: visible; pointer-events: auto; }
.phone-zooms button {
  height: 34px; border: 2px solid var(--muted); background: var(--panel2);
  color: var(--fg); font: inherit; cursor: pointer; box-shadow: 2px 2px 0 var(--shadow);
}
.phone-zooms button:hover { border-color: var(--gold); }
.phone-zooms button.active { background: var(--gold); border-color: var(--gold); color: #111; }
#phone-readout { margin-top: 7px; color: var(--muted); font-size: 0.66rem; line-height: 1.35; text-align: center; }

.sc-nav { display: flex; flex-direction: column; align-items: center; gap: 5px; margin-top: 12px; }
.sc-nav > div { display: flex; gap: 5px; }
.sc-nav button {
  width: 46px; height: 36px;
  background: var(--panel2);
  border: 2px solid var(--border); border-radius: 0;
  color: var(--fg); cursor: pointer; font-size: 0.85rem; font-family: inherit;
  box-shadow: 2px 2px 0 0 var(--shadow);
}
.sc-nav button:hover { background: #26283c; }
.sc-nav button:active { transform: translate(2px, 2px); box-shadow: none; }
.seat-card-actions { display: block; }
.seat-card-toggle { display: none; }

/* ---------- tooltip ---------- */
#tooltip {
  position: fixed; top: 0; left: 0; z-index: 20;
  pointer-events: none; opacity: 0;
  background: var(--panel);
  border: 2px solid var(--border);
  box-shadow: 3px 3px 0 0 var(--shadow);
  border-radius: 0; padding: 4px 9px;
  font-size: 0.9rem; transition: opacity 0.1s steps(2);
}

/* ---------- 移动端 ---------- */
@media (max-width: 760px) {
  :root { font-size: 15px; }
  #topbar {
    top: max(6px, env(safe-area-inset-top)); width: calc(100vw - 12px);
    max-width: none; flex-direction: column; align-items: stretch; gap: 7px;
    padding: 8px 9px; overflow: hidden;
  }
  .topbar-info { width: 100%; gap: 8px; }
  .venue-brand { min-height: 34px; padding-right: 8px; }
  .venue-brand > span:last-child { display: none; }
  .venue-brand .brand-mark { width: 17px; height: 29px; }
  .venue-brand .brand-mark img { width: 39px; height: 39px; left: -11px; top: -5px; }
  #topbar .title { min-width: 0; }
  #topbar h1 { font-size: 1rem; overflow: hidden; text-overflow: ellipsis; }
  #topbar h1 span { font-size: .78rem; }
  #topbar .title p { font-size: .68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .top-actions {
    width: 100%; gap: 7px; overflow-x: auto; padding: 0 2px 4px;
    scrollbar-width: none; overscroll-behavior-x: contain;
  }
  .top-actions::-webkit-scrollbar { display: none; }
  .top-actions .pill { flex: 0 0 auto; min-height: 42px; padding: 7px 10px; font-size: .78rem; }
  .venue-data-note {
    top: auto; right: 8px; bottom: max(8px, env(safe-area-inset-bottom));
  }
  .venue-data-note > summary { min-height: 44px; padding: 8px 10px; font-size: .74rem; }
  .venue-data-note-body {
    top: auto; right: 0; bottom: calc(100% + 8px); width: calc(100vw - 16px);
    max-height: min(58svh, 440px); overflow-y: auto; padding: 12px;
    font-size: .7rem; line-height: 1.55;
  }
  body.in-seat #topbar {
    width: auto; max-width: calc(100vw - 16px); right: 8px; left: 8px;
    transform: none; padding: 7px 10px;
  }
  body.in-seat #topbar .top-actions { display: none; }
  body.in-seat #topbar .topbar-info { gap: 7px; }
  body.in-seat #topbar .title { display: flex; align-items: baseline; gap: 8px; }
  body.in-seat #topbar .title p { margin: 0; max-width: 45vw; }

  #mobile-controls {
    display: block; position: fixed; left: 8px;
    bottom: max(8px, env(safe-area-inset-bottom)); z-index: 11;
    min-height: 44px; padding: 8px 12px;
  }
  body.in-seat #mobile-controls { display: none; }
  #panel {
    left: 8px; right: 8px; top: auto;
    bottom: max(8px, env(safe-area-inset-bottom)); width: auto;
    max-height: min(72svh, 620px); padding: 46px 14px 16px;
    transform: translateY(calc(100% + 18px)); opacity: 0; pointer-events: none;
    overscroll-behavior: contain;
  }
  body.mobile-panel-open #panel { transform: translateY(0); opacity: 1; pointer-events: auto; }
  body.in-seat #panel { transform: translateY(calc(100% + 18px)); opacity: 0; pointer-events: none; }
  .panel-close {
    display: grid; place-items: center; position: absolute; top: 8px; right: 8px;
    width: 34px; height: 34px; border: 2px solid var(--border); background: var(--panel2);
    color: var(--fg); font: inherit; font-size: 1.25rem;
  }
  .zone-grid { grid-template-columns: repeat(4, 1fr); }
  .zone-chip, .search input, .search button { min-height: 44px; }
  .search input { font-size: 16px; }

  #minimap-wrap { display: none; }
  #seat-card {
    width: calc(100vw - 16px); left: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    max-height: none; overflow: hidden; overscroll-behavior: contain;
    padding: 10px 11px;
  }
  .sc-head { align-items: flex-start; }
  .sc-head h3 { font-size: 1rem; }
  .badge { max-width: 48%; text-align: right; }
  .tag { margin-top: 3px; font-size: .78rem; }
  .seat-card-details { display: none; }
  #seat-card.expanded {
    max-height: min(62svh, 540px); overflow-y: auto;
    padding: 12px;
  }
  #seat-card.expanded .seat-card-details { display: block; }
  .seat-card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
  .seat-card-toggle { display: block; }
  .seat-card-actions .pill { min-height: 44px; margin: 0; width: 100%; padding: 7px 8px; }
  .sc-stats, .sc-aim, .phone-camera, .sc-nav { margin-top: 9px; }
  .sc-aim .pill, .phone-toggle, .pill.back { min-height: 42px; }
  .sc-nav { position: static; }
  .sc-nav button { width: 48px; height: 44px; }

  #phone-hud { inset: 64px 6px max(6px, env(safe-area-inset-bottom)); }
  body.phone-mode.in-seat #seat-card:not(.expanded) { opacity: .88; }
  .phone-hud-bottom span { display: none; }
}

@media (max-width: 380px) {
  #topbar h1 span { display: none; }
  .top-actions .pill { font-size: .72rem; padding-inline: 8px; }
  #seat-card.expanded { max-height: 68svh; }
  .sc-aim .pill { font-size: .72rem; }
}

@media (max-height: 560px) and (orientation: landscape) {
  #topbar { left: 6px; transform: none; width: min(56vw, 610px); }
  #topbar .title { display: none; }
  #mobile-controls { bottom: max(6px, env(safe-area-inset-bottom)); }
  #panel { max-height: calc(100svh - 16px); }
  #seat-card { width: min(390px, 48vw); max-height: calc(100svh - 16px); }
  #phone-hud { inset: 62px 6px 6px; }
}

/* Blender model review tools */
.thunder-review-grid {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;}
.thunder-review-grid .pill{min-width:0;padding:8px 4px;font-size:.8rem;text-align:center;white-space:normal;overflow-wrap:anywhere;}
@media(min-width:761px){
 body[data-venue="thunderdome"] #panel {width:250px;padding:12px;}
 body[data-venue="thunderdome"] #minimap {width:126px!important;height:140px!important;}
 body[data-venue="thunderdome"] #minimap-wrap p {max-width:126px;font-size:.65rem;}
}

.layout-source { margin: 9px 0 0; color: var(--muted); font-size: .68rem; line-height: 1.5; overflow-wrap: anywhere; }
