* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
  html, body { width:100%; height:100%; overflow:hidden; background:#10141f;
    font-family:-apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; color:#e8ecf5;
    touch-action:none; overscroll-behavior:none; user-select:none; -webkit-user-select:none; }
  canvas { display:block; position:fixed; inset:0; }

  /* ---------- menu overlay ---------- */
  #menu { position:fixed; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:flex-start;
    overflow-y:auto; padding:max(18px, env(safe-area-inset-top)) 0 max(18px, env(safe-area-inset-bottom));
    background:radial-gradient(ellipse at 50% 30%, #1d2438 0%, #10141f 70%); z-index:20;
    touch-action:pan-y; overscroll-behavior:contain; -webkit-overflow-scrolling:touch; }
  .card { width:min(88vw, 360px); text-align:center; padding:28px 26px; border-radius:20px;
    background:rgba(255,255,255,.045); border:1px solid rgba(255,255,255,.09);
    backdrop-filter:blur(8px); margin:auto 0; }
  .logo { font-size:44px; }
  h1 { font-size:24px; margin:8px 0 2px; letter-spacing:1px; }
  .sub { font-size:13px; color:#8b94ab; margin-bottom:22px; }
  input { width:100%; padding:13px 16px; margin-bottom:12px; border-radius:12px; border:1px solid rgba(255,255,255,.14);
    background:rgba(0,0,0,.3); color:#fff; font-size:16px; outline:none; text-align:center; }
  input:focus { border-color:#00d1b2; }
  button.primary { width:100%; padding:14px; border:none; border-radius:12px; font-size:17px; font-weight:700;
    background:linear-gradient(135deg,#00d1b2,#00a5cf); color:#04202a; cursor:pointer; }
  button.primary, button.ghost, .modes button, #langSelect { min-height:44px; }
  button.primary:active { transform:scale(.97); }
  .modes { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; margin-bottom:12px; }
  .modes button { flex:1; padding:11px 4px; border-radius:12px; font-size:14px; cursor:pointer;
    border:1px solid rgba(255,255,255,.14); background:rgba(0,0,0,.3); color:#8b94ab; }
  .modes button.on { border-color:#00d1b2; color:#fff; background:rgba(0,209,178,.12); }
  .roomrow { display:flex; gap:8px; margin-bottom:12px; }
  .roomrow input { margin:0; flex:1; text-transform:uppercase; }
  #snapshotPanel { display:none; margin:-2px 0 12px; padding:10px 12px; border-radius:12px;
    border:1px solid rgba(255,180,0,.22); background:rgba(255,180,0,.08); text-align:left; }
  #snapshotSelect { width:100%; margin:0 0 8px; padding:9px 10px; border-radius:10px; border:1px solid rgba(255,255,255,.14);
    background:rgba(0,0,0,.3); color:#fff; outline:none; }
  #snapshotInfo { margin-bottom:8px; color:#aab3c8; font-size:12px; line-height:1.45; }
  .hint { font-size:12px; color:#66708a; margin-top:16px; line-height:1.7; }
  #err { color:#ff5a5f; font-size:13px; min-height:18px; margin-top:8px; }
  .authbox { margin-bottom:14px; padding:12px; border-radius:12px; background:rgba(0,0,0,.22);
    border:1px solid rgba(255,255,255,.08); }
  .authrow { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:10px;
    font-size:13px; color:#aab3c8; }
  .authrow b { color:#fff; }
  .authtabs { display:flex; gap:6px; margin-bottom:10px; }
  .authtabs button, button.ghost { border:1px solid rgba(255,255,255,.14); background:rgba(255,255,255,.04);
    color:#aab3c8; border-radius:10px; padding:8px 10px; cursor:pointer; }
  .authtabs button { flex:1; }
  .authtabs button.on { color:#fff; border-color:#00d1b2; background:rgba(0,209,178,.12); }
  button.ghost { font-size:12px; padding:7px 10px; }
  button.ghost.wide { width:100%; margin-top:10px; padding:11px; font-size:14px; }
  #authForm input { padding:10px 12px; margin-bottom:8px; font-size:14px; }
  #authForm .primary { padding:10px; font-size:14px; }
  #authErr { color:#ff5a5f; font-size:12px; min-height:16px; margin-top:6px; }
  #globalLb { margin-top:12px; padding-top:10px; border-top:1px solid rgba(255,255,255,.08);
    text-align:left; font-size:12px; color:#aab3c8; line-height:1.7; }
  #globalLb b { color:#e8ecf5; }
  #globalLb .row { display:flex; justify-content:space-between; gap:10px; }
  #globalLb .empty { color:#66708a; text-align:center; }
  #profilePanel { display:none; margin:-4px 0 12px; }
  #snapshotList { display:none; margin:-2px 0 12px; text-align:left; }
  .snapshotItem { padding:9px 0; border-top:1px solid rgba(255,255,255,.08); }
  .snapshotItem:first-child { border-top:none; }
  .snapshotTitle { display:flex; align-items:center; justify-content:space-between; gap:8px; color:#e8ecf5; font-size:13px; }
  .snapshotMeta { color:#8b94ab; font-size:12px; margin:4px 0 7px; }
  .snapshotRename { display:flex; gap:6px; }
  .snapshotRename input { flex:1; margin:0; padding:8px 10px; border-radius:10px; font-size:13px; text-align:left; }
  .snapshotRename button { padding:8px 10px; white-space:nowrap; }
  .swatches { display:grid; grid-template-columns:repeat(5, 1fr); gap:7px; margin-bottom:8px; }
  .swatches button { height:44px; border-radius:10px; border:2px solid rgba(255,255,255,.16);
    cursor:pointer; font-size:0; }
  .swatches button.on { border-color:#fff; box-shadow:0 0 0 2px rgba(0,209,178,.45); }
  .langrow { display:flex; align-items:center; justify-content:center; gap:8px; margin:-8px 0 14px;
    font-size:12px; color:#8b94ab; }
  #langSelect { width:auto; min-width:116px; margin:0; padding:7px 10px; border-radius:10px;
    font-size:12px; text-align:left; }
  .versionrow { display:flex; align-items:center; justify-content:center; gap:8px; margin:12px 0 -6px;
    color:#66708a; font-size:11px; }
  .versionrow button { border:0; background:none; color:#00d1b2; font-size:11px; cursor:pointer; padding:0; }

  /* ---------- HUD ---------- */
  #hud { position:fixed; inset:0; pointer-events:none; z-index:10; display:none; }
  #lb { position:absolute; top:calc(max(10px, env(safe-area-inset-top)) + 104px); right:10px; min-width:150px;
    background:rgba(10,14,25,.55); border:1px solid rgba(255,255,255,.08); border-radius:12px;
    padding:8px 12px; font-size:12px; line-height:1.85; backdrop-filter:blur(4px); }
  #lb .me { color:#00d1b2; font-weight:700; }
  #lb .row { display:flex; justify-content:space-between; gap:12px; white-space:nowrap; }
  #mystat { position:absolute; top:max(10px, env(safe-area-inset-top)); left:10px;
    background:rgba(10,14,25,.55); border:1px solid rgba(255,255,255,.08); border-radius:12px;
    padding:8px 14px; font-size:13px; backdrop-filter:blur(4px); }
  #mystat b { color:#ffb400; font-size:17px; }
  #fxStatus { margin-top:4px; max-width:260px; color:#aab3c8; font-size:11px; line-height:1.4; }
  #homeStatus { margin-top:4px; color:#ffdf7a; font-size:11px; line-height:1.4; display:none; }
  #roomtag { position:absolute; bottom:max(10px, env(safe-area-inset-bottom)); left:10px;
    font-size:11px; color:#66708a; }
  #wavetag { position:absolute; top:max(10px, env(safe-area-inset-top)); left:50%; transform:translateX(-50%);
    background:rgba(10,14,25,.55); border:1px solid rgba(255,180,0,.35); border-radius:12px;
    padding:6px 16px; font-size:14px; font-weight:700; color:#ffb400; display:none; backdrop-filter:blur(4px); }
  #banner { position:absolute; top:22%; left:50%; transform:translateX(-50%); max-width:90vw;
    font-size:clamp(18px, 5vw, 26px); font-weight:800; text-align:center; white-space:nowrap;
    text-shadow:0 2px 12px rgba(0,0,0,.8); opacity:0; transition:opacity .3s; pointer-events:none; }
  #banner.show { opacity:1; }
  #feed { position:absolute; top:calc(max(10px, env(safe-area-inset-top)) + 56px); left:10px;
    font-size:12px; color:#aab3c8; line-height:1.8; text-shadow:0 1px 2px #000; }

  /* boost button (touch only) */
  #boostBtn { position:absolute; right:max(18px, env(safe-area-inset-right)); bottom:max(18px, env(safe-area-inset-bottom));
    width:48px; height:48px; border-radius:50%; pointer-events:auto; display:none;
    background:radial-gradient(circle at 35% 30%, rgba(255,180,0,.85), rgba(255,90,95,.8));
    border:2px solid rgba(255,255,255,.35); font-size:17px; color:#fff;
    align-items:center; justify-content:center; box-shadow:0 4px 18px rgba(255,120,0,.35);
    touch-action:none; }
  #boostBtn.on { transform:scale(.9); filter:brightness(1.3); }
  body.touch #boostBtn { display:flex; }
  #paintBtn { position:absolute; right:calc(max(18px, env(safe-area-inset-right)) + 58px); bottom:max(18px, env(safe-area-inset-bottom));
    width:56px; height:56px; min-width:44px; min-height:44px; border:2px solid rgba(255,255,255,.65); border-radius:50%;
    background:rgba(0,209,178,.82); color:#fff; font-size:23px; z-index:20; display:none; pointer-events:auto;
    touch-action:none; user-select:none; -webkit-user-select:none; box-shadow:0 8px 24px rgba(0,0,0,.28); }

  /* modal overlays */
  #death { position:fixed; inset:0; display:none; align-items:center; justify-content:center;
    background:rgba(10,12,20,.72); z-index:40; backdrop-filter:blur(3px); }
  #homeExit { position:fixed; left:14px; top:58px; display:none; z-index:12; pointer-events:none; }
  #homeExit .card { width:min(220px, calc(100vw - 28px)); padding:8px; text-align:left; pointer-events:auto;
    border-radius:8px; background:rgba(16,20,31,.78); border:1px solid rgba(255,255,255,.12); box-shadow:none; }
  #homeExit .logo { display:none; }
  #homeExit .primary, #homeExit .ghost { padding:8px 10px; border-radius:8px; font-size:12px; text-align:center; }
  #death .card, #homeExit .card { animation:pop .25s ease; }
  @keyframes pop { from { transform:scale(.85); opacity:0; } }
  #deathMsg { font-size:15px; color:#aab3c8; margin:6px 0 4px; }
  #deathScore { font-size:38px; font-weight:800; color:#ffb400; margin-bottom:18px; }
  #replayIdBox { display:none; gap:6px; margin:8px 0 12px; }
  #replayIdInput { flex:1; margin:0; padding:9px 10px; border-radius:8px; font-size:12px; text-align:left;
    font-family:ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
  #copyReplayIdBtn { width:auto; padding:9px 10px; white-space:nowrap; }
  #homeExitMsg { display:block; color:#dbe3f5; font-size:12px; line-height:1.45; margin-bottom:8px; }
  #stayHomeBtn { margin-top:6px; }
  #changeLogCard { display:none; }
  #changeLogBody { text-align:left; margin:12px 0 14px; color:#aab3c8; font-size:13px; line-height:1.6; }
  #changeLogBody b { color:#e8ecf5; display:block; margin-bottom:6px; }
  #changeLogBody li { margin-left:18px; }

  #discBar { position:fixed; top:0; left:0; right:0; padding:8px; text-align:center; font-size:13px;
    background:#ff5a5f; color:#fff; z-index:30; display:none; }
