:root { --paper: #f4f1ea; --ink: #1b1a18; --sub: #5d5850; --mute: #8b857a; --line: rgba(27, 26, 24, 0.14); --accent: #b3462f; --panel: rgba(250, 248, 243, 0.92); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #c9d6df; color: var(--ink); font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif; -webkit-user-select: none; user-select: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }

#hud { position: fixed; left: 14px; top: calc(12px + env(safe-area-inset-top)); display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(8px); box-shadow: 0 6px 20px rgba(0,0,0,0.12); }
.hud-floor { width: 46px; height: 46px; border-radius: 10px; background: var(--ink); color: var(--paper); display: grid; place-items: center; font: 900 20px "Noto Serif TC", serif; }
.hud-txt { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.hud-txt b { font-size: 16px; white-space: nowrap; }
.hud-txt span { font-size: 12px; color: var(--sub); }
#hud-floor-btn { margin-left: 4px; font-size: 13px; font-weight: 700; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--ink); background: transparent; cursor: pointer; white-space: nowrap; }
#hud-floor-btn:hover { background: var(--ink); color: var(--paper); }
#menu-btn { position: fixed; right: 14px; top: calc(12px + env(safe-area-inset-top)); width: 46px; height: 46px; font-size: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }

#hint { position: fixed; left: 50%; top: 64%; transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 8px 16px; border-radius: 999px; background: rgba(27,26,24,0.84); color: #fff; font-size: 15px; pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#help { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom)); font-size: 12px; color: var(--sub); background: var(--panel); padding: 6px 14px; border-radius: 999px; white-space: nowrap; pointer-events: none; border: 1px solid var(--line); }

#joy { position: fixed; left: 22px; bottom: calc(28px + env(safe-area-inset-bottom)); width: 124px; height: 124px; border-radius: 50%; background: rgba(250,248,243,0.35); border: 1px solid rgba(27,26,24,0.25); touch-action: none; }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: rgba(27,26,24,0.55); border: 2px solid rgba(255,255,255,0.7); }
#act-btn { position: fixed; right: 22px; bottom: calc(40px + env(safe-area-inset-bottom)); width: 84px; height: 84px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.7); background: rgba(27,26,24,0.45); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; touch-action: none; -webkit-tap-highlight-color: transparent; }
#act-btn b { font: 900 22px "Noto Serif TC", serif; }
#act-btn span { font-size: 13px; }
#act-btn.on { background: var(--accent); border-color: #fff; }

/* join */
#join { position: fixed; inset: 0; display: flex; align-items: center; padding: 16px 6vw; background: linear-gradient(90deg, rgba(244,241,234,0.97) 0%, rgba(244,241,234,0.85) 38%, rgba(244,241,234,0) 66%); }
#join .card { width: min(440px, 100%); }
.eyebrow { font-size: 13px; letter-spacing: 0.12em; color: var(--accent); font-weight: 700; }
#join h1 { margin: 10px 0 8px; font: 900 64px/1.05 "Noto Serif TC", serif; letter-spacing: 0.04em; }
#join .sub { color: var(--sub); line-height: 1.7; margin: 0 0 6px; font-size: 16px; }
#join .count { color: var(--mute); font-size: 13px; margin: 0 0 18px; }
.lbl { font-size: 13px; color: var(--sub); margin-bottom: 8px; }
#j-avatars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }
#j-avatars button { font-size: 14px; padding: 11px 0; background: rgba(255,255,255,0.6); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
#j-avatars button.on { border-color: var(--ink); background: var(--ink); color: var(--paper); }
#j-go { width: 100%; font-size: 20px; font-weight: 900; padding: 15px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; cursor: pointer; letter-spacing: 0.1em; }
#j-go:disabled { opacity: 0.55; cursor: wait; }
#join .fine { font-size: 12px; color: var(--mute); margin-top: 14px; line-height: 1.6; }

/* detail panel */
#panel { position: fixed; inset: 0; z-index: 50; background: rgba(20,18,15,0.45); display: flex; justify-content: flex-end; }
#panel .sheet { position: relative; width: min(560px, 100%); height: 100%; background: var(--paper); box-shadow: -10px 0 40px rgba(0,0,0,0.25); animation: slide 0.25s ease-out; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
#panel-close, #elev-close { position: absolute; right: 14px; top: calc(12px + env(safe-area-inset-top)); width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 16px; z-index: 2; }
#panel-body { height: 100%; overflow-y: auto; padding: calc(28px + env(safe-area-inset-top)) 30px calc(40px + env(safe-area-inset-bottom)); -webkit-user-select: text; user-select: text; line-height: 1.75; }
.p-kicker { font-size: 13px; color: var(--accent); font-weight: 700; letter-spacing: 0.06em; padding-right: 48px; }
#panel h2 { font: 900 30px/1.3 "Noto Serif TC", serif; margin: 6px 48px 2px 0; text-wrap: balance; }
.p-en { color: var(--mute); font-size: 14px; font-style: italic; }
#panel figure { margin: 18px 0; }
#panel figure img { width: 100%; max-height: 52vh; object-fit: contain; background: #e7e2d8; border-radius: 6px; display: block; }
#panel figcaption { font-size: 12px; color: var(--mute); margin-top: 6px; }
#panel figure.noimg { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
#panel figure.noimg p { margin: 12px 0 10px; color: var(--sub); font-size: 14px; }
#panel figure.noimg small { display: block; color: var(--mute); font-size: 12px; margin-top: 10px; }
.pal { display: flex; height: 36px; border-radius: 6px; overflow: hidden; }
.pal i { flex: 1; }
#panel dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; margin: 0 0 14px; }
#panel dt { color: var(--mute); }
#panel dd { margin: 0; }
.p-desc { font-size: 16px; }
#panel h3 { font: 900 22px "Noto Serif TC", serif; margin: 24px 0 4px; border-top: 1px solid var(--line); padding-top: 18px; }
#panel h3 span { font: 400 13px "Noto Sans TC", sans-serif; color: var(--mute); margin-left: 6px; }
#panel p { margin: 0 0 12px; }
#panel a { color: var(--accent); }
.btn { display: inline-block; padding: 9px 14px; border-radius: 10px; background: var(--ink); color: #fff !important; text-decoration: none; font-weight: 700; font-size: 14px; }
.btn.ghost { background: transparent; color: var(--ink) !important; border: 1px solid var(--ink); }
#panel details { margin-top: 18px; font-size: 13px; color: var(--sub); }
#panel summary { cursor: pointer; font-weight: 700; color: var(--ink); }
#panel ul { padding-left: 18px; margin: 8px 0; font-size: 13px; }
#panel li { margin-bottom: 4px; word-break: break-word; }

/* elevator + menu */
#elev, #menu { position: fixed; inset: 0; z-index: 50; background: rgba(20,18,15,0.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
#elev .card, #menu .card { position: relative; width: min(460px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--paper); border-radius: 18px; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
#elev h2, #menu h2 { margin: 0 0 14px; font: 900 26px "Noto Serif TC", serif; }
#elev-list { display: grid; gap: 10px; }
#elev-list button { display: flex; align-items: center; gap: 16px; text-align: left; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
#elev-list button:hover { border-color: var(--ink); }
#elev-list button.cur { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
#elev-list b { font: 900 28px "Noto Serif TC", serif; width: 52px; }
#elev-list span { font-size: 13px; color: var(--sub); line-height: 1.5; }
#elev-list em { display: block; font-style: normal; font-weight: 700; font-size: 16px; color: var(--ink); }
#menu button { display: block; width: 100%; margin-top: 10px; font-size: 16px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
#menu button.primary { background: var(--ink); color: var(--paper); border: 0; font-weight: 900; }
#menu .sets { margin: 16px 0 6px; font-size: 15px; }
#menu .sets label { display: flex; align-items: center; gap: 8px; }
#menu .sets select { margin-left: auto; font: inherit; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
#menu details { margin-top: 10px; font-size: 14px; color: var(--sub); line-height: 1.7; }
#menu summary { cursor: pointer; color: var(--ink); font-weight: 700; }

#fade { position: fixed; inset: 0; background: var(--paper); opacity: 0; pointer-events: none; transition: opacity 0.3s; z-index: 60; }
#fade.on { opacity: 1; }
#toast { position: fixed; left: 50%; top: calc(80px + env(safe-area-inset-top)); transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 10px 18px; border-radius: 12px; background: var(--ink); color: var(--paper); font-weight: 700; opacity: 0; transition: opacity 0.3s; pointer-events: none; z-index: 70; text-align: center; }
#toast.show { opacity: 1; }

@media (max-width: 760px) {
  #join { align-items: flex-end; background: linear-gradient(0deg, rgba(244,241,234,0.98) 0%, rgba(244,241,234,0.9) 62%, rgba(244,241,234,0) 100%); padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); }
  #join h1 { font-size: 40px; }
  #join .sub { font-size: 14px; }
  #help { display: none; }
  #hud { left: 10px; right: 66px; gap: 8px; }
  .hud-floor { width: 40px; height: 40px; font-size: 18px; }
  .hud-txt b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
  #hud-floor-btn { margin-left: auto; padding: 7px 9px; font-size: 12px; }
  #menu-btn { right: 10px; }
  #panel-body { padding-left: 18px; padding-right: 18px; }
  #panel h2 { font-size: 24px; }
  #hint { top: auto; bottom: calc(170px + env(safe-area-inset-bottom)); font-size: 14px; }
}
