:root {
    --ground: #dfece6; --panel: #fbfcf9; --panel-2: #eef5f1; --ink: #1d2a33; --muted: #5b6d74; --line: #c6d8d0;
    --accent: #d9503a; --accent-ink: #ffffff; --accent-soft: #fbe3dd; --teal: #2a767c; --gold: #b7791f;
    --wood: #8e6240; --wood-d: #6d4a30; --focus: #2a767c; --ok: #2f7d4f;
    --r1: #e4e1ee; --r2: #cdeff2; --r3: #ffd6e0; --r4: #e5d8ff;
    --f-display: "Mitr", "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, sans-serif;
    --f-body: "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
    --f-pixel: "Pixelify Sans", ui-monospace, Menlo, monospace;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      color-scheme: dark; --ground: #0e1d24; --panel: #152c35; --panel-2: #1b3843; --ink: #e3efeb; --muted: #93abb1; --line: #28474f;
      --accent: #ff7a5c; --accent-ink: #1a1111; --accent-soft: #3e2621; --teal: #66c4c4; --gold: #f2c14e; --wood: #b98759; --wood-d: #8a6040; --focus: #66c4c4; --ok: #6fd39b;
      --r1: #3a3f52; --r2: #1f4b52; --r3: #5a2f3d; --r4: #3f3566;
    }
  }
  :root[data-theme="dark"] {
    color-scheme: dark; --ground: #0e1d24; --panel: #152c35; --panel-2: #1b3843; --ink: #e3efeb; --muted: #93abb1; --line: #28474f;
    --accent: #ff7a5c; --accent-ink: #1a1111; --accent-soft: #3e2621; --teal: #66c4c4; --gold: #f2c14e; --wood: #b98759; --wood-d: #8a6040; --focus: #66c4c4; --ok: #6fd39b;
    --r1: #3a3f52; --r2: #1f4b52; --r3: #5a2f3d; --r4: #3f3566;
  }
  * { box-sizing: border-box; }
  [hidden] { display: none !important; }
  body { background: var(--ground); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.5; padding-inline: 16px; padding-block: 14px 40px; }
  .wrap { max-width: 1000px; margin: 0 auto; display: grid; gap: 10px; }
  .pixel { font-family: var(--f-pixel); letter-spacing: .05em; }

  /* HUD */
  .hud { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; }
  .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .who h1 { font-family: var(--f-display); font-weight: 600; font-size: 20px; margin: 0; line-height: 1.1; }
  .lvl { display: grid; gap: 2px; }
  .lvl .top { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
  .lvl .top b { font-family: var(--f-pixel); font-size: 15px; color: var(--teal); }
  .xpbar { width: 150px; height: 8px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); overflow: hidden; }
  .xpbar i { display: block; height: 100%; width: 0; background: var(--teal); transition: width .3s; }
  .chips { display: flex; gap: 6px; flex-wrap: wrap; }
  .chip { display: inline-flex; align-items: center; gap: 5px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 13.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .chip .pixel { font-size: 14px; }
  .chip.save.ok { color: var(--ok); }

  .stage { position: relative; background: var(--wood); border-radius: 12px; padding: 8px; box-shadow: inset 0 0 0 2px var(--wood-d); }
  #view { display: block; width: 100%; height: auto; aspect-ratio: 5 / 3; image-rendering: pixelated; border-radius: 4px; background: #7ec46e; touch-action: none; outline: none; }
  #view:focus-visible { box-shadow: 0 0 0 3px var(--focus); }
  .toasts { position: absolute; left: 0; right: 0; top: 14px; display: grid; justify-items: center; gap: 6px; pointer-events: none; padding-inline: 16px; }
  .toast { background: rgba(20, 30, 40, .86); color: #fff; border-radius: 10px; padding: 6px 12px; font-size: 14px; max-width: 100%; text-align: center; animation: pop .2s ease-out; }
  .toast.gold { background: rgba(120, 80, 10, .9); }
  .toast.bad { background: rgba(120, 30, 40, .88); }
  @keyframes pop { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }
  .hint { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); background: rgba(20, 30, 40, .78); color: #fff; font-size: 13.5px; border-radius: 999px; padding: 4px 12px; pointer-events: none; white-space: nowrap; max-width: calc(100% - 32px); overflow: hidden; text-overflow: ellipsis; }
  .fade { position: absolute; inset: 8px; border-radius: 4px; background: #101830; opacity: 0; pointer-events: none; transition: opacity .6s; }
  .fade.on { opacity: 1; }

  .bar { order: 1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
  .btn { font: inherit; font-size: 14px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 999px; padding: 6px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
  .btn:hover { border-color: var(--teal); }
  .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 500; }
  .btn:disabled { opacity: .45; cursor: not-allowed; }
  .btn:focus-visible, .tab:focus-visible, .slot:focus-visible, .pick:focus-visible, .pad button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
  .keys { color: var(--muted); font-size: 13px; margin: 0; }
  .kbd { font-family: var(--f-pixel); font-size: 11px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; }

  /* touch controls */
  .touch { display: none; justify-content: space-between; align-items: center; gap: 12px; user-select: none; -webkit-user-select: none; }
  @media (hover: none), (pointer: coarse) { .touch { display: flex; } .keys { display: none; } }
  body.touch-on .touch { display: flex; } body.touch-on .keys { display: none; }
  .pad { display: grid; grid-template-columns: repeat(3, 54px); grid-template-rows: repeat(3, 54px); gap: 4px; touch-action: none; }
  .pad button { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; font-size: 20px; color: var(--ink); touch-action: none; }
  .pad button.on { background: var(--panel-2); }
  .pad .u { grid-area: 1 / 2; } .pad .l { grid-area: 2 / 1; } .pad .r { grid-area: 2 / 3; } .pad .d { grid-area: 3 / 2; }
  .abtns { display: flex; gap: 10px; align-items: center; }
  .abtn { width: 84px; height: 84px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-family: var(--f-display); font-size: 18px; touch-action: none; box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 55%, #000); }
  .abtn.small { width: 58px; height: 58px; font-size: 14px; background: var(--panel); color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
  .abtn.small[aria-pressed="true"] { background: var(--ink); color: var(--panel); }

  /* modals */
  .overlay { position: fixed; inset: 0; background: rgba(15, 25, 30, .55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
  .card { background: var(--panel); color: var(--ink); border-radius: 16px; width: min(640px, 100%); max-height: 88vh; overflow: auto; padding: 18px; position: relative; box-shadow: 0 20px 50px -20px rgba(0,0,0,.5); }
  .card h2 { font-family: var(--f-display); font-weight: 500; font-size: 22px; margin: 0 40px 4px 0; }
  .card .sub { color: var(--muted); font-size: 13.5px; margin: 0 0 10px; }
  .x { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-size: 16px; cursor: pointer; }
  .tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
  .tab { font: inherit; font-size: 14px; border: 0; background: transparent; color: var(--muted); padding: 8px 12px; border-bottom: 2px solid transparent; cursor: pointer; }
  .tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 500; }
  .ic { display: inline-block; width: 48px; height: 48px; image-rendering: pixelated; background-repeat: no-repeat; flex: none; }
  .ic.sm { width: 24px; height: 24px; }
  .fishic { display: inline-block; width: 64px; height: 40px; image-rendering: pixelated; background-repeat: no-repeat; flex: none; }
  .fishic.big { width: 128px; height: 80px; }
  .fishic.sil { filter: brightness(0) opacity(.35); }
  .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
  .slot { font: inherit; color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 6px; display: grid; justify-items: center; gap: 2px; text-align: center; cursor: pointer; position: relative; }
  .slot[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
  .slot .nm { font-size: 12.5px; line-height: 1.3; }
  .slot .qty { position: absolute; top: 4px; right: 6px; font-family: var(--f-pixel); font-size: 12px; }
  .slot.r1 { background: var(--r1); } .slot.r2 { background: var(--r2); } .slot.r3 { background: var(--r3); } .slot.r4 { background: var(--r4); }
  .slot.r5 { background: linear-gradient(120deg, var(--r3), #fff1bf, #d8f5e3, var(--r2)); color: #1d2a33; }
  .rows { display: grid; gap: 8px; }
  .row { display: flex; gap: 12px; align-items: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
  .row .tx { flex: 1; min-width: 0; line-height: 1.35; }
  .row .tx b { display: block; font-weight: 500; }
  .row .tx small { color: var(--muted); font-size: 12.5px; display: block; }
  .row .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; flex: none; }
  .price { font-family: var(--f-pixel); font-variant-numeric: tabular-nums; }
  .rar { display: inline-block; font-size: 12px; border-radius: 99px; padding: 0 8px; border: 1px solid var(--line); }
  .rar.r1 { background: var(--r1); } .rar.r2 { background: var(--r2); } .rar.r3 { background: var(--r3); } .rar.r4 { background: var(--r4); } .rar.r5 { background: linear-gradient(90deg, #ffd6e0, #fff1bf, #d8f5e3, #d8e6ff); color: #1d2a33; }
  .catch { text-align: center; width: min(400px, 100%); }
  .catch .fishic.big { margin: 6px auto 0; display: block; }
  .newb { position: absolute; left: 14px; top: 14px; background: var(--gold); color: #1d1405; font-family: var(--f-pixel); border-radius: 8px; padding: 2px 8px; transform: rotate(-8deg); }
  .reward { display: flex; justify-content: center; gap: 6px; margin: 10px 0 14px; flex-wrap: wrap; }
  .reward span { background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px; font-size: 13.5px; }
  .picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin: 10px 0 14px; }
  .pick { font: inherit; color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 6px; display: grid; justify-items: center; gap: 2px; cursor: pointer; }
  .pick[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
  .pick canvas { width: 80px; height: 80px; image-rendering: pixelated; }
  .pick span { font-size: 12.5px; }
  .empty { color: var(--muted); font-size: 14px; padding: 18px; text-align: center; }
  .danger { color: var(--accent); background: none; border: 0; font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; padding: 0; }
  .book-hint { font-size: 12px; color: var(--muted); line-height: 1.35; }
  .xpbar.sta i { background: var(--gold); }
  .xpbar.sta.low i { background: var(--accent); }
  .lvl .top { align-items: center; }
  .chip.buff { border-color: var(--gold); }
  .btn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }
  .chhead { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
  .chhead canvas { width: 128px; height: 128px; image-rendering: pixelated; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; flex: none; }
  .chhead .meta { flex: 1; min-width: 0; display: grid; gap: 4px; }
  .chhead .meta b { font-family: var(--f-display); font-weight: 500; font-size: 18px; }
  .chhead .xpbar { width: 100%; height: 10px; }
  .pts { font-size: 13.5px; }
  .pts b { font-family: var(--f-pixel); color: var(--accent); font-size: 16px; }
  .sec { font-family: var(--f-display); font-weight: 500; font-size: 15px; margin: 14px 0 6px; }
  .statv { font-family: var(--f-pixel); font-size: 18px; min-width: 2.2em; text-align: right; font-variant-numeric: tabular-nums; }
  .statv small { font-family: var(--f-body); font-size: 12px; color: var(--ok); display: block; line-height: 1; }
  .plus { width: 36px; height: 36px; border-radius: 50%; padding: 0; justify-content: center; font-size: 18px; }
  .derived { display: flex; flex-wrap: wrap; gap: 6px; }
  .derived span { background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px; font-size: 12.5px; }
  .pbar { height: 6px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); overflow: hidden; margin-top: 4px; }
  .pbar i { display: block; height: 100%; background: var(--teal); }
  .durbar { display: block; height: 5px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); overflow: hidden; margin-top: 4px; max-width: 220px; }
  .durbar i { display: block; height: 100%; background: #7cc46e; }
  .durbar i.low { background: #f2a14e; }
  .row.broken { border-color: #e5483b; }
  .hslot.broken .ic { opacity: .4; }
  .hslot.broken b { color: #ff8a7a; }
  .mats { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
  .need { font-size: 12.5px; }
  .need .miss { color: var(--accent); }
  .need .have { color: var(--ok); }
  .slot .book-hint { font-size: 11px; }
  .slot:disabled { cursor: not-allowed; opacity: .55; }
  /* MMORPG unit frame (top-left of the game screen) */
  .stage { container-type: inline-size; }
  .ufwrap { position: absolute; left: 16px; top: 16px; display: grid; gap: 5px; justify-items: start; z-index: 2; }
  .uf { --pz: clamp(42px, 7cqw, 66px); font: inherit; color: #fff; cursor: pointer; display: flex; align-items: center; gap: clamp(6px, 1cqw, 10px);
    width: clamp(150px, 30cqw, 280px); padding: clamp(4px, .7cqw, 7px) clamp(8px, 1.2cqw, 12px) clamp(4px, .7cqw, 7px) clamp(4px, .7cqw, 7px);
    background: linear-gradient(180deg, rgba(46,36,60,.86), rgba(24,19,34,.86)); border: 2px solid #150f1d; border-radius: 10px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.13), inset 0 1px 0 rgba(255,255,255,.18), 0 3px 0 rgba(0,0,0,.28); text-align: left; }
  .uf:hover { background: linear-gradient(180deg, rgba(58,46,76,.9), rgba(30,24,42,.9)); }
  .uf:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
  .uf-port { position: relative; width: var(--pz); height: var(--pz); flex: none; border-radius: 50%; background: radial-gradient(circle at 50% 38%, #7fd1c9, #2f7f86 70%, #22575f);
    border: 2px solid #e8c170; box-shadow: 0 0 0 2px #150f1d, inset 0 -3px 0 rgba(0,0,0,.25); }
  .uf-port canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; border-radius: 50%; }
  .uf-lv { position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%); background: linear-gradient(#ffe08a, #e0a73a); color: #2b1a05; border: 2px solid #150f1d;
    border-radius: 6px; padding: 0 5px; font-family: var(--f-pixel); font-size: clamp(11px, 1.5cqw, 14px); line-height: 1.25; white-space: nowrap; }
  .uf-lv.up { animation: lvup 1.1s ease-out; }
  @keyframes lvup { 0% { transform: translateX(-50%) scale(1); } 20% { transform: translateX(-50%) scale(1.6); filter: brightness(1.5); } 100% { transform: translateX(-50%) scale(1); } }
  .uf-main { flex: 1; min-width: 0; display: grid; gap: clamp(3px, .5cqw, 5px); }
  .uf-name { display: flex; align-items: center; gap: 6px; font-family: var(--f-display); font-weight: 500; font-size: clamp(12px, 1.7cqw, 15px); line-height: 1.1; text-shadow: 0 1px 0 #150f1d; white-space: nowrap; overflow: hidden; }
  .uf-pts { font-family: var(--f-pixel); font-size: clamp(10px, 1.3cqw, 12px); background: #e5483b; color: #fff; border-radius: 99px; padding: 0 6px; line-height: 1.4; animation: blink 1.2s steps(2) infinite; }
  @keyframes blink { 50% { opacity: .45; } }
  .uf-bar { position: relative; display: block; height: clamp(11px, 1.8cqw, 15px); background: #2a2133; border: 1px solid #150f1d; border-radius: 4px; overflow: hidden; box-shadow: inset 0 2px 0 rgba(0,0,0,.35); }
  .uf-bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 3px 0 0 3px; }
  .uf-bar .fill { transition: width .18s ease-out; box-shadow: inset 0 1px 0 rgba(255,255,255,.45), inset 0 -2px 0 rgba(0,0,0,.18); }
  .uf-bar .trail { background: #ffe9b8; transition: width .5s ease-in .35s; }
  .uf-bar.sta .fill { background: linear-gradient(90deg, #f0a13a, #ffd66b); }
  .uf-bar.sta.low .fill { background: linear-gradient(90deg, #d9503a, #ff8a6a); }
  .uf-bar.sta.low { animation: lowsta .8s ease-in-out infinite alternate; }
  @keyframes lowsta { to { box-shadow: inset 0 2px 0 rgba(0,0,0,.35), 0 0 0 2px rgba(229,72,59,.7); } }
  .uf-bar.xp { height: clamp(9px, 1.4cqw, 12px); }
  .uf-bar.xp .fill { background: linear-gradient(90deg, #5a8cff, #9fd0ff); transition: width .4s ease-out; }
  .uf-bar em { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 3px; font-style: normal; font-family: var(--f-pixel);
    font-size: clamp(9px, 1.35cqw, 12px); line-height: 1; color: #fff; text-shadow: 1px 0 #150f1d, -1px 0 #150f1d, 0 1px #150f1d, 0 -1px #150f1d; letter-spacing: .04em; }
  .uf-bar.xp em { font-size: clamp(8px, 1.15cqw, 10px); }
  .uf-bar em .lab { color: #ffe9b8; }
  .uf-buffs { display: flex; gap: 4px; padding-left: 4px; }
  .uf-buff { position: relative; width: 30px; height: 30px; border: 2px solid #150f1d; border-radius: 6px; background: rgba(46,36,60,.86); box-shadow: inset 0 0 0 1px #e8c170; display: grid; place-items: center; }
  .uf-buff .ic.sm { width: 24px; height: 24px; }
  .uf-buff small { position: absolute; bottom: -9px; left: 50%; transform: translateX(-50%); font-family: var(--f-pixel); font-size: 10px; color: #fff; background: #150f1d; border-radius: 4px; padding: 0 3px; line-height: 1.3; white-space: nowrap; }
  /* top-right: clock + money panel */
  .trw { position: absolute; right: 16px; top: 16px; display: grid; gap: 5px; justify-items: end; z-index: 2; pointer-events: none; }
  .gpanel { background: linear-gradient(180deg, rgba(46,36,60,.86), rgba(24,19,34,.86)); border: 2px solid #150f1d; border-radius: 10px; color: #fff;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.13), inset 0 1px 0 rgba(255,255,255,.18), 0 3px 0 rgba(0,0,0,.28); }
  .clockw { display: flex; align-items: center; gap: clamp(6px, 1cqw, 10px); padding: clamp(4px, .6cqw, 6px) clamp(8px, 1.2cqw, 12px) clamp(4px, .6cqw, 6px) clamp(4px, .6cqw, 6px); }
  .clockw canvas { width: clamp(44px, 7.2cqw, 70px); aspect-ratio: 22 / 14; image-rendering: pixelated; border: 2px solid #150f1d; border-radius: 6px; box-shadow: 0 0 0 1px #e8c170; display: block; }
  .clockw .ct { display: grid; line-height: 1.15; text-shadow: 0 1px 0 #150f1d; }
  .clockw .ct b { font-family: var(--f-pixel); font-weight: 600; font-size: clamp(15px, 2.4cqw, 22px); letter-spacing: .06em; font-variant-numeric: tabular-nums; }
  .clockw .ct span { font-size: clamp(10px, 1.35cqw, 12.5px); color: #e6dcf0; white-space: nowrap; }
  .gpills { display: flex; gap: 5px; }
  .gpill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px 1px 4px; border-radius: 99px; font-size: clamp(11px, 1.4cqw, 13px); white-space: nowrap; }
  .gpill .pixel { font-size: clamp(12px, 1.6cqw, 15px); color: #ffe08a; text-shadow: 0 1px 0 #150f1d; }
  .gpill.save { padding: 3px 8px; gap: 0; }
  .gpill.save i { width: 8px; height: 8px; border-radius: 50%; background: #9aa3ad; box-shadow: 0 0 0 2px rgba(0,0,0,.3); flex: none; }
  .gpill.save[data-mode="cloud"] i { background: #6fd39b; }
  .gpill.save[data-mode="saving"] i { background: #f2c14e; animation: blink .5s steps(2) infinite; }
  .gpill.save span { max-width: 0; overflow: hidden; transition: max-width .4s, margin .4s; }
  .gpill.save.show span { max-width: 12em; margin-left: 6px; }
  /* bottom-left hotbar */
  .hotbar { position: absolute; left: 16px; bottom: 16px; display: flex; gap: 6px; z-index: 2; }
  .hslot { --hs: clamp(40px, 6.6cqw, 62px); position: relative; width: var(--hs); height: var(--hs); padding: 0; display: grid; place-items: center; cursor: pointer; color: #fff; font: inherit;
    background: linear-gradient(180deg, rgba(46,36,60,.88), rgba(24,19,34,.88)); border: 2px solid #150f1d; border-radius: 9px;
    box-shadow: inset 0 0 0 1px #e8c170, inset 0 2px 0 rgba(255,255,255,.15), 0 3px 0 rgba(0,0,0,.28); }
  .hslot:hover { filter: brightness(1.15); }
  .hslot:active { transform: translateY(1px); }
  .hslot:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
  .hslot .ic { pointer-events: none; }
  .hslot b { position: absolute; right: 2px; bottom: 1px; font-family: var(--f-pixel); font-size: clamp(10px, 1.4cqw, 13px); line-height: 1; color: #fff; text-shadow: 1px 0 #150f1d, -1px 0 #150f1d, 0 1px #150f1d, 0 -1px #150f1d; }
  .hslot kbd { position: absolute; left: 3px; top: 2px; font-family: var(--f-pixel); font-size: 10px; line-height: 1; color: #e8c170; text-shadow: 0 1px 0 #150f1d; }
  .hslot .hxp { position: absolute; left: 4px; right: 4px; bottom: -6px; height: 4px; border-radius: 3px; background: #2a2133; border: 1px solid #150f1d; overflow: hidden; }
  .hslot .hxp i { display: block; height: 100%; background: #6fd39b; }
  .toasts { padding-inline: calc(clamp(170px, 30cqw, 280px) + 28px); }
  @container (max-width: 640px) {
    .toasts { top: calc(clamp(42px, 7cqw, 66px) + 30px); padding-inline: 16px; }
    .hint { bottom: calc(clamp(40px, 6.6cqw, 62px) + 26px); }
    .clockw .ct .wx { display: none; }
    .trw .gpill.save { display: none; }
    .ufwrap, .trw { top: 12px; } .ufwrap { left: 12px; } .trw { right: 12px; } .hotbar { left: 12px; bottom: 12px; }
  }
  @media (prefers-reduced-motion: reduce) { .gpill.save i, .gpill.save span { animation: none; transition: none; } .uf-pts, .uf-bar.sta.low, .uf-lv.up { animation: none; } .uf-bar .fill, .uf-bar .trail { transition: none; } }
  @media (prefers-reduced-motion: reduce) { .toast { animation: none; } .fade { transition: none; } }

  /* ---- 3D stage overrides */
  .stage { padding: 0; background: #10161c; overflow: hidden; box-shadow: 0 0 0 2px #2b1e26, 0 10px 30px -12px rgba(0,0,0,.45); user-select: none; -webkit-user-select: none; }
  #gl { display: block; width: 100%; aspect-ratio: 16 / 10; touch-action: none; outline: none; cursor: pointer; }
  #gl:focus-visible { box-shadow: inset 0 0 0 3px var(--focus); }
  #ov { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
  .flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
  .bitering { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 0 10px rgba(229,72,59,.35); opacity: 0; }
  .fade { inset: 0; border-radius: 0; z-index: 4; }
  .cams { position: absolute; right: 14px; bottom: 14px; z-index: 3; display: flex; gap: 4px; }
  .cbtn { width: clamp(32px, 4.4cqw, 40px); height: clamp(32px, 4.4cqw, 40px); padding: 0; font: inherit; font-size: clamp(15px, 2cqw, 18px); color: #fff; cursor: pointer; display: grid; place-items: center; line-height: 1; }
  .cbtn:hover { filter: brightness(1.18); }
  .cbtn:focus-visible, .abtn3:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
  .stage.fishing .cams { display: none; }
  .abtn3 { position: absolute; right: 14px; bottom: 14px; z-index: 3; width: clamp(58px, 12cqw, 76px); height: clamp(58px, 12cqw, 76px); border-radius: 50%; border: 3px solid #150f1d; background: radial-gradient(circle at 40% 35%, #ff8a70, #d9503a); color: #fff; font-family: var(--f-display); font-size: 22px; box-shadow: 0 4px 0 rgba(0,0,0,.35), inset 0 2px 0 rgba(255,255,255,.35); touch-action: none; display: none; }
  body.touch-on .abtn3 { display: block; }
  .bbtn3 { right: calc(14px + (clamp(58px, 12cqw, 76px) - clamp(48px, 10cqw, 62px)) / 2); bottom: calc(26px + clamp(58px, 12cqw, 76px)); width: clamp(48px, 10cqw, 62px); height: clamp(48px, 10cqw, 62px); font-size: 18px; background: radial-gradient(circle at 40% 35%, #8fd0ff, #3f86d9); }
  body.touch-on .bbtn3 { display: none; }
  body.touch-on #stage.luring .bbtn3 { display: block; }
  body.touch-on #stage.luring .hint { left: 12px; transform: none; max-width: calc(100% - 100px); white-space: normal; border-radius: 12px; }
  body.touch-on .cams { bottom: calc(clamp(58px, 12cqw, 76px) + 24px); }
  .nogl { color: #fff; padding: 40px 20px; text-align: center; }
  @container (max-width: 640px) { #gl { aspect-ratio: 3 / 4; max-height: 78vh; } }

  /* ---- in-game windows (non-blocking, draggable) */
  .gwin { position: absolute; z-index: 6; width: min(480px, calc(100% - 20px)); max-height: calc(100% - 20px); display: flex; flex-direction: column;
    background: rgba(24,19,34,.95); border: 2px solid #150f1d; border-radius: 10px; color: #f1ecf7; font-size: 14px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.13), 0 12px 28px rgba(0,0,0,.45);
    --panel: #2b2238; --panel-2: #342a44; --ink: #f1ecf7; --muted: #c2b6d2; --line: #4d3f60; --accent-soft: #55302c; --ok: #7fe0a4;
    --accent: #ff7a5c; --accent-ink: #1a1111; --teal: #66c4c4; --r1: #3a3f52; --r2: #1f4b52; --r3: #5a2f3d; --r4: #3f3566; color-scheme: dark; }
  .gwin-h { display: flex; align-items: center; gap: 8px; padding: 5px 6px 5px 12px; cursor: move; background: linear-gradient(#3d3053, #2a2139); border-bottom: 1px solid #150f1d; border-radius: 8px 8px 0 0; touch-action: none; user-select: none; }
  .gwin-h b { font-family: var(--f-display); font-weight: 500; font-size: 15px; }
  .gwin-h .k, .gm .k { font-family: var(--f-pixel); font-size: 11px; line-height: 1.2; color: #ffe08a; border: 1px solid #6b5a80; border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: #1d1628; }
  .gwin-x { margin-left: auto; width: 28px; height: 28px; border-radius: 6px; border: 1px solid #5a4a70; background: #2a2139; color: #fff; cursor: pointer; font-size: 14px; }
  .gwin-x:hover { background: #4a3a60; }
  .gwin-b { overflow: auto; padding: 10px 12px 12px; overscroll-behavior: contain; }
  .gwin .tab { color: var(--muted); } .gwin .tab[aria-selected="true"] { color: #fff; }
  .gwin .btn { background: #3a2f4c; color: #fff; border-color: #5a4a70; }
  .gwin .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
  .gwin :focus-visible { outline: 2px solid #ffe08a; outline-offset: 2px; }
  #charWin { left: 14px; top: calc(clamp(42px, 7cqw, 66px) + 40px); } #bagWin { right: 14px; top: calc(clamp(42px, 7cqw, 66px) + 70px); } #helpWin { left: 50%; top: 40px; transform: translateX(-50%); width: min(430px, calc(100% - 20px)); }
  @container (max-width: 640px) { .gwin { left: 10px !important; right: 10px !important; top: 10px !important; transform: none !important; width: auto; } }

  /* character window */
  .cw-hd { display: grid; gap: 4px; margin-bottom: 10px; }
  .cw-name { display: flex; gap: 8px; align-items: center; }
  .cw-name b { font-family: var(--f-display); font-weight: 500; font-size: 19px; }
  .cw-name input { font: inherit; font-size: 15px; background: #1d1628; color: #fff; border: 1px solid #6b5a80; border-radius: 6px; padding: 3px 8px; width: 11em; }
  .cw-edit { border: 1px solid #5a4a70; background: #2a2139; color: #ffe08a; border-radius: 6px; font: inherit; font-size: 12.5px; padding: 1px 8px; cursor: pointer; }
  .cw-sub { color: var(--muted); font-size: 13px; }
  .cw-hd .xpbar { width: 100%; height: 8px; background: #1d1628; border-color: #4d3f60; }
  .cw-hd .xpbar i { background: linear-gradient(90deg, #5a8cff, #9fd0ff); }
  .cw-grid { display: grid; grid-template-columns: 172px 1fr; gap: 12px; align-items: start; }
  @container (max-width: 520px) { .cw-grid { grid-template-columns: 1fr; } }
  .cw-doll { display: grid; grid-template-columns: 48px 64px 48px; grid-template-rows: 48px 64px 48px; gap: 4px; justify-content: center; align-items: center; justify-items: center;
    background: radial-gradient(circle at 50% 45%, #3f5f6a, #221b2e 75%); border: 1px solid #4d3f60; border-radius: 10px; padding: 8px 4px; }
  .cw-doll canvas { grid-area: 2 / 2; width: 96px; height: 96px; image-rendering: pixelated; margin: -16px; }
  .cw-slot { position: relative; width: 48px; height: 48px; border-radius: 8px; border: 2px solid #150f1d; background: #2a2139; box-shadow: inset 0 0 0 1px #e8c170; cursor: pointer; padding: 0; display: grid; place-items: center; }
  .cw-slot[aria-pressed="true"] { box-shadow: inset 0 0 0 2px #ffe08a, 0 0 0 2px #ffe08a; }
  .cw-slot .ic { width: 24px; height: 24px; }
  .cw-slot small { position: absolute; left: 0; right: 0; bottom: -2px; font-size: 9.5px; color: #c2b6d2; text-align: center; line-height: 1; }
  .cw-slot.s-hat { grid-area: 1 / 2; } .cw-slot.s-top { grid-area: 2 / 1; } .cw-slot.s-rod { grid-area: 2 / 3; } .cw-slot.s-shoes { grid-area: 3 / 2; }
  .cw-pts { font-size: 13px; margin-bottom: 6px; } .cw-pts b { font-family: var(--f-pixel); color: #ff9a7a; font-size: 15px; }
  .cw-stat { display: grid; grid-template-columns: 24px 1fr auto 30px; gap: 8px; align-items: center; padding: 4px 6px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); margin-bottom: 4px; }
  .cw-stat .ic { width: 24px; height: 24px; }
  .cw-stat .nm { line-height: 1.15; font-size: 13.5px; } .cw-stat .nm small { display: block; color: var(--muted); font-size: 11px; }
  .cw-stat .v { font-family: var(--f-pixel); font-size: 17px; } .cw-stat .v i { font-style: normal; font-size: 11px; color: #7fe0a4; margin-left: 2px; }
  .cw-stat .plus { width: 28px; height: 28px; font-size: 16px; }
  .cw-pick { margin-top: 10px; padding: 8px; border: 1px dashed #6b5a80; border-radius: 10px; }
  .cw-pick .grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
  .cw-sec { font-family: var(--f-display); font-weight: 500; font-size: 14px; margin: 12px 0 6px; color: #ffe08a; }
  .cw-prof { display: grid; grid-template-columns: 24px 1fr; gap: 8px; align-items: center; margin-bottom: 6px; font-size: 13px; }
  .cw-prof .ic { width: 24px; height: 24px; }
  .cw-prof .pbar { background: #1d1628; border-color: #4d3f60; }
  .gwin .derived span { background: #2a2139; border-color: #4d3f60; }

  /* in-game menu with hotkeys */
  .gmenu { position: absolute; right: 14px; bottom: 14px; z-index: 3; display: flex; gap: 4px; }
  .gm { position: relative; width: clamp(40px, 5.4cqw, 50px); height: clamp(40px, 5.4cqw, 50px); padding: 0; cursor: pointer; color: #fff; font: inherit; font-size: 11px; display: grid; place-items: center; }
  .gm:hover { filter: brightness(1.18); }
  .gm:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
  .gm .ic.sm { width: 24px; height: 24px; }
  .gm .k { position: absolute; top: -7px; right: -5px; }
  .gm .lb { position: absolute; bottom: 1px; left: 0; right: 0; text-align: center; font-size: 9.5px; line-height: 1; color: #e6dcf0; }
  .gm .gl { font-size: 17px; line-height: 1; margin-top: -8px; }
  .gm .dot { position: absolute; top: 3px; left: 3px; width: 8px; height: 8px; border-radius: 50%; background: #ff6a4a; }
  .gm .pixel { position: absolute; top: 2px; left: 3px; font-size: 9px; color: #ffe08a; }
  .cams { bottom: calc(clamp(40px, 5.4cqw, 50px) + 26px); }
  .hint { bottom: calc(clamp(40px, 5.4cqw, 50px) + 28px); }
  @container (max-width: 640px) {
    .gmenu { right: auto; left: 50%; transform: translateX(-50%); bottom: 10px; display: grid; grid-template-columns: repeat(4, 34px); gap: 3px; }
    .gm { width: 34px; height: 34px; } .gm .lb, .gm .k, .gm .pixel { display: none; } .gm .gl { margin-top: 0; }
    .cams { bottom: auto; top: 92px; right: 10px; flex-direction: column; } #zoomI, #zoomO { display: none; }
    .hint { bottom: 92px; }
  }
  body.touch-on .gm .k { display: none; }
  #campWin { left: 50%; top: 40px; transform: translateX(-50%); width: min(440px, calc(100% - 20px)); }
  #campWin .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .camphud { position: absolute; z-index: 3; left: 50%; transform: translateX(-50%); top: calc(clamp(42px, 7cqw, 66px) + 26px); display: flex; align-items: center; gap: 8px; padding: 5px 6px 5px 10px; color: #fff; font-size: 13.5px; white-space: nowrap; }
  .camphud .ic { width: 24px; height: 24px; }
  .camphud .btn { padding: 3px 10px; font-size: 13px; background: #3a2f4c; color: #fff; border-color: #5a4a70; }
  .camphud .kbd { font-size: 10px; padding: 0 3px; }
  body.touch-on .camphud .kbd { display: none; }
  @container (max-width: 640px) { .camphud { top: 64px; font-size: 12px; gap: 6px; } .camphud .ic { display: none; } }
  .helpk { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13.5px; align-items: center; }
  .helpk .kk { white-space: nowrap; }
  .namef { display: grid; gap: 4px; margin: 4px 0 10px; font-size: 14px; }
  .namef input { font: inherit; font-size: 16px; padding: 7px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); max-width: 320px; }
  .namef input:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
  .nameerr { color: var(--accent); font-size: 13px; margin: -6px 0 8px; }
