:root {
  --panel: rgba(18, 20, 24, 0.72);
  --panel-line: rgba(255, 255, 255, 0.12);
  --text: #f2efe9;
  --muted: #b9b4aa;
  --accent: #d9b36c;
  font-family: "PingFang TC", "Noto Sans TC", "Heiti TC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #111; color: var(--text); }
#view { display: block; width: 100vw; height: 100vh; }
button { font-family: inherit; }

.topbar {
  position: fixed; top: 16px; left: 16px; right: 16px;
  display: flex; justify-content: space-between; align-items: center; pointer-events: none;
}
.brand, .mode { pointer-events: auto; background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 12px; backdrop-filter: blur(8px); }
.brand { padding: 10px 16px; display: flex; gap: 12px; align-items: baseline; }
.brand .title { font-size: 18px; font-weight: 600; letter-spacing: 0.08em; }
.brand .sub { font-size: 13px; color: var(--muted); }
.top-right { display: flex; gap: 8px; align-items: center; }
.mode { display: flex; padding: 4px; gap: 4px; }
.mode button { border: 0; background: transparent; color: var(--muted); padding: 8px 14px; border-radius: 8px;
  font-size: 14px; cursor: pointer; }
.mode button.on { background: var(--accent); color: #1b1710; font-weight: 600; }

.rooms { position: fixed; left: 16px; top: 84px; width: 132px; background: var(--panel);
  border: 1px solid var(--panel-line); border-radius: 12px; padding: 10px; backdrop-filter: blur(8px); }
.rooms h2 { font-size: 12px; font-weight: 500; color: var(--muted); margin: 2px 4px 8px; letter-spacing: 0.1em; }
.rooms button { display: flex; width: 100%; justify-content: space-between; border: 0; background: transparent;
  color: var(--text); padding: 7px 8px; border-radius: 6px; font-size: 14px; cursor: pointer; }
.rooms button:hover { background: rgba(255, 255, 255, 0.08); }
.rooms button.on { background: rgba(217, 179, 108, 0.22); color: var(--accent); }
.rooms button kbd { color: var(--muted); font-size: 11px; }

.minimap { position: fixed; right: 16px; bottom: 16px; width: 320px; background: var(--panel);
  border: 1px solid var(--panel-line); border-radius: 12px; padding: 8px; backdrop-filter: blur(8px); }
.minimap img { display: block; width: 100%; border-radius: 6px; opacity: 0.92; }
.plan-wrap { position: relative; }
#me { position: absolute; width: 0; height: 0; }
#me .cone { position: absolute; left: -18px; top: -18px; width: 36px; height: 36px;
  background: conic-gradient(from -35deg, rgba(217, 179, 108, 0.55) 0 70deg, transparent 70deg);
  border-radius: 50%; }
#me::after { content: ""; position: absolute; left: -6px; top: -6px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px #1b1710; }

.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(8, 9, 11, 0.55); }
.overlay.hidden { display: none; }
.card { width: min(420px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 16px; padding: 24px 28px; backdrop-filter: blur(12px); }
.card h1 { margin: 0 0 8px; font-size: 22px; letter-spacing: 0.06em; }
.card p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.bar { height: 4px; background: rgba(255, 255, 255, 0.1); border-radius: 2px; overflow: hidden; margin-bottom: 16px; }
#load-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.keys { list-style: none; padding: 0; margin: 0 0 18px; font-size: 14px; line-height: 2; }
kbd { display: inline-block; min-width: 22px; padding: 0 6px; margin-right: 3px; text-align: center;
  border: 1px solid var(--panel-line); border-radius: 4px; background: rgba(255, 255, 255, 0.06);
  font-family: inherit; font-size: 12px; line-height: 20px; }
#enter { width: 100%; padding: 12px; border: 0; border-radius: 10px; background: var(--accent); color: #1b1710;
  font-size: 16px; font-weight: 600; cursor: pointer; }
#enter:disabled { opacity: 0.4; cursor: wait; }

#toast { position: fixed; left: 50%; top: 84px; transform: translateX(-50%); padding: 8px 16px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--panel-line); font-size: 14px; opacity: 0; transition: opacity 0.2s;
  pointer-events: none; backdrop-filter: blur(8px); }
#toast.show { opacity: 1; }

