    * { margin: 0; padding: 0; box-sizing: border-box; }
    body { background: linear-gradient(180deg, #0055aa 0%, #003d7a 40%, #001f4d 100%); overflow: hidden; font-family: Arial, sans-serif; }
    canvas { display: block; }
    #ui { position: fixed; inset: 0; pointer-events: none; }

    /* ── START BACKDROP ── */
    #start-backdrop {
      position: absolute; inset: 0;
      background: linear-gradient(180deg, #0077cc 0%, #0055aa 40%, #002f7a 100%);
      pointer-events: none;
    }

    /* ── START SCREEN ── */
    #start-screen {
      position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
      background: linear-gradient(160deg, #003d7a 0%, #00245c 50%, #001535 100%);
      border: 3px solid #44aaff; border-radius: 22px;
      padding: 36px 48px; color: white; text-align: center; min-width: 500px;
      max-height: 92vh; overflow-y: auto;
      pointer-events: all;
      box-shadow: 0 0 80px rgba(0,120,255,0.35), 0 0 20px rgba(0,80,200,0.5), inset 0 1px 0 rgba(100,180,255,0.15);
    }
    #start-screen h1 {
      color: #ffffff; font-size: 46px; margin-bottom: 4px;
      text-shadow: 0 0 30px rgba(0,200,255,0.8), 0 2px 8px rgba(0,0,0,0.6);
    }
    #start-screen .sub {
      color: #88ddff; font-size: 15px; margin-bottom: 22px; letter-spacing: 0.5px;
    }
    #start-screen .ctrl {
      font-size: 13px; color: #aaccee; line-height: 2.2; margin-bottom: 22px;
      text-align: left; background: rgba(0,30,80,0.5); border-radius: 12px;
      padding: 14px 18px; border: 1px solid rgba(68,170,255,0.2);
    }
    #start-screen .ctrl b { color: #66ddff; }
    #start-screen button {
      background: linear-gradient(135deg, #0088ee, #0055bb);
      color: #ffffff; border: 2px solid #44aaff;
      padding: 14px 44px; font-size: 22px; font-weight: bold;
      border-radius: 12px; cursor: pointer;
      box-shadow: 0 4px 20px rgba(0,120,255,0.5);
      letter-spacing: 1px; transition: all 0.15s;
    }
    #start-screen button:hover {
      background: linear-gradient(135deg, #22aaff, #0077dd);
      box-shadow: 0 6px 30px rgba(0,160,255,0.7);
      transform: translateY(-2px);
    }
    /* ── GAMEMODE OVERLAY ── */
    #mode-overlay {
      display: none; position: absolute; inset: 0;
      background: linear-gradient(160deg, #001030 0%, #000820 100%);
      align-items: center; justify-content: center;
      pointer-events: all; flex-direction: column; gap: 28px;
    }
    #mode-overlay h2 { font-size: 28px; color: #fff; margin: 0; text-shadow: 0 0 20px rgba(100,200,255,0.6); }
    #mode-overlay p  { font-size: 13px; color: #6699bb; margin: -16px 0 0; letter-spacing: 1px; }
    #mode-cards { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
    .mode-card {
      width: 150px; background: rgba(255,255,255,0.04);
      border: 2px solid rgba(255,255,255,0.12); border-radius: 18px;
      padding: 22px 16px; text-align: center; cursor: pointer;
      transition: all 0.18s; user-select: none;
    }
    .mode-card:hover { transform: translateY(-4px); background: rgba(255,255,255,0.09); }
    .mode-card.selected { border-width: 3px; box-shadow: 0 0 30px var(--mc); background: rgba(255,255,255,0.08); }
    .mode-card-icon  { font-size: 44px; margin-bottom: 10px; }
    .mode-card-name  { font-size: 18px; font-weight: bold; color: #fff; margin-bottom: 8px; }
    .mode-card-desc  { font-size: 11px; color: #99aabb; line-height: 1.6; }
    #mode-back-btn {
      padding: 10px 30px; border-radius: 10px; background: rgba(255,255,255,0.06);
      border: 2px solid rgba(255,255,255,0.15); color: #aabbcc; font-size: 14px;
      cursor: pointer; font-family: inherit;
    }
    #mode-back-btn:hover { background: rgba(255,255,255,0.12); }
    #mode-start-btn {
      padding: 14px 44px; border-radius: 12px; font-size: 20px; font-weight: bold;
      cursor: pointer; font-family: inherit; letter-spacing: 1px;
      border: 2px solid; transition: all 0.15s;
    }
    #mode-start-btn:hover { transform: translateY(-2px); }

    /* ── BACK BUTTON (top-right, always visible) ── */
    #mob-back {
      position: absolute; top: 14px; right: 14px; z-index: 9999;
      width: 44px; height: 44px; border-radius: 50%;
      background: rgba(0,10,30,0.72); border: 2px solid rgba(100,160,255,0.45);
      color: #88ccff; font-size: 22px; font-weight: bold;
      cursor: pointer; pointer-events: all; line-height: 1;
      display: flex; align-items: center; justify-content: center;
      transition: background 0.15s, border-color 0.15s;
      box-shadow: 0 2px 10px rgba(0,0,0,0.4);
    }
    #mob-back:hover { background: rgba(0,40,100,0.85); border-color: #44aaff; color: #fff; }

    /* ── MOBILE CHAT BUTTON (always visible on touch, not tied to mobile controls) ── */
    #mob-chat {
      position: absolute; top: 14px; right: 68px; z-index: 9999;
      width: 44px; height: 44px; border-radius: 50%;
      background: rgba(0,10,30,0.72); border: 2px solid rgba(255,200,0,0.55);
      font-size: 22px; cursor: pointer; pointer-events: all;
      display: none; align-items: center; justify-content: center;
      transition: background 0.15s, border-color 0.15s;
      box-shadow: 0 2px 10px rgba(0,0,0,0.4);
      touch-action: manipulation;
    }
    @media (pointer: coarse) { #mob-chat { display: flex; } }
    #mob-chat:active { background: rgba(60,40,0,0.9); border-color: gold; }

    /* ── SAVE FILE SLOTS ── */
    #continue-btn {
      width:100%; padding:13px 18px; margin:14px 0 8px;
      background: linear-gradient(135deg, #0088ee, #0055bb);
      border: 2px solid #44aaff; border-radius:12px;
      color:#fff; font-size:18px; font-weight:bold;
      cursor:pointer; font-family:inherit; letter-spacing:1px;
      transition:all 0.15s; box-shadow: 0 4px 20px rgba(0,120,255,0.4);
    }
    #continue-btn:hover { background:linear-gradient(135deg,#22aaff,#0077dd); transform:translateY(-2px); box-shadow:0 6px 28px rgba(0,160,255,0.55); }
    #save-toggle-btn {
      width:100%; padding:11px 18px; margin:14px 0 0;
      background:rgba(0,30,80,0.55); border:2px solid rgba(68,170,255,0.3);
      border-radius:12px; color:#88ccff; font-size:15px; font-weight:bold;
      cursor:pointer; font-family:inherit; letter-spacing:0.5px;
      transition:all 0.15s; text-align:left;
    }
    #save-toggle-btn:hover { background:rgba(0,55,130,0.65); border-color:rgba(68,170,255,0.6); color:#fff; }

    /* ── Settings button ── */
    #settings-toggle-btn {
      width:100%; padding:11px 18px; margin:8px 0 0;
      background:rgba(20,20,40,0.55); border:2px solid rgba(160,160,255,0.25);
      border-radius:12px; color:#aaaadd; font-size:15px; font-weight:bold;
      cursor:pointer; font-family:inherit; letter-spacing:0.5px;
      transition:all 0.15s; text-align:left;
    }
    #settings-toggle-btn:hover { background:rgba(40,40,90,0.7); border-color:rgba(160,160,255,0.55); color:#fff; }

    /* ── Settings panel ── */
    #settings-panel {
      margin-top:10px; padding:14px 16px;
      background:rgba(10,10,30,0.7); border:1.5px solid rgba(150,150,255,0.2);
      border-radius:14px;
    }
    .settings-section-title {
      font-size:11px; font-weight:bold; color:#7788bb;
      letter-spacing:2px; text-transform:uppercase; margin-bottom:10px;
    }
    .sfx-row {
      display:flex; align-items:center; gap:12px;
      background:rgba(255,255,255,0.05); border-radius:10px;
      padding:10px 14px; margin-bottom:4px;
    }
    #sfx-vol-label { font-size:13px; color:#aaccee; min-width:72px; font-weight:bold; }
    .settings-theme-cards { display:flex; gap:10px; }
    .stc {
      flex:1; padding:12px 10px; border-radius:12px; cursor:pointer;
      border:2px solid rgba(255,255,255,0.1); background:rgba(255,255,255,0.05);
      text-align:center; transition:all 0.18s;
    }
    .stc:hover { background:rgba(255,255,255,0.10); border-color:rgba(255,255,255,0.25); }
    .stc-active {
      border-color:#44aaff; background:rgba(0,120,255,0.18);
      box-shadow:0 0 12px rgba(0,150,255,0.25);
    }
    .stc-icon { font-size:26px; margin-bottom:5px; }
    .stc-name { font-size:13px; font-weight:bold; color:#ddeeff; margin-bottom:3px; }
    .stc-desc { font-size:10px; color:#668899; line-height:1.4; }
    #save-slots { display:flex; flex-direction:column; gap:10px; margin:10px 0 4px; }
    .save-slot {
      background:rgba(0,30,80,0.55); border:2px solid rgba(68,170,255,0.25);
      border-radius:14px; padding:13px 16px; cursor:pointer;
      transition:all 0.15s; text-align:left; position:relative;
    }
    .save-slot:hover { background:rgba(0,55,130,0.65); border-color:rgba(68,170,255,0.55); transform:translateY(-1px); }
    .save-slot-empty { text-align:center; border-style:dashed; border-color:rgba(68,170,255,0.18); padding:18px 16px; }
    .save-slot-empty:hover { border-color:rgba(68,170,255,0.45); }
    .ss-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:5px; }
    .ss-num { font-size:13px; color:#66aadd; font-weight:bold; letter-spacing:0.5px; }
    #start-screen .ss-delete { background:rgba(255,60,60,0.14); border:1px solid rgba(255,80,80,0.3); color:#ff8888; border-radius:7px; padding:3px 9px; font-size:12px; cursor:pointer; font-family:inherit; box-shadow:none; letter-spacing:0; transform:none; }
    #start-screen .ss-delete:hover { background:rgba(255,60,60,0.32); transform:none; box-shadow:none; }
    .ss-diff { font-size:12px; color:#88aacc; margin-bottom:2px; }
    .ss-level { font-size:15px; font-weight:bold; color:#eef6ff; }
    .ss-stats { font-size:12px; color:#7799bb; margin-top:3px; }
    .ss-time { font-size:11px; color:#445566; margin-top:3px; }
    .ss-empty-icon { font-size:28px; margin:4px 0 6px; }
    .ss-empty-label { font-size:14px; color:#446688; margin-bottom:10px; }
    #start-screen .ss-btn { display:inline-block; padding:8px 22px; border-radius:8px; font-size:14px; font-weight:bold; cursor:pointer; font-family:inherit; letter-spacing:0.5px; border:2px solid transparent; margin-top:8px; transition:all 0.12s; box-shadow:none; }
    #start-screen .ss-btn-continue { background:linear-gradient(135deg,#0088ee,#0055bb); color:#fff; border-color:#44aaff; }
    #start-screen .ss-btn-continue:hover { background:linear-gradient(135deg,#22aaff,#0077dd); transform:translateY(-1px); }
    #start-screen .ss-btn-new { background:rgba(68,170,255,0.1); color:#66aadd; border-color:rgba(68,170,255,0.3); }
    #start-screen .ss-btn-new:hover { background:rgba(68,170,255,0.22); border-color:#44aaff; transform:translateY(-1px); }

    /* HUD mode badge */
    #mode-badge-hud {
      display: none; position: absolute; top: 8px; right: 16px;
      padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: bold;
      border: 2px solid; pointer-events: none; letter-spacing: 1px;
    }
    /* Gamemode button on start screen */
    #gamemodeBtn {
      background: linear-gradient(135deg, #1a3a6a, #0d2248);
      color: #88ccff; border: 2px solid rgba(68,170,255,0.5);
      padding: 10px 28px; font-size: 15px; font-weight: bold;
      border-radius: 10px; cursor: pointer; margin-bottom: 14px;
      letter-spacing: 0.5px; transition: all 0.15s; display: block; width: 100%;
    }
    #gamemodeBtn:hover { background: linear-gradient(135deg, #224488, #112255); border-color: #44aaff; }
    #gamemode-preview {
      font-size: 13px; color: #66aadd; margin-bottom: 14px; text-align: center;
    }

    /* Mobile toggle row */
    #mobile-toggle-row {
      display: flex; align-items: center; justify-content: space-between;
      background: rgba(0,30,80,0.5); border: 1px solid rgba(68,170,255,0.2);
      border-radius: 12px; padding: 12px 18px; margin-bottom: 22px;
      cursor: pointer; user-select: none;
    }
    #mobile-toggle-row:hover { background: rgba(0,50,110,0.6); }
    #mobile-toggle-label { font-size: 14px; color: #aaccee; }
    #mobile-toggle-label span { color: #66ddff; font-weight: bold; }
    /* The pill switch — shared by both toggles */
    #mobile-pill, .mobile-pill-btn {
      width: 50px; height: 26px; border-radius: 13px; position: relative;
      background: #334; border: 2px solid rgba(68,170,255,0.3);
      transition: background 0.2s; flex-shrink: 0;
    }
    #mobile-pill::after, .mobile-pill-btn::after {
      content: ''; position: absolute; top: 3px; left: 3px;
      width: 16px; height: 16px; border-radius: 50%;
      background: #557; transition: transform 0.2s, background 0.2s;
    }
    #mobile-pill.on, .mobile-pill-btn.on { background: #0077ee; border-color: #44aaff; }
    #mobile-pill.on::after, .mobile-pill-btn.on::after { transform: translateX(24px); background: white; }

    /* ── BANK PROXIMITY HINT ── */
    #bank-hint {
      display: none; position: absolute; bottom: 120px; left: 50%;
      transform: translateX(-50%);
      background: rgba(0,5,20,0.82); border: 2px solid #ffd700;
      border-radius: 12px; padding: 10px 22px; color: #ffd700;
      font-size: 15px; font-weight: bold; letter-spacing: 1px;
      pointer-events: all; cursor: pointer; text-align: center;
      box-shadow: 0 0 20px rgba(255,210,0,0.2);
      animation: hintpulse 1.5s ease-in-out infinite;
    }
    @keyframes hintpulse {
      0%,100% { box-shadow: 0 0 20px rgba(255,210,0,0.2); }
      50%      { box-shadow: 0 0 35px rgba(255,210,0,0.5); }
    }

    /* ── CROSSHAIR ── */
    #crosshair {
      display: none; position: absolute; top: 50%; left: 50%;
      transform: translate(-50%,-50%); color: rgba(255,255,255,0.8); font-size: 22px;
      text-shadow: 0 0 6px #000;
    }

    /* ── TOP LEFT: score + kills ── */
    #top-left {
      display: none; position: absolute; top: 14px; left: 14px;
      flex-direction: column; gap: 7px;
    }
    .hbox {
      background: rgba(0,8,24,0.75); border: 2px solid rgba(0,200,255,0.35);
      border-radius: 10px; padding: 6px 14px; color: white; font-size: 14px;
    }
    #score-box { color: #00ffcc; font-weight: bold; font-size: 16px; }
    #kill-box  { color: #ffdd44; }
    #hp-box    { border-color: rgba(255,80,80,0.4); }

    /* ── QUEST HUD ── */
    #quest-hud {
      background: rgba(0,8,24,0.82); border: 2px solid rgba(68,170,255,0.3);
      border-radius: 10px; padding: 8px 13px; color: white; font-size: 13px;
      min-width: 200px; transition: border-color 0.3s, box-shadow 0.3s;
    }
    .qh-label { font-size: 12px; color: #88ccff; margin-bottom: 3px; }
    .qh-done  { color: #ffe066; font-weight: bold; font-size: 11px; margin-left: 4px; animation: hcPulse 1s infinite; }
    .qh-task  { font-size: 13px; font-weight: bold; color: #ffffff; margin-bottom: 5px; }
    .qh-bar-wrap {
      background: rgba(255,255,255,0.1); border-radius: 4px; height: 6px;
      margin-bottom: 4px; overflow: hidden;
    }
    .qh-bar {
      height: 100%; border-radius: 4px;
      background: linear-gradient(90deg, #44aaff, #00ffcc);
      transition: width 0.4s ease;
    }
    .qh-nums { font-size: 11px; color: #aaccee; }

    /* ── Daily quests ───────────────────────────────────── */
    #daily-wrap { margin-top: 4px; }
    #daily-btn {
      width: 100%; text-align: left; cursor: pointer;
      background: rgba(10,15,35,0.82); border: 2px solid rgba(255,180,0,0.45);
      border-radius: 10px; padding: 7px 13px; color: #ffe066;
      font-size: 12px; font-family: inherit; transition: background 0.3s, border-color 0.3s;
    }
    #daily-btn:hover { background: rgba(30,25,0,0.88); }
    #daily-panel {
      background: rgba(0,8,24,0.9); border: 2px solid rgba(255,180,0,0.3);
      border-top: none; border-radius: 0 0 10px 10px;
      padding: 8px; display: flex; flex-direction: column; gap: 6px;
    }
    .dq-card {
      background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
      border-radius: 8px; padding: 8px 10px;
    }
    .dq-card.dq-ready  { border-color: #ffe066; box-shadow: 0 0 8px rgba(255,220,0,0.3); animation: hcPulse 1.5s infinite; }
    .dq-card.dq-done   { opacity: 0.55; }
    .dq-name  { font-size: 12px; font-weight: bold; color: #fff; margin-bottom: 5px; }
    .dq-barbg {
      background: rgba(255,255,255,0.1); border-radius: 4px; height: 5px;
      margin-bottom: 5px; overflow: hidden;
    }
    .dq-barfill {
      height: 100%; border-radius: 4px;
      background: linear-gradient(90deg, #ffaa00, #ffe066);
      transition: width 0.4s ease;
    }
    .dq-foot   { display: flex; justify-content: space-between; align-items: center; }
    .dq-prog   { font-size: 11px; color: #aaccee; }
    .dq-rwrd   { font-size: 11px; color: #ffe066; }
    .dq-rwrd-got { color: #44ff88; }
    .dq-collect {
      background: linear-gradient(135deg,#ffe066,#ffaa00); border: none;
      border-radius: 6px; padding: 3px 9px; font-size: 11px; font-weight: bold;
      color: #1a0800; cursor: pointer; transition: transform 0.1s;
    }
    .dq-collect:hover { transform: scale(1.06); }
    #level-box {
      border-color: rgba(255,200,0,0.5);
      background: rgba(20,10,0,0.82);
      display: flex; align-items: center; gap: 8px;
    }
    #level-badge {
      font-size: 18px; font-weight: bold;
      background: linear-gradient(135deg, #ffcc00, #ff8800);
      -webkit-background-clip: text; -webkit-text-fill-color: transparent;
      background-clip: text;
    }
    #level-name { color: #ffeeaa; font-size: 12px; }
    #level-xp-bar-wrap { flex: 1; min-width: 80px; }
    #level-xp-bar { width: 100%; height: 6px; background: #222; border-radius: 3px; overflow: hidden; margin-top: 3px; }
    #level-xp-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg,#ffcc00,#ff8800); transition: width .3s; }
    .bar { width: 80px; height: 10px; background: #222; border-radius: 5px; overflow: hidden; margin-top: 4px; transition: width 0.4s ease; }
    .bar-fill { height: 100%; border-radius: 5px; transition: width .2s; }
    #php-fill { background: linear-gradient(90deg,#ff4444,#ff8888); }

    /* ── TOP CENTER: boss bars (stack up to 4) ── */
    #boss-bars-container {
      display: none; position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
      flex-direction: column; gap: 5px; align-items: center;
    }
    .boss-bar-item {
      background: rgba(0,8,24,0.88); border: 2px solid #ff3333; border-radius: 10px;
      padding: 7px 18px; color: #ff6666; font-size: 13px; text-align: center; min-width: 230px;
    }
    .boss-bar-track { width: 200px; height: 13px; background: #333; border-radius: 7px; overflow: hidden; margin-top: 5px; }
    .boss-bar-fill  { height: 100%; background: linear-gradient(90deg,#ff2222,#ff8800); border-radius: 7px; transition: width .15s; }

    /* ── BOTTOM CENTER: weapons ── */
    #weapons {
      display: none; position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
      flex-direction: column; align-items: center; gap: 6px;
      pointer-events: none; /* individual slots set their own pointer-events */
    }
    .wslot { cursor: pointer; touch-action: manipulation; }
    #weapon-hint { font-size: 11px; color: rgba(255,255,255,0.45); }
    #wslots { display: flex; gap: 8px; }
    .wslot {
      background: rgba(0,8,24,0.75); border: 2px solid rgba(255,255,255,0.18);
      border-radius: 8px; padding: 7px 14px; color: #666; font-size: 13px; text-align: center;
      min-width: 80px;
      position: relative; overflow: hidden;  /* needed for the CD sweep */
      --cd: 0;  /* 0 = ready, 1 = just attacked — set by JS */
    }
    .wslot.unlocked  { color: #aaa; border-color: rgba(255,255,255,0.3); }
    .wslot.active    { color: white; border-color: white; background: rgba(255,255,255,0.12); }
    .wslot.cooldown  { color: #444; }
    /* Clock-sweep cooldown overlay on the active slot */
    .wslot.active::after {
      content: '';
      position: absolute;
      inset: 0;
      border-radius: inherit;
      pointer-events: none;
      background: conic-gradient(
        from -90deg,
        rgba(0, 0, 0, 0.58) calc(var(--cd) * 360deg),
        transparent calc(var(--cd) * 360deg)
      );
    }

    /* ── SPEECH BUBBLE ── */
    #speech-bubble {
      display: none; position: absolute; pointer-events: none;
      background: rgba(255,255,255,0.94); border: 2px solid #333;
      border-radius: 14px; padding: 10px 16px; max-width: 260px;
      font-size: 14px; color: #222; line-height: 1.5;
      box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    }
    #speech-bubble::after {
      content: ''; position: absolute; bottom: -12px; left: 50%; transform: translateX(-50%);
      border: 6px solid transparent; border-top-color: #333;
    }
    #fish-name { font-weight: bold; color: #e06000; font-size: 12px; margin-bottom: 3px; }

    /* ── OVERLAY / RESPAWN ── */
    #overlay {
      display: none; position: absolute; top: 50%; left: 50%;
      transform: translate(-50%,-50%);
      background: rgba(0,8,24,0.88); border: 3px solid white;
      border-radius: 14px; padding: 20px 40px; color: white;
      font-size: 22px; text-align: center; line-height: 1.6;
    }
    #respawn-msg {
      display: none; position: absolute; top: 56%; left: 50%;
      transform: translate(-50%,-50%); color: white; font-size: 26px;
      text-align: center; text-shadow: 0 0 12px #000;
    }

    /* ── EVENT TICKER (top right) ── */
    #event-ticker {
      display: none; position: absolute; top: 14px; right: 14px;
      background: rgba(0,8,24,0.8); border: 2px solid gold;
      border-radius: 10px; padding: 7px 14px; color: gold; font-size: 13px;
      text-align: right; max-width: 200px;
    }

    /* ── HOUSE UI ── */
    #house-ui {
      display: none; position: absolute; inset: 0;
      background: rgba(0,8,24,0.88);
      align-items: center; justify-content: center;
      pointer-events: all;
    }
    #house-panel {
      background: linear-gradient(160deg, #0a2040 0%, #061428 100%);
      border: 2px solid #3399cc;
      border-radius: 20px; padding: 36px 48px;
      color: white; text-align: center;
      min-width: 380px; max-width: 440px;
      box-shadow: 0 0 40px rgba(0,150,255,0.15);
    }
    #house-icon { font-size: 52px; margin-bottom: 8px; line-height: 1; }
    #house-name { color: #88ddff; font-size: 26px; font-weight: bold; margin-bottom: 6px; }
    #house-subtitle { color: #44dd88; font-size: 13px; margin-bottom: 22px; letter-spacing: 1px; }
    .house-divider { border: none; border-top: 1px solid rgba(68,170,220,0.25); margin: 18px 0; }
    .house-row {
      display: flex; align-items: center; gap: 10px;
      background: rgba(0,80,140,0.25); border-radius: 10px;
      padding: 10px 14px; margin-bottom: 10px; text-align: left;
    }
    .house-row-icon { font-size: 20px; flex-shrink: 0; }
    .house-row-text { font-size: 13px; color: #aaccee; line-height: 1.5; }
    .house-row-text b { color: #ddeeff; }
    #house-exit-btn {
      width: 100%; margin-top: 20px;
      background: #2277aa; color: #e8f8ff; border: 2px solid #44aadd;
      padding: 12px 0; font-size: 16px; font-weight: bold;
      border-radius: 10px; cursor: pointer; letter-spacing: 0.5px;
      transition: background 0.15s;
    }
    #house-exit-btn:hover { background: #3399cc; }

    /* ── SPAWN SHIELD INDICATOR ── */
    #spawn-shield {
      display: none; position: absolute; top: 50%; left: 50%;
      transform: translate(-50%, -50%);
      pointer-events: none; z-index: 60; text-align: center;
    }
    #spawn-shield-icon {
      font-size: 64px; line-height: 1;
      filter: drop-shadow(0 0 18px gold);
      animation: shield-pulse 0.6s ease-in-out infinite alternate;
    }
    #spawn-shield-time {
      font-size: 22px; font-weight: bold; color: #ffdd44;
      text-shadow: 0 0 12px gold;
      margin-top: 4px;
    }
    @keyframes shield-pulse {
      from { transform: scale(0.9); opacity: 0.7; }
      to   { transform: scale(1.1); opacity: 1.0; }
    }

    /* ── GRASS COMPANION PANEL ── */
    #grass-panel {
      display: none;
      position: absolute; bottom: 16px; left: 16px;
      background: rgba(0,15,5,0.88); border: 2px solid #33aa44;
      border-radius: 14px; padding: 10px 14px; min-width: 170px;
      pointer-events: none; z-index: 50;
      box-shadow: 0 0 20px rgba(50,200,80,0.25);
    }
    #grass-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
    #grass-avatar { font-size: 22px; line-height: 1; }
    #grass-name   { font-size: 15px; font-weight: bold; color: #66ee66; }
    #grass-level  { font-size: 11px; color: #aaffaa; margin-left: auto; background: rgba(0,80,0,0.6); padding: 2px 6px; border-radius: 8px; }
    .grass-bar-wrap { margin: 4px 0; }
    .grass-bar-label { font-size: 10px; color: #88cc88; margin-bottom: 2px; display: flex; justify-content: space-between; }
    .grass-bar-bg { background: rgba(0,40,0,0.7); border-radius: 4px; height: 7px; overflow: hidden; }
    .grass-bar-fill { height: 100%; border-radius: 4px; transition: width 0.25s, background 0.25s; }
    #grass-hp-fill  { background: #44ff66; }
    #grass-xp-fill  { background: #88ffcc; }
    #grass-footer { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11px; color: #77bb77; }
    #grass-status { font-size: 10px; color: #88ff88; margin-top: 4px; }

    /* ── CHOMP COMPANION PANEL ── */
    #chomp-panel {
      display: none;
      position: absolute; bottom: 16px; left: 200px;
      background: rgba(18, 8, 2, 0.88); border: 2px solid #aa5511;
      border-radius: 14px; padding: 10px 14px; min-width: 170px;
      pointer-events: none; z-index: 50;
      box-shadow: 0 0 20px rgba(180, 100, 30, 0.3);
    }
    #chomp-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
    #chomp-avatar { font-size: 22px; line-height: 1; }
    #chomp-name   { font-size: 15px; font-weight: bold; color: #dd8833; }
    #chomp-level  { font-size: 11px; color: #eebb88; margin-left: auto; background: rgba(80,30,0,0.6); padding: 2px 6px; border-radius: 8px; }
    .chomp-bar-wrap  { margin: 4px 0; }
    .chomp-bar-label { font-size: 10px; color: #aa7744; margin-bottom: 2px; display: flex; justify-content: space-between; }
    .chomp-timer-bg  { background: rgba(40,15,0,0.7); border-radius: 4px; height: 7px; overflow: hidden; }
    .chomp-timer-fill { height: 100%; border-radius: 4px; background: #44ff88; transition: width 0.3s; }
    #chomp-status { font-size: 10px; color: #aaffaa; margin-top: 4px; }

    /* ── CONFUSION PULSE HUD ── */
    #confusion-hud {
      display: none;
      position: absolute; bottom: 158px; left: 16px;
      background: rgba(40, 0, 60, 0.82);
      border: 1px solid #9900cc;
      border-radius: 10px; padding: 8px 12px; min-width: 148px;
      backdrop-filter: blur(6px);
      box-shadow: 0 0 20px rgba(180, 0, 255, 0.35);
    }
    #confusion-header  { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
    #confusion-key     { font-size: 14px; font-weight: bold; color: #fff; background: rgba(120,0,180,0.8); border-radius: 5px; padding: 1px 7px; border: 1px solid #cc44ff; transition: opacity 0.3s; }
    #confusion-name    { font-size: 13px; font-weight: bold; color: #dd66ff; }
    .confusion-bar-wrap  { margin: 4px 0; }
    .confusion-bar-label { font-size: 10px; color: #aa66cc; margin-bottom: 2px; display: flex; justify-content: space-between; }
    .confusion-cd-bg   { background: rgba(40,0,60,0.8); border-radius: 4px; height: 7px; overflow: hidden; }
    .confusion-cd-fill { height: 100%; border-radius: 4px; background: #cc44ff; transition: width 0.3s; }
    #confusion-status  { font-size: 10px; color: #cc88ff; margin-top: 4px; }

    /* ── ARENA SELECTOR UI ── */
    #arena-ui {
      display: none; position: absolute; inset: 0;
      background: rgba(0,2,15,0.88);
      align-items: center; justify-content: center; pointer-events: all;
    }
    #arena-panel {
      background: linear-gradient(160deg, #080018 0%, #020010 100%);
      border: 2px solid #ff6600; border-radius: 20px;
      padding: 28px 32px; width: min(480px, 94vw);
      display: flex; flex-direction: column;
      max-height: 88vh; box-sizing: border-box;
      box-shadow: 0 0 60px rgba(255,100,0,0.25);
    }
    #arena-header { text-align: center; margin-bottom: 20px; flex-shrink: 0; }
    #arena-header h2 { font-size: 24px; color: #ff8800; margin: 0 0 4px; }
    #arena-header p  { font-size: 12px; color: #885533; margin: 0; letter-spacing: 1px; }
    #arena-list {
      overflow-y: auto; flex: 1;
      display: flex; flex-direction: column; gap: 10px;
      padding-right: 4px;
      scrollbar-width: thin; scrollbar-color: #ff6600 #111;
    }
    #arena-list::-webkit-scrollbar { width: 6px; }
    #arena-list::-webkit-scrollbar-track { background: #111; border-radius: 3px; }
    #arena-list::-webkit-scrollbar-thumb { background: #ff6600; border-radius: 3px; }
    .arena-card {
      display: flex; align-items: center; gap: 14px;
      background: rgba(255,100,0,0.07); border: 1px solid #331500;
      border-radius: 12px; padding: 14px 16px; cursor: pointer;
      transition: background 0.15s, border-color 0.15s;
    }
    .arena-card:hover { background: rgba(255,100,0,0.18); border-color: #ff6600; }
    .arena-card.locked { opacity: 0.45; cursor: not-allowed; }
    .arena-card-icon { font-size: 32px; flex-shrink: 0; line-height: 1; }
    .arena-card-info { flex: 1; }
    .arena-card-name { font-size: 16px; font-weight: bold; color: #ffcc88; margin-bottom: 3px; }
    .arena-card-desc { font-size: 12px; color: #886644; }
    .arena-card-lock { font-size: 11px; color: #ff4444; margin-top: 3px; }
    #arena-close-btn {
      margin-top: 18px; flex-shrink: 0;
      padding: 11px; border-radius: 10px; font-size: 14px; font-family: inherit;
      font-weight: bold; cursor: pointer; border: 2px solid #443300;
      background: #1a0a00; color: #886644; width: 100%;
    }
    #arena-close-btn:hover { background: #2a1200; }

    /* ── WAVE HUD ── */
    #wave-hud {
      display: none; position: absolute; top: 16px; left: 50%;
      transform: translateX(-50%);
      background: rgba(0,5,20,0.85); border: 2px solid #ff6600;
      border-radius: 14px; padding: 10px 28px; text-align: center;
      pointer-events: none; z-index: 50;
      box-shadow: 0 0 30px rgba(255,100,0,0.4);
    }
    #wave-num  { font-size: 22px; font-weight: bold; color: #ff8800; letter-spacing: 2px; }
    #wave-left { font-size: 13px; color: #ffcc88; margin-top: 2px; }

    /* ── ACHIEVEMENTS UI ── */
    #achieve-ui {
      display: none; position: absolute; inset: 0;
      background: rgba(10,6,0,0.9);
      align-items: center; justify-content: center; pointer-events: all;
    }
    #achieve-panel {
      background: linear-gradient(160deg, #1a1000 0%, #2a1800 60%, #1a0e00 100%);
      border: 2px solid #ffaa00; border-radius: 20px;
      padding: 28px 36px; width: 480px; max-width: 96vw;
      box-shadow: 0 0 60px rgba(255,160,0,0.3);
      max-height: 80vh; display: flex; flex-direction: column;
    }
    #achieve-header { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
    #achieve-title { font-size: 22px; font-weight: bold; color: #ffd700; }
    #achieve-progress { font-size: 13px; color: #cc9900; margin-left: auto; }
    #achieve-list { overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
    #achieve-list::-webkit-scrollbar { width: 5px; }
    #achieve-list::-webkit-scrollbar-thumb { background: #664400; border-radius: 3px; }
    .achieve-row {
      display: flex; align-items: center; gap: 12px;
      padding: 10px 14px; border-radius: 12px;
      transition: background 0.15s;
    }
    .achieve-row.achieved { background: rgba(255,180,0,0.12); border: 1px solid rgba(255,160,0,0.3); }
    .achieve-row.achieved.claimed { background: rgba(0,180,80,0.08); border: 1px solid rgba(0,180,80,0.2); }
    .achieve-row.locked { background: rgba(60,40,0,0.3); border: 1px solid rgba(80,60,0,0.3); opacity: 0.65; }
    .achieve-icon { font-size: 24px; flex-shrink: 0; width: 30px; text-align: center; }
    .achieve-info { flex: 1; min-width: 0; }
    .achieve-name { font-size: 14px; font-weight: bold; color: #ffeebb; }
    .achieve-desc { font-size: 11px; color: #aa8855; margin-top: 2px; }
    .achieve-claim-btn {
      flex-shrink: 0; background: #cc7700; color: #fff8e0;
      border: 2px solid #ffaa00; border-radius: 8px;
      padding: 5px 12px; font-size: 12px; font-weight: bold; cursor: pointer;
      white-space: nowrap; transition: background 0.15s;
    }
    .achieve-claim-btn:hover { background: #ffaa00; color: #1a0a00; }
    .achieve-claimed-tag { flex-shrink: 0; color: #44cc77; font-size: 12px; white-space: nowrap; }
    .achieve-locked-tag  { flex-shrink: 0; color: #665533; font-size: 12px; white-space: nowrap; }
    #achieve-close-btn {
      width: 100%; margin-top: 18px; background: #443300; color: #ffd700;
      border: 2px solid #aa7700; padding: 11px 0; border-radius: 10px;
      font-size: 14px; cursor: pointer; transition: background 0.15s; flex-shrink: 0;
    }
    #achieve-close-btn:hover { background: #665500; }

    /* ── BANK UI ── */
    #bank-ui {
      display: none; position: absolute; inset: 0;
      background: rgba(0,5,20,0.82);
      align-items: center; justify-content: center; pointer-events: all;
    }
    #bank-panel {
      background: linear-gradient(160deg, #1a1200 0%, #0d0900 100%);
      border: 2px solid #ffd700; border-radius: 20px;
      padding: 32px 42px; min-width: 360px; text-align: center;
      box-shadow: 0 0 50px rgba(255,210,0,0.25);
    }
    #bank-icon { font-size: 48px; margin-bottom: 6px; }
    #bank-title { font-size: 24px; font-weight: bold; color: #ffd700; margin-bottom: 4px; }
    #bank-subtitle { font-size: 11px; color: #887744; margin-bottom: 22px; letter-spacing: 1px; }
    .bank-balance-row {
      display: flex; justify-content: space-between;
      background: rgba(255,210,0,0.07); border: 1px solid #443300;
      border-radius: 10px; padding: 10px 16px; margin-bottom: 10px;
      font-size: 15px; color: #ffeeaa;
    }
    .bank-balance-row span { color: #ffd700; font-weight: bold; }
    #bank-interest-note { font-size: 11px; color: #887744; margin-bottom: 20px; }
    #bank-input {
      width: 100%; box-sizing: border-box;
      background: rgba(150,110,0,0.18); border: 2px solid #886600;
      border-radius: 10px; color: #ffffff; font-size: 20px; font-family: inherit;
      text-align: center; padding: 9px 14px; outline: none; margin-bottom: 16px;
      letter-spacing: 1px;
    }
    #bank-input:focus { border-color: #ffd700; box-shadow: 0 0 12px rgba(255,210,0,0.3); }
    .bank-btn {
      padding: 11px 22px; border-radius: 10px; font-size: 14px; font-family: inherit;
      font-weight: bold; cursor: pointer; border: 2px solid; transition: background 0.15s;
      margin: 0 5px;
    }
    #bank-deposit-btn   { background: #3a2200; border-color: #ffd700; color: #ffd700; }
    #bank-deposit-btn:hover { background: #5a3500; }
    #bank-withdraw-btn  { background: #221100; border-color: #aa7700; color: #ffcc44; }
    #bank-withdraw-btn:hover { background: #332200; }
    #bank-close-btn     { background: #1a1100; border-color: #443300; color: #887744; }
    #bank-close-btn:hover { background: #2a1a00; }
    #bank-rob-warn {
      margin-top: 14px; font-size: 11px; color: #cc4400;
      display: none;
    }

    /* ── FORCED NAME POPUP ── */
    #name-required-overlay {
      position: fixed; inset: 0; z-index: 9999;
      background: rgba(0,10,30,0.92);
      display: flex; align-items: center; justify-content: center;
      pointer-events: all;
    }
    #name-required-panel {
      background: linear-gradient(160deg, #0a1f3a 0%, #051020 100%);
      border: 3px solid #00ccff; border-radius: 22px;
      padding: 36px 32px; max-width: 360px; width: 88%;
      text-align: center; box-shadow: 0 0 40px rgba(0,200,255,0.3);
    }
    #name-required-icon { font-size: 52px; margin-bottom: 10px; }
    #name-required-title {
      font-size: 26px; font-weight: 900; color: #00eeff;
      margin-bottom: 8px; letter-spacing: 1px;
    }
    #name-required-sub {
      font-size: 14px; color: #88ccdd; margin-bottom: 20px; line-height: 1.4;
    }
    #name-required-input {
      width: 100%; box-sizing: border-box;
      padding: 12px 16px; font-size: 18px; font-weight: bold;
      border-radius: 12px; border: 2px solid #0099cc;
      background: rgba(0,30,60,0.8); color: #fff;
      text-align: center; outline: none; margin-bottom: 8px;
    }
    #name-required-input:focus { border-color: #00eeff; box-shadow: 0 0 10px rgba(0,238,255,0.4); }
    #name-required-error { color: #ff6666; font-size: 13px; margin-bottom: 8px; }
    #name-required-btn {
      margin-top: 12px; width: 100%; padding: 14px;
      font-size: 18px; font-weight: 900; border-radius: 14px;
      border: none; cursor: pointer;
      background: linear-gradient(135deg, #0077cc, #00bbff);
      color: #fff; box-shadow: 0 4px 18px rgba(0,180,255,0.4);
      transition: transform 0.1s;
    }
    #name-required-btn:active { transform: scale(0.96); }

    /* ── NICKNAME UI ── */
    #nickname-ui {
      display: none; position: absolute; inset: 0;
      background: rgba(0,5,20,0.85);
      align-items: center; justify-content: center; pointer-events: all;
    }
    #nickname-panel {
      background: linear-gradient(160deg, #1a0a3a 0%, #0d0520 100%);
      border: 2px solid #cc44ff; border-radius: 20px;
      padding: 36px 44px; min-width: 340px; text-align: center;
      box-shadow: 0 0 50px rgba(180,60,255,0.3);
    }
    #nickname-icon { font-size: 52px; margin-bottom: 8px; }
    #nickname-title { font-size: 22px; font-weight: bold; color: #dd88ff; margin-bottom: 6px; }
    #nickname-subtitle { font-size: 12px; color: #8855aa; margin-bottom: 24px; letter-spacing: 1px; }
    #nickname-input {
      width: 100%; box-sizing: border-box;
      background: rgba(100,30,160,0.3); border: 2px solid #9933cc;
      border-radius: 10px; color: #ffffff; font-size: 20px; font-family: inherit;
      text-align: center; padding: 10px 14px; outline: none; margin-bottom: 18px;
      letter-spacing: 1px;
    }
    #nickname-input:focus { border-color: #dd44ff; box-shadow: 0 0 12px rgba(200,60,255,0.4); }
    #nickname-preview { font-size: 13px; color: #aa77cc; margin-bottom: 20px; min-height: 18px; }
    .nick-btn {
      padding: 11px 28px; border-radius: 10px; font-size: 15px; font-family: inherit;
      font-weight: bold; cursor: pointer; border: 2px solid; transition: background 0.15s;
    }
    #nickname-save-btn { background: #7722bb; border-color: #cc44ff; color: #ffffff; margin-right: 10px; }
    #nickname-save-btn:hover { background: #9933dd; }
    #nickname-cancel-btn { background: #221133; border-color: #553366; color: #aa88cc; }
    #nickname-cancel-btn:hover { background: #332244; }

    /* ── LEVEL UP POPUP ── */
    #levelup-popup {
      display: none; position: absolute;
      top: 50%; left: 50%; transform: translate(-50%, -60%);
      background: linear-gradient(160deg, #1a0a00 0%, #2d1500 60%, #1a0800 100%);
      border: 2px solid #ffaa00; border-radius: 20px;
      padding: 28px 40px; min-width: 300px; text-align: center;
      box-shadow: 0 0 60px rgba(255,160,0,0.4), 0 0 20px rgba(255,100,0,0.3);
      pointer-events: none; z-index: 200;
      animation: lvup-in 0.35s cubic-bezier(0.175,0.885,0.32,1.275);
    }
    @keyframes lvup-in {
      from { transform: translate(-50%, -60%) scale(0.5); opacity: 0; }
      to   { transform: translate(-50%, -60%) scale(1);   opacity: 1; }
    }
    #levelup-title { font-size: 13px; letter-spacing: 3px; color: #ffaa44; text-transform: uppercase; margin-bottom: 4px; }
    #levelup-badge { font-size: 52px; line-height: 1.1; margin: 6px 0; }
    #levelup-name  { font-size: 20px; font-weight: bold; color: #ffeebb; margin-bottom: 16px; }
    #levelup-rewards { display: flex; flex-direction: column; gap: 8px; }
    .lvup-row {
      display: flex; align-items: center; gap: 10px;
      background: rgba(255,140,0,0.12); border-radius: 10px;
      padding: 8px 14px; font-size: 14px; color: #ffd899;
    }
    .lvup-row-icon { font-size: 20px; flex-shrink: 0; }
    .lvup-row b { color: #ffffff; }

    /* ── SHOP ── */
    #shop-ui {
      display: none; position: absolute; inset: 0;
      background: rgba(0,10,30,0.9); align-items: center; justify-content: center;
      pointer-events: all;
    }
    #shop-panel {
      background: rgba(5,20,50,0.97); border: 3px solid #ffcc00; border-radius: 18px;
      color: white; width: min(94vw, 500px); max-height: 88vh;
      display: flex; flex-direction: column; overflow: hidden;
    }
    #shop-header {
      display: flex; align-items: center; justify-content: space-between;
      padding: 14px 20px; border-bottom: 2px solid rgba(255,204,0,0.3); flex-shrink: 0;
    }
    #shop-header h2 { color: #ffcc00; font-size: 20px; margin: 0; }
    #shop-money-disp { color: #ffcc00; font-size: 15px; font-weight: bold; }
    #shop-close-btn {
      background: none; border: 2px solid #666; color: #aaa; border-radius: 6px;
      width: 30px; height: 30px; cursor: pointer; font-size: 15px; pointer-events: all;
    }
    #shop-close-btn:hover { border-color: #fff; color: #fff; }
    #shop-tabs { display: flex; border-bottom: 2px solid rgba(255,204,0,0.2); flex-shrink: 0; }
    .shop-tab {
      flex: 1; padding: 10px; background: none; border: none; color: #888;
      font-size: 14px; cursor: pointer; pointer-events: all;
      border-bottom: 3px solid transparent;
    }
    .shop-tab.active { color: #ffcc00; border-bottom-color: #ffcc00; }
    #shop-content-row { display: flex; flex: 1; overflow: hidden; }
    #shop-content { overflow-y: auto; padding: 14px; flex: 1; }
    #shop-scroll-btns {
      display: flex;
      flex-direction: column; gap: 8px;
      padding: 8px 10px 12px 0;
      align-items: center; flex-shrink: 0;
      justify-content: center;
    }
    #shop-scroll-up, #shop-scroll-down {
      width: 52px; height: 52px; border-radius: 50%;
      background: rgba(255,204,0,0.9); border: 2px solid #ffcc00;
      color: #001020; font-size: 22px; font-weight: bold;
      cursor: pointer; pointer-events: all; touch-action: manipulation;
      display: flex; align-items: center; justify-content: center;
    }
    .shop-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .shop-item {
      background: rgba(255,255,255,0.05); border: 2px solid rgba(255,255,255,0.12);
      border-radius: 12px; padding: 12px; text-align: center;
    }
    .shop-item.s-owned   { border-color: rgba(0,220,150,0.45); }
    .shop-item.s-equipped { border-color: #ffcc00; background: rgba(255,204,0,0.08); }
    .skin-swatch { width: 44px; height: 44px; border-radius: 50%; margin: 0 auto 7px; border: 3px solid rgba(255,255,255,0.25); }
    .shop-item-name { font-size: 12px; font-weight: bold; margin-bottom: 3px; }
    .shop-item-price { font-size: 11px; color: #ffcc00; margin-bottom: 7px; }
    .shop-item-desc  { font-size: 11px; color: #99bbcc; margin-bottom: 7px; }
    .shop-btn {
      background: #ffcc00; color: #001a2e; border: none; border-radius: 6px;
      padding: 5px 10px; font-size: 12px; font-weight: bold;
      cursor: pointer; pointer-events: all; width: 100%;
    }
    .shop-btn:hover:not(:disabled) { background: #ffdd44; }
    .shop-btn:disabled { background: #333; color: #666; cursor: default; }
    .shop-btn.equip-btn  { background: #00ccff; color: #001a2e; }
    .shop-btn.badge-btn  { background: rgba(255,204,0,0.2); color: #ffcc00; cursor: default; }

    /* ── Loadout tab ── */
    .loadout-grid { display: flex; flex-direction: column; gap: 10px; }
    .loadout-slot { background: rgba(255,255,255,0.05); border: 2px solid rgba(255,255,255,0.14);
      border-radius: 12px; padding: 10px 12px; }
    .loadout-slot.loadout-active { border-color: #ffcc00; background: rgba(255,204,0,0.08); }
    .loadout-slot-num  { font-size: 10px; color: #88aacc; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 3px; }
    .loadout-slot-weapon { font-size: 14px; font-weight: bold; color: #fff; margin-bottom: 8px; }
    .loadout-slot-btns { display: flex; flex-wrap: wrap; gap: 5px; }
    .lw-btn { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.2);
      border-radius: 7px; padding: 4px 10px; color: #cce; font-size: 11px; cursor: pointer;
      transition: background 0.15s; }
    .lw-btn:hover { background: rgba(255,255,255,0.18); }
    .lw-btn.lw-active { background: rgba(255,204,0,0.25); border-color: #ffcc00; color: #ffee88; font-weight: bold; }

    .wrow { display: flex; align-items: center; gap: 12px; padding: 10px 12px;
            background: rgba(255,255,255,0.05); border: 2px solid rgba(255,255,255,0.1);
            border-radius: 12px; margin-bottom: 8px; }
    .wrow.s-owned { border-color: rgba(0,220,150,0.4); }
    .wrow-icon { font-size: 32px; }
    .wrow-info { flex: 1; }
    .wrow-name { font-size: 13px; font-weight: bold; }
    .wrow-desc { font-size: 11px; color: #99bbcc; margin-top: 2px; }

    /* money HUD */
    #money-box { color: #ffcc00; border-color: rgba(255,204,0,0.4) !important; }


    /* ── MINI-MAP ── */
    #minimap-wrap {
      display: none; position: absolute; top: 76px; right: 14px;
      pointer-events: none;
      transform: scale(0.85);
      transform-origin: top right;
    }
    #minimap-label {
      font-size: 10px; color: rgba(0,200,255,0.5); text-align: center;
      margin-bottom: 3px; letter-spacing: 2px; text-transform: uppercase;
    }
    #minimap {
      border-radius: 10px; border: 2px solid rgba(0,200,255,0.35); display: block;
    }

    /* ── MOBILE CONTROLS ── */
    #mobile-ui { display: none; position: absolute; inset: 0; pointer-events: none; }
    /* Shown by default on touch devices OR when forced on */
    @media (pointer: coarse) { #mobile-ui { display: block; } }
    #mobile-ui.force-on  { display: block !important; }
    #mobile-ui.force-off { display: none  !important; }

    #joy-base {
      position: absolute; width: 114px; height: 114px; border-radius: 50%;
      background: rgba(255,255,255,0.08); border: 2px solid rgba(255,255,255,0.22);
      pointer-events: none; transition: opacity .15s;
    }
    #joy-knob {
      position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
      width: 50px; height: 50px; border-radius: 50%;
      background: rgba(255,255,255,0.38); pointer-events: none;
    }
    .mob-btn {
      position: absolute; border-radius: 50%; border: none;
      display: flex; align-items: center; justify-content: center;
      font-size: 26px; font-weight: bold; color: white;
      pointer-events: all; cursor: pointer; user-select: none;
      -webkit-user-select: none; touch-action: manipulation;
    }
    #mob-attack {
      width: 80px; height: 80px; bottom: 20px; right: 20px;
      background: rgba(255,60,60,0.82); border: 3px solid #ff4444;
    }
    #mob-up {
      width: 58px; height: 58px; bottom: 88px; right: 144px;
      background: rgba(0,160,255,0.65); border: 2px solid rgba(0,220,255,0.8);
      font-size: 20px;
    }
    #mob-down {
      width: 58px; height: 58px; bottom: 20px; right: 144px;
      background: rgba(0,100,200,0.65); border: 2px solid rgba(0,160,255,0.8);
      font-size: 20px;
    }
    #mob-talk {
      width: 58px; height: 58px; bottom: 172px; right: 20px;
      background: rgba(255,180,0,0.7); border: 2px solid gold;
      font-size: 18px;
    }
    #mob-shop {
      width: 52px; height: 52px; bottom: 302px; right: 20px;
      background: rgba(255,204,0,0.7); border: 2px solid #ffcc00;
      font-size: 20px;
    }
    #mob-home {
      width: 52px; height: 52px; bottom: 364px; right: 20px;
      background: rgba(0,160,80,0.82); border: 2px solid #00cc66;
      font-size: 22px;
    }
    #mob-police {
      width: 52px; height: 52px; bottom: 240px; right: 20px;
      background: rgba(20,80,200,0.82); border: 2px solid #4488ff;
      font-size: 22px;
    }
    #mob-prev-weapon, #mob-next-weapon {
      width: 52px; height: 52px;
      background: rgba(40,40,80,0.82); border: 2px solid rgba(180,180,255,0.6);
      font-size: 22px;
    }
    #mob-prev-weapon { bottom: 110px; right: 82px; }
    #mob-next-weapon { bottom: 110px; right: 20px; }
    #mob-dash {
      width: 70px; height: 70px; bottom: 170px; right: 110px;
      background: rgba(0,200,255,0.85); border: 3px solid #00eeff;
      font-size: 28px;
    }
    #mob-confusion {
      width: 70px; height: 70px; bottom: 158px; left: 55px;
      background: rgba(140,0,220,0.85); border: 3px solid #cc44ff;
      font-size: 28px;
    }
    #mob-confusion.on-cooldown { opacity: 0.45; }
    #mob-gyro {
      width: 52px; height: 52px; top: 16px; right: 16px;
      background: rgba(0,60,140,0.65); border: 2px solid rgba(80,160,255,0.8);
      font-size: 22px;
    }

    /* ── Panel scroll buttons (always visible) ── */
    .panel-scroll-btn {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 100%;
      padding: 5px 0;
      font-size: 16px;
      color: #88ccff;
      background: rgba(0,60,120,0.35);
      border: none;
      border-radius: 8px;
      cursor: pointer;
      user-select: none;
      -webkit-user-select: none;
      touch-action: none;
      letter-spacing: 2px;
      flex-shrink: 0;
    }
    .panel-scroll-btn:hover  { background: rgba(0,80,160,0.5); color: #aaddff; }
    .panel-scroll-btn:active { background: rgba(0,120,220,0.65); color: #fff; }

    /* ── Kidnap alert ── */
    #kidnap-alert {
      animation: kidnap-pulse 1.1s ease-in-out infinite alternate;
    }
    @keyframes kidnap-pulse {
      from { box-shadow: 0 4px 22px rgba(255,30,0,0.45); }
      to   { box-shadow: 0 4px 32px rgba(255,80,0,0.9); border-color: #ff6600; }
    }

    /* ── Ransom note ── */
    #ransom-note {
      animation: ransom-drop 0.4s cubic-bezier(0.22, 1.4, 0.55, 1) both;
      transform-origin: top center;
    }
    @keyframes ransom-drop {
      from { transform: translate(-50%, -65%) rotate(-4deg) scale(0.7); opacity: 0; }
      to   { transform: translate(-50%, -50%) rotate(-1.5deg) scale(1);  opacity: 1; }
    }

    /* Sticky top/bottom inside #start-screen */
    .panel-scroll-top {
      position: sticky; top: 0; z-index: 2;
      border-radius: 8px 8px 0 0; margin-bottom: 4px;
    }
    .panel-scroll-bot {
      position: sticky; bottom: 0; z-index: 2;
      border-radius: 0 0 8px 8px; margin-top: 4px;
    }

    /* Inline row inside arena/achieve panels */
    .panel-scroll-row { border-radius: 8px; margin: 2px 0; }

    /* Make HUD readable on small screens */
    @media (max-width: 500px) {
      .hbox { font-size: 12px; padding: 4px 10px; }
      #score-box { font-size: 13px; }
      .wslot { min-width: 60px; font-size: 11px; padding: 5px 8px; }
      #start-screen { min-width: unset; width: 92vw; padding: 22px 20px; border-radius: 16px; }
      #start-screen h1 { font-size: 32px; }
      #start-screen button { font-size: 18px; padding: 12px 32px; }
      .panel-scroll-btn { font-size: 20px; padding: 7px 0; }
    }

  @keyframes hcPulse {
    0%,100% { opacity:1; text-shadow: 0 0 14px #ff00aa, 0 0 28px #ff00aa; }
    50%      { opacity:0.7; text-shadow: 0 0 4px #ff00aa; }
  }

  /* ── LEADERBOARD HINT ── */
  #lb-hint {
    display: none; position: absolute; bottom: 80px; left: 50%;
    transform: translateX(-50%);
    background: rgba(5,15,5,0.88); border: 2px solid #ffd700;
    border-radius: 12px; padding: 10px 24px; color: #ffd700;
    font-size: 15px; font-weight: bold; letter-spacing: 0.5px;
    pointer-events: all; cursor: pointer; text-align: center;
    box-shadow: 0 0 22px rgba(255,215,0,0.25);
    animation: hintpulse 1.5s ease-in-out infinite;
    white-space: nowrap;
  }

  /* ── LEADERBOARD PANEL ── */
  #leaderboard-ui {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.78);
    display: flex; align-items: center; justify-content: center;
    z-index: 220; pointer-events: all;
  }
  #lb-panel {
    background: linear-gradient(160deg, #0a1a00 0%, #0d2240 60%, #0a0d1a 100%);
    border: 2.5px solid #ffd700; border-radius: 20px;
    padding: 26px 30px 20px; min-width: 340px; max-width: 470px; width: 92%;
    box-shadow: 0 0 50px rgba(255,215,0,0.18), inset 0 0 30px rgba(255,215,0,0.04);
  }
  #lb-header { text-align: center; margin-bottom: 16px; }
  #lb-trophy-icon { font-size: 38px; line-height: 1; margin-bottom: 4px; }
  #lb-title {
    font-size: 24px; font-weight: bold; color: #ffd700;
    letter-spacing: 3px; text-transform: uppercase;
  }
  #lb-subtitle {
    font-size: 10px; color: #886600; letter-spacing: 4px;
    margin-top: 2px; text-transform: uppercase;
  }
  #lb-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
  .lb-tab {
    flex: 1; padding: 8px 4px; border: 1.5px solid #553300;
    border-radius: 10px; background: #1a0e00; color: #aa7722;
    font-size: 13px; cursor: pointer; transition: all 0.18s;
    font-weight: bold;
  }
  .lb-tab:hover { background: #2a1800; border-color: #ffd700; color: #ffd700; }
  .lb-tab-active {
    background: linear-gradient(135deg, #ffd700, #cc9900);
    color: #1a0a00; border-color: #ffd700;
    box-shadow: 0 2px 10px rgba(255,215,0,0.3);
  }
  #lb-content { display: flex; flex-direction: column; gap: 5px; min-height: 220px; }
  .lb-row {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 13px; border-radius: 10px;
    background: rgba(255,255,255,0.04); border: 1.5px solid rgba(255,255,255,0.08);
    transition: background 0.15s;
  }
  .lb-gold   { background: rgba(255,215,0,0.10); border-color: rgba(255,215,0,0.35); }
  .lb-silver { background: rgba(200,200,200,0.08); border-color: rgba(200,200,200,0.25); }
  .lb-bronze { background: rgba(205,127,50,0.10); border-color: rgba(205,127,50,0.28); }
  .lb-me {
    background: rgba(255,215,0,0.16) !important;
    border-color: #ffd700 !important;
    box-shadow: 0 0 10px rgba(255,215,0,0.2);
  }
  .lb-rank { font-size: 20px; min-width: 30px; text-align: center; flex-shrink: 0; }
  .lb-name {
    flex: 1; color: #ffe090; font-size: 13px; font-weight: bold;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .lb-val  { color: #ffd700; font-size: 13px; font-weight: bold; white-space: nowrap; }
  .lb-you-tag {
    font-size: 9px; font-weight: bold; color: #1a0a00;
    background: #ffd700; border-radius: 5px;
    padding: 2px 5px; letter-spacing: 1px; flex-shrink: 0;
  }
  .lb-loading {
    text-align: center; color: #886600; padding: 40px 20px;
    font-size: 14px; line-height: 1.6;
  }
  .lb-offline {
    text-align: center; color: #cc4444; padding: 30px 20px;
    font-size: 13px; line-height: 1.7;
  }
  #lb-close-btn {
    width: 100%; margin-top: 16px; padding: 11px;
    border: 1.5px solid #553300; border-radius: 12px;
    background: #1a0e00; color: #aa7722; font-size: 14px;
    cursor: pointer; transition: all 0.18s; font-weight: bold;
  }
  #lb-close-btn:hover {
    background: linear-gradient(135deg, #ffd700, #cc9900);
    color: #1a0a00; border-color: #ffd700;
  }

  /* ══════════════════════════════════════════════════════
     MULTIPLAYER PORTAL UI
  ══════════════════════════════════════════════════════ */
  #mp-hint {
    position: absolute; bottom: 130px; left: 50%; transform: translateX(-50%);
    background: rgba(0, 30, 50, 0.88); color: #88eeff;
    border: 1.5px solid #00ccee; border-radius: 12px;
    padding: 10px 22px; font-size: 15px; font-weight: bold;
    cursor: pointer; pointer-events: all; text-align: center;
    backdrop-filter: blur(4px);
    box-shadow: 0 0 20px rgba(0,200,240,0.3);
    transition: opacity 0.25s;
  }
  #mp-hint:hover { background: rgba(0, 50, 80, 0.95); }

  /* ── In-game HUD badge (top-right corner) ── */
  #mp-hud {
    position: absolute; top: 16px; right: 16px;
    background: rgba(0, 25, 45, 0.88);
    border: 1.5px solid #00ccee; border-radius: 14px;
    padding: 8px 14px 8px 12px;
    color: #88eeff; font-size: 13px;
    pointer-events: all;
    display: flex; align-items: center; gap: 8px;
    backdrop-filter: blur(4px);
    box-shadow: 0 0 20px rgba(0,180,220,0.25);
  }
  #mp-hud-icon { font-size: 18px; }
  #mp-hud-name { font-weight: bold; color: #ccf4ff; font-size: 13px; line-height: 1.3; }
  #mp-hud-code { color: #00aacc; font-size: 11px; font-weight: bold; letter-spacing: 1px; }
  #mp-hud-leave {
    background: none; border: 1px solid #004466; border-radius: 8px;
    color: #448899; font-size: 12px; padding: 3px 7px;
    cursor: pointer; transition: all 0.15s; font-family: inherit;
  }
  #mp-hud-leave:hover { background: rgba(0,100,140,0.5); color: #88ddff; }

  /* ── Full panel overlay ── */
  #mp-ui {
    position: absolute; inset: 0;
    background: rgba(0, 12, 24, 0.82);
    display: none; align-items: center; justify-content: center;
    pointer-events: all; backdrop-filter: blur(3px);
  }
  #mp-panel {
    background: linear-gradient(160deg, #041e30 0%, #021525 60%, #010d1a 100%);
    border: 2px solid #00aacc; border-radius: 22px;
    padding: 32px 36px; color: white;
    min-width: 360px; max-width: 480px; width: 92vw;
    box-shadow: 0 0 60px rgba(0,180,220,0.3), inset 0 1px 0 rgba(0,200,255,0.1);
    max-height: 88vh; overflow-y: auto;
  }
  #mp-header { text-align: center; margin-bottom: 22px; }
  #mp-portal-icon { font-size: 42px; margin-bottom: 6px; filter: drop-shadow(0 0 12px #00eeff); }
  #mp-title {
    font-size: 26px; font-weight: bold; color: #ccf4ff;
    text-shadow: 0 0 20px rgba(0,220,255,0.7);
    margin-bottom: 4px;
  }
  #mp-subtitle {
    font-size: 10px; color: #3388aa; letter-spacing: 2px;
    text-transform: uppercase;
  }

  /* ── Tab row ── */
  .mp-tabs {
    display: flex; gap: 8px; margin-bottom: 18px;
  }
  .mp-tab {
    flex: 1; padding: 10px 6px; border-radius: 12px; font-size: 14px;
    font-weight: bold; cursor: pointer; transition: all 0.18s;
    background: rgba(0,100,140,0.15); border: 1.5px solid rgba(0,150,200,0.3);
    color: #557788; font-family: inherit;
  }
  .mp-tab:hover { background: rgba(0,120,170,0.3); color: #aaddee; }
  .mp-tab-active {
    background: linear-gradient(135deg, rgba(0,150,200,0.35), rgba(0,100,160,0.25));
    border-color: #00aacc; color: #88eeff;
    box-shadow: 0 0 15px rgba(0,170,220,0.2);
  }

  /* ── Form area ── */
  .mp-form { display: flex; flex-direction: column; gap: 10px; }
  .mp-label {
    font-size: 12px; font-weight: bold; color: #4499bb;
    text-transform: uppercase; letter-spacing: 1px;
  }
  .mp-input {
    width: 100%; padding: 12px 16px; border-radius: 12px; font-size: 16px;
    background: rgba(0, 40, 70, 0.7); border: 1.5px solid #005577;
    color: #ccf4ff; font-family: inherit; outline: none;
    transition: border-color 0.18s;
  }
  .mp-input:focus { border-color: #00aacc; box-shadow: 0 0 12px rgba(0,170,220,0.2); }
  .mp-code-input {
    font-size: 32px; font-weight: bold; letter-spacing: 10px;
    text-align: center; padding: 12px 8px;
  }
  .mp-field-hint { font-size: 11px; color: #336677; line-height: 1.5; }

  /* ── Buttons ── */
  .mp-btn {
    padding: 12px 20px; border-radius: 13px; font-size: 16px;
    font-weight: bold; cursor: pointer; transition: all 0.18s;
    font-family: inherit; border: 2px solid; width: 100%; margin-top: 4px;
  }
  .mp-create-btn {
    background: linear-gradient(135deg, #0077aa, #004d77);
    border-color: #00aacc; color: #ccf4ff;
    box-shadow: 0 4px 18px rgba(0,150,200,0.35);
  }
  .mp-create-btn:hover {
    background: linear-gradient(135deg, #00aadd, #0077aa);
    box-shadow: 0 6px 28px rgba(0,180,240,0.55); transform: translateY(-2px);
  }
  .mp-join-btn {
    background: linear-gradient(135deg, #005588, #003355);
    border-color: #0088bb; color: #aaddff;
    box-shadow: 0 4px 18px rgba(0,120,180,0.3);
  }
  .mp-join-btn:hover {
    background: linear-gradient(135deg, #0077bb, #005588);
    box-shadow: 0 6px 28px rgba(0,150,220,0.5); transform: translateY(-2px);
  }
  .mp-leave-btn {
    background: rgba(80,20,20,0.6); border-color: #883333; color: #ffaaaa;
    margin-top: 8px;
  }
  .mp-leave-btn:hover { background: rgba(120,30,30,0.8); border-color: #cc4444; }

  /* ── In-world view ── */
  .mp-in-world { display: flex; flex-direction: column; align-items: center; gap: 12px; }
  .mp-world-badge {
    font-size: 20px; font-weight: bold; color: #ccf4ff;
    text-align: center;
  }
  .mp-code-display {
    font-size: 44px; font-weight: bold; color: #00eeff;
    letter-spacing: 8px; text-shadow: 0 0 25px rgba(0,240,255,0.6);
    background: rgba(0,30,60,0.6); border-radius: 16px;
    padding: 12px 24px; border: 2px solid rgba(0,200,240,0.3);
  }
  .mp-share-hint { font-size: 13px; color: #3388aa; text-align: center; }
  .mp-online-count {
    font-size: 14px; color: #88ddff;
    background: rgba(0,40,70,0.6); border-radius: 10px;
    padding: 8px 16px; border: 1px solid rgba(0,150,200,0.3);
  }

  /* ── No RTDB warning ── */
  .mp-no-rtdb {
    margin-top: 14px; padding: 14px 16px;
    background: rgba(80,30,0,0.4); border: 1.5px solid #885500;
    border-radius: 12px; font-size: 12px; color: #ffcc88; line-height: 1.7;
    text-align: center;
  }

  /* ── Status line ── */
  #mp-status {
    min-height: 18px; font-size: 13px; color: #88ddff;
    text-align: center; margin-top: 10px; line-height: 1.5;
  }

  /* ── Close button ── */
  #mp-close-btn {
    width: 100%; margin-top: 16px; padding: 11px;
    border: 1.5px solid #004455; border-radius: 12px;
    background: #010e1a; color: #336677; font-size: 14px;
    cursor: pointer; transition: all 0.18s; font-weight: bold; font-family: inherit;
  }
  #mp-close-btn:hover {
    background: linear-gradient(135deg, #00aadd, #007799);
    color: #fff; border-color: #00ccee;
  }
