:root {
  --ink: #16110d;
  --panel: rgba(28, 21, 16, 0.82);
  --line: rgba(236, 220, 184, 0.22);
  --cream: #f1e4c6;
  --muted: #b9a684;
  --accent: #d9a35b;
  --font: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: var(--cream); font-family: var(--font); }
canvas#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* 进入页 */
#entry { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at 50% 30%, rgba(60, 40, 22, 0.55), rgba(10, 7, 5, 0.92)); z-index: 10; }
#entry .card { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px 20px; }
#entry h1 { margin: 0; font-size: 26px; letter-spacing: 0.2em; }
#entry .sub { margin: 6px 0 20px; color: var(--muted); font-size: 12px; letter-spacing: 0.15em; }
#entry label { font-size: 13px; color: var(--muted); }
#entry input { width: 100%; margin: 6px 0 14px; padding: 11px 12px; font: 16px var(--font); color: var(--cream);
  background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); border-radius: 8px; outline: none; }
#entry input:focus { border-color: var(--accent); }
.colors { display: flex; gap: 10px; margin-bottom: 18px; }
.colors button { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.colors button[aria-pressed="true"] { border-color: var(--cream); }
#enter { width: 100%; padding: 13px; font: 600 16px var(--font); color: var(--ink); background: var(--accent);
  border: 0; border-radius: 10px; cursor: pointer; }
#enter:disabled { opacity: 0.6; cursor: default; }
#entry .hint { margin: 14px 0 0; font-size: 12px; line-height: 1.6; color: var(--muted); }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; user-select: none; -webkit-user-select: none; }
#status { position: absolute; top: calc(12px + env(safe-area-inset-top)); left: 16px; display: flex; gap: 8px; align-items: center;
  padding: 6px 12px; font-size: 13px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; }
#online { color: var(--muted); }
#online::before { content: "·"; margin-right: 8px; }
#tools { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 12px; display: flex; gap: 8px; pointer-events: auto; }
#tools button { height: 38px; min-width: 52px; padding: 0 12px; border-radius: 19px; font: 600 13px var(--font); color: var(--cream);
  background: var(--panel); border: 1px solid var(--line); cursor: pointer; }
#chat { font-size: 18px !important; }
#chatpanel { position: absolute; right: 12px; top: calc(58px + env(safe-area-inset-top)); width: min(300px, calc(100% - 24px));
  max-height: 55vh; overflow-y: auto; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  pointer-events: auto; display: flex; flex-direction: column; gap: 6px; }
#chatpanel .emojis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 4px; }
#chatpanel .emojis button { font-size: 24px; padding: 6px 0; background: rgba(255,255,255,0.06); border: 0; border-radius: 10px; cursor: pointer; }
#chatpanel .phrase { text-align: left; padding: 9px 12px; font: 14px var(--font); color: var(--cream);
  background: rgba(255,255,255,0.06); border: 0; border-radius: 10px; cursor: pointer; }
#toast { position: absolute; left: 50%; top: calc(60px + env(safe-area-inset-top)); transform: translateX(-50%); padding: 8px 16px; font-size: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px; white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; }

/* Roblox 式：左下摇杆，右下跳跃 + 互动 */
#joy { position: absolute; width: 120px; height: 120px; border-radius: 50%; left: 28px; bottom: calc(28px + env(safe-area-inset-bottom));
  border: 2px solid rgba(241, 228, 198, 0.35); background: rgba(0, 0, 0, 0.18); opacity: 0.45; transition: opacity 0.15s; }
#joy.on { opacity: 1; }
#knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(241, 228, 198, 0.6); }
#jump { position: absolute; right: 24px; bottom: calc(32px + env(safe-area-inset-bottom)); width: 78px; height: 78px; border-radius: 50%;
  font: 700 17px var(--font); color: var(--ink); background: rgba(241, 228, 198, 0.85); border: 0; pointer-events: auto; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3); }
#jump:active { transform: scale(0.94); }
#act { position: absolute; right: 116px; bottom: calc(46px + env(safe-area-inset-bottom)); height: 50px; padding: 0 20px; border-radius: 25px;
  font: 700 16px var(--font); color: var(--ink); background: var(--accent); border: 0; pointer-events: auto; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3); white-space: nowrap; }
@media (hover: hover) and (pointer: fine) { #joy { display: none; } }

/* 标注模式 */
#ink { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 20; touch-action: none; cursor: crosshair; }
#inkbar { position: fixed; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 21; padding: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; gap: 8px; }
#inkbar .row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
#inkbar button { height: 36px; padding: 0 12px; border-radius: 18px; font: 600 13px var(--font); color: var(--cream);
  background: rgba(255,255,255,0.08); border: 1px solid var(--line); cursor: pointer; }
#inkbar .pen { width: 32px; padding: 0; border: 2px solid transparent; }
#inkbar .pen[aria-pressed="true"] { border-color: #fff; }
#inkbar input { flex: 1; min-width: 0; height: 36px; padding: 0 10px; font: 15px var(--font); color: var(--cream);
  background: rgba(0,0,0,0.35); border: 1px solid var(--line); border-radius: 10px; outline: none; }
#inkbar .send { background: var(--accent); color: var(--ink); border: 0; }
#inkbar .legend { margin: 0; font-size: 11px; color: var(--muted); }