#fade { position: fixed; inset: 0; background: #0b0c0e; opacity: 0; pointer-events: none; transition: opacity 0.18s; }
#fade.on { opacity: 1; }

/* ---------------------------------------------------------------- touch (phones / tablets) */
.icon-btn, .sheet-head, #plan-labels, #sheet-backdrop, .keys.touch { display: none; }

body.touch { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent; }
body.touch #view { touch-action: none; }
body.touch button { touch-action: manipulation; }
body.touch .keys.desk { display: none; }
body.touch .keys.touch { display: block; }

body.touch .topbar { top: max(10px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right)); }
body.touch .brand { padding: 8px 12px; gap: 8px; }
body.touch .brand .title { font-size: 15px; }
body.touch .brand .sub { font-size: 12px; }
body.touch .brand .title, body.touch .brand .sub { white-space: nowrap; }
@media (max-width: 560px) { body.touch .brand .sub { display: none; } }
body.touch .mode button { padding: 0; width: 36px; height: 34px; font-size: 16px; }
body.touch .mode .lbl { display: none; }
body.touch .icon-btn { display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border-radius: 50%; border: 1px solid var(--panel-line); background: var(--panel); color: var(--text);
  backdrop-filter: blur(8px); pointer-events: auto; cursor: pointer; }
body.touch .icon-btn[aria-expanded="true"] { background: var(--accent); color: #1b1710; border-color: var(--accent); }

/* room list -> horizontal chips along the bottom */
body.touch .rooms { top: auto; left: 0; right: 0; width: auto; bottom: max(12px, env(safe-area-inset-bottom));
  padding: 0; background: none; border: 0; backdrop-filter: none; }
body.touch .rooms h2 { display: none; }
body.touch #room-list { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  scroll-padding: 0 12px; -webkit-overflow-scrolling: touch; }
body.touch #room-list::-webkit-scrollbar { display: none; }
body.touch .rooms button { flex: none; width: auto; padding: 9px 16px; border-radius: 999px; font-size: 14px;
  background: var(--panel); border: 1px solid var(--panel-line); backdrop-filter: blur(8px); }
body.touch .rooms button.on { background: var(--accent); color: #1b1710; border-color: var(--accent); font-weight: 600; }
body.touch .rooms button kbd { display: none; }

/* minimap -> bottom sheet */
body.touch #sheet-backdrop { display: block; position: fixed; inset: 0; background: rgba(8, 9, 11, 0.45);
  opacity: 0; pointer-events: none; transition: opacity 0.2s; }
body.touch .minimap { left: 0; right: 0; bottom: 0; width: auto; max-height: 88dvh;
  padding: 0 max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  border-radius: 18px 18px 0 0; border-bottom: 0; background: rgba(22, 24, 28, 0.94);
  transform: translateY(105%); visibility: hidden; transition: transform 0.25s ease, visibility 0s 0.25s; }
body.touch.sheet-open .minimap { transform: none; visibility: visible; transition: transform 0.25s ease; }
body.touch.sheet-open #sheet-backdrop { opacity: 1; pointer-events: auto; }
body.touch .sheet-head { display: flex; align-items: center; justify-content: space-between; position: relative;
  padding: 18px 0 10px; font-size: 14px; color: var(--muted); }
body.touch .sheet-head .handle { position: absolute; left: 50%; top: 7px; width: 36px; height: 4px; margin-left: -18px;
  border-radius: 2px; background: rgba(255, 255, 255, 0.25); }
#sheet-close { width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.08);
  color: var(--text); font-size: 14px; cursor: pointer; }
body.touch .plan-wrap { width: min(100%, calc((88dvh - 90px) * 1.6)); margin: 0 auto; touch-action: manipulation; }
body.touch #plan-labels { display: block; position: absolute; inset: 0; pointer-events: none; }
#plan-labels button { position: absolute; transform: translate(-50%, -50%); padding: 3px 8px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18); background: rgba(18, 20, 24, 0.82); color: var(--text);
  font-size: 12px; white-space: nowrap; cursor: pointer; pointer-events: auto; }
#plan-labels button.on { background: var(--accent); color: #1b1710; border-color: var(--accent); }
body.touch #me { z-index: 1; pointer-events: none; }

body.touch #toast { top: calc(max(10px, env(safe-area-inset-top)) + 58px); width: max-content; max-width: calc(100vw - 32px); text-align: center; }
