* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b1530; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }
button, select, input { font: inherit; }

#labels, #npc-tags { position: fixed; inset: 0; z-index: var(--ui-z-world); pointer-events: none; overflow: hidden; }
.label, .npc-tag { position: absolute; left: 0; top: 0; white-space: nowrap; will-change: transform; }
.label.building, .label.poi { font-weight: 650; color: var(--ui-paper); text-shadow: 0 0 2px rgba(0, 14, 36, 0.95), 0 1px 3px rgba(0, 14, 36, 0.85), 0 0 10px rgba(0, 14, 36, 0.45); }
.label.building { font-size: 12.5px; }
.label.poi { font-size: var(--ui-t-xs); font-weight: 750; color: #ffd36b; }
.label.player, .npc-tag.name { padding: 2px 9px; border: var(--ui-border); border-radius: var(--ui-r-pill); background: var(--ui-paper-a); color: var(--ui-navy); font-weight: 750; box-shadow: var(--ui-shadow-sm); }
.label.player { font-size: 13px; border-color: var(--ui-navy); box-shadow: inset 0 -2px 0 var(--ui-gold), var(--ui-shadow-sm); }
.npc-tag.name { font-size: var(--ui-t-xs); font-weight: 650; padding: 1px 8px; }
.label.bubble, .npc-tag.say { white-space: normal; width: max-content; max-width: 220px; overflow-wrap: anywhere; padding: 5px 10px; border: var(--ui-border); border-radius: 12px; background: #fffdf8; color: var(--ui-ink); font-size: 13px; font-weight: 500; line-height: 1.3; text-align: center; box-shadow: var(--ui-shadow-sm); }
.label.bubble::after, .npc-tag.say::after { content: ''; position: absolute; left: 50%; bottom: -7px; width: 10px; height: 10px; margin-left: -5px; background: #fffdf8; border: var(--ui-border); border-top: 0; border-left: 0; transform: rotate(45deg); }
.npc-tag.prompt { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px; border: var(--ui-border); border-radius: var(--ui-r-pill); background: var(--ui-paper-a); color: var(--ui-navy); font-size: var(--ui-t-sm); font-weight: 650; box-shadow: var(--ui-shadow-sm); }

#hud { position: fixed; inset: 0; z-index: var(--ui-z-hud); pointer-events: none; }
#hud > * { position: absolute; }
#brand { top: 16px; left: 18px; font-weight: 800; font-size: 20px; letter-spacing: -0.02em; }
#brand span { font-weight: 300; margin-left: 2px; }
#gear { pointer-events: auto; top: 14px; right: 16px; color: var(--ui-navy); }
#gear svg { transition: transform 0.3s ease; }
body.menu-open #gear { background: var(--ui-gold); }
body.menu-open #gear svg { transform: rotate(60deg); }
#clock { pointer-events: auto; top: 15px; right: 60px; height: 34px; font-size: var(--ui-t-md); font-weight: 500; }
#online { top: 58px; right: 18px; }
#run { top: 56px; left: 16px; width: 240px; font-size: 13px; }
.run-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; color: var(--ui-navy); }
.run-head b { font-variant-numeric: tabular-nums; font-size: var(--ui-t-lg); }
#run-list { margin: 6px 0; }
#run-list li { padding: 3px 2px; gap: 8px; }
#run-list li::before { content: ''; width: 9px; height: 9px; flex: none; border: 1.5px solid var(--ui-line); border-radius: 50%; }
#run-list li.done { color: var(--ui-ink-3); text-decoration: line-through; }
#run-list li.done::before { background: var(--ui-gold); }
#run-foot { font-size: var(--ui-t-xs); color: var(--ui-ink-2); margin-bottom: 6px; }
#location { left: 18px; bottom: 18px; display: flex; flex-direction: column; max-width: 46vw; }
#location b { font-size: 18px; }
#location span { font-size: var(--ui-t-sm); opacity: 0.9; }
#prompt { left: 50%; bottom: 70px; transform: translateX(-50%); }
#toast { top: 64px; left: 50%; transform: translateX(-50%); max-width: 80vw; z-index: 1; }
#minimap { right: 18px; bottom: 30px; width: 180px; height: 180px; border-radius: 50%; border: 5px solid var(--ui-paper); box-shadow: 0 0 0 1.5px var(--ui-line), var(--ui-shadow); }
#speedo { right: 214px; bottom: 34px; display: flex; flex-direction: column; align-items: flex-end; line-height: 1; opacity: 0; transition: opacity 0.4s, transform 0.22s ease; }
#speedo.on { opacity: 1; }
#speedo b { font-size: var(--ui-t-xl); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
#speedo span { margin-top: 3px; font-size: var(--ui-t-xs); font-weight: 650; opacity: 0.9; }
#players { top: 108px; left: 50%; transform: translateX(-50%); width: min(340px, 90vw); max-height: calc(100vh - 300px); overflow: hidden; font-size: 13px; }
.pl-head { display: flex; justify-content: space-between; align-items: baseline; }
.pl-head b { font-size: var(--ui-t-md); font-weight: 800; color: var(--ui-navy); }
.pl-head span, .pl-room, .pl-foot { font-size: var(--ui-t-xs); color: var(--ui-ink-2); }
.pl-room { margin: 1px 0 6px; }
#players li b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
#players li span { font-size: var(--ui-t-sm); color: var(--ui-ink-2); font-variant-numeric: tabular-nums; }
#players li.self { background: var(--ui-gold-soft); }
#players li.self b { color: var(--ui-navy); font-weight: 800; }
#players li.self span { color: var(--ui-gold-ink); font-weight: 700; }
.pl-foot { margin-top: 6px; }
#fps { top: 44px; left: 18px; font: 600 11px ui-monospace, monospace; }
#attribution { right: 18px; bottom: 8px; font-size: 10px; pointer-events: auto; }
#attribution a { color: inherit; }
#npc-card { left: 50%; bottom: 116px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 240px; max-width: 80vw; text-align: center; }
#npc-card b { color: var(--ui-navy); font-size: var(--ui-t-lg); font-weight: 800; }
#npc-card span { font-size: var(--ui-t-sm); color: var(--ui-ink-2); }
#npc-card em { font-style: normal; font-size: 13px; margin-top: 2px; }

#chat { left: 16px; bottom: 66px; width: min(420px, 60vw); display: flex; flex-direction: column; gap: 6px; }
#chat-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; max-height: 32vh; overflow: hidden; }
#chat-log li { max-width: 100%; padding: 3px 10px; border: 1.5px solid rgba(251, 247, 238, 0.16); border-radius: var(--ui-r); background: var(--ui-shade); color: var(--ui-on-shade); font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; transition: opacity 1.2s ease; }
#chat-log li b { font-weight: 750; }
#chat-log li.self b { color: var(--ui-gold); }
#chat-log li.system { font-style: italic; background: rgba(12, 22, 42, 0.55); color: rgba(251, 247, 238, 0.85); }
#chat-log li.old { opacity: 0; }
#chat-input { display: none; pointer-events: auto; width: 100%; box-shadow: 0 0 0 3px var(--ui-gold-soft), var(--ui-shadow-sm); border-color: var(--ui-gold-ink); }
#chat.open #chat-input { display: block; }
#chat.open #chat-log { pointer-events: auto; overflow-y: auto; }
#chat.open #chat-log li { opacity: 1; transition: none; }

#pb, #pb-screen { position: fixed; inset: 0; pointer-events: none; }
#pb-cross { position: absolute; left: 50%; top: 50%; --s: 6px; }
#pb-cross i { position: absolute; background: var(--ui-paper); border-radius: 1px; box-shadow: 0 0 0 1px rgba(0, 20, 45, 0.6); transition: opacity 0.12s; }
#pb-cross i:nth-child(1), #pb-cross i:nth-child(2) { width: 2px; height: 8px; left: -1px; }
#pb-cross i:nth-child(3), #pb-cross i:nth-child(4) { width: 8px; height: 2px; top: -1px; }
#pb-cross i:nth-child(1) { top: calc(-8px - var(--s)); }
#pb-cross i:nth-child(2) { top: var(--s); }
#pb-cross i:nth-child(3) { left: calc(-8px - var(--s)); }
#pb-cross i:nth-child(4) { left: var(--s); }
#pb-cross b { position: absolute; width: 4px; height: 4px; left: -2px; top: -2px; border-radius: 50%; background: var(--ui-gold); box-shadow: 0 0 0 1px rgba(0, 20, 45, 0.6); }
#pb.ads #pb-cross i { opacity: 0; }
#pb-hit { position: absolute; left: 50%; top: 50%; opacity: 0; }
#pb-hit i { position: absolute; width: 3px; height: 10px; left: -1.5px; top: -5px; background: var(--ui-paper); border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 20, 45, 0.5); }
#pb-hit i:nth-child(1) { transform: rotate(45deg) translateY(-13px); }
#pb-hit i:nth-child(2) { transform: rotate(135deg) translateY(-13px); }
#pb-hit i:nth-child(3) { transform: rotate(225deg) translateY(-13px); }
#pb-hit i:nth-child(4) { transform: rotate(315deg) translateY(-13px); }
#pb-hit.out i { background: #ff2d6f; }
#pb-hit.on { animation: pb-hit 0.32s ease-out; }
@keyframes pb-hit { from { opacity: 1; transform: scale(1.35); } to { opacity: 0; transform: scale(1); } }
#pb-panel { position: absolute; right: 18px; bottom: 228px; width: 180px; padding: 10px 12px; border: var(--ui-border); border-radius: var(--ui-r-lg); background: var(--ui-paper-a); color: var(--ui-ink); box-shadow: var(--ui-shadow-sm); backdrop-filter: blur(8px); transition: transform 0.22s ease; }
.pb-ammo { display: flex; align-items: baseline; gap: 6px; color: var(--ui-navy); }
.pb-ammo b { font-size: 30px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.pb-ammo span { font-size: 13px; color: var(--ui-ink-2); font-variant-numeric: tabular-nums; }
#pb.empty .pb-ammo b { color: var(--ui-red); }
.pb-bar, .pb-health { height: 8px; margin: 6px 0; border: 1.5px solid var(--ui-line); border-radius: var(--ui-r-pill); background: var(--ui-paper-2); overflow: hidden; }
.pb-bar { height: 6px; }
#pb-reload { height: 100%; width: 0; background: var(--ui-gold); }
#pb-health { height: 100%; width: 100%; background: var(--ui-green); transition: width 0.15s; }
#pb-health.low { background: var(--ui-red); }
.pb-stats { display: flex; justify-content: space-between; font-size: var(--ui-t-sm); }
.pb-stats b { color: var(--ui-navy); }
.pb-keys { margin-top: 6px; font-size: var(--ui-t-xs); line-height: 1.7; color: var(--ui-ink-2); }
.pb-keys kbd { height: 18px; min-width: 18px; margin: 0 1px; padding: 0 4px; font-size: 10px; border-bottom-width: 2px; }
.pb-weapons { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 6px; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--ui-line-soft); font-size: var(--ui-t-xs); }
.pb-weapons span { display: flex; align-items: center; gap: 4px; padding: 1px 4px 1px 1px; border-radius: var(--ui-r-sm); color: var(--ui-ink-3); white-space: nowrap; }
.pb-weapons span.on { background: var(--ui-gold-soft); color: var(--ui-navy); font-weight: 750; }
.pb-weapons kbd { height: 17px; min-width: 17px; margin: 0; padding: 0 3px; font-size: 10px; border-bottom-width: 2px; }
.pb-weapons span.on kbd { background: var(--ui-gold); }
#pb-charge { position: absolute; left: 50%; top: 50%; width: 32px; height: 32px; margin: -16px 0 0 -16px; border-radius: 50%; opacity: 0; transition: opacity 0.1s; background: conic-gradient(var(--ui-paper) calc(var(--c, 0) * 1turn), rgba(0, 20, 45, 0.3) 0); -webkit-mask: radial-gradient(circle, transparent 11.5px, #000 12px); mask: radial-gradient(circle, transparent 11.5px, #000 12px); filter: drop-shadow(0 0 1px rgba(0, 20, 45, 0.8)); }
#pb-charge.on { opacity: 1; }
#pb-charge.full { background: var(--ui-gold); }
.pb-splat { position: absolute; inset: 0; opacity: 0.85; transition: opacity 2.2s ease-in 0.3s; filter: blur(1px); }
.pb-splat.fade { opacity: 0; }

#intro { position: fixed; inset: 0; z-index: var(--ui-z-top); display: grid; place-items: center; background: rgba(0, 20, 45, 0.35); backdrop-filter: blur(3px); }
.intro { width: min(520px, 92vw); padding: 30px 32px 22px; text-align: center; }
.intro h1 { display: inline-block; margin: 0 0 8px; padding-bottom: 6px; font-size: 44px; color: var(--ui-navy); letter-spacing: -0.03em; background: linear-gradient(var(--ui-gold), var(--ui-gold)) center bottom / 72% 5px no-repeat; border-radius: 2px; }
.intro h1 span { font-weight: 300; margin-left: 2px; }
.intro p { margin: 8px 0; color: var(--ui-ink-2); }
.intro #play { margin: 14px 0 10px; padding: 11px 38px; font-size: 18px; }
.intro .keys-hint { font-size: 13px; line-height: 2; }
.intro .tiny { font-size: var(--ui-t-xs); color: var(--ui-ink-3); }

#menu, #character { position: fixed; top: 64px; right: 16px; z-index: var(--ui-z-panel); width: var(--ui-panel-w); display: flex; }
#menu { bottom: 16px; }
#character { max-height: calc(100vh - 80px); }
#character .ui-panel { flex: 1; }
#menu .ui-panel { flex: 1; }
#menu .ui-select { width: 150px; }
.name-field { display: flex; gap: 6px; align-items: center; }
.name-field .ui-input { width: 150px; }
#character .ui-input { width: 170px; }
#character .ui-row.stack { align-items: flex-start; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatches button { width: 26px; height: 26px; padding: 0; border-radius: 50%; background: var(--c); border: 1.5px solid var(--ui-line); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.75); }
.swatches button:hover { background: var(--c); }
.swatches button.on { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.9), 0 0 0 2.5px var(--ui-gold); }

#map { position: fixed; inset: 0; z-index: var(--ui-z-overlay); display: grid; place-items: center; background: rgba(0, 20, 45, 0.3); }
.map-panel { position: relative; width: min(1180px, 92vw); height: min(820px, 86vh); overflow: hidden; padding: 0; background: #9cc5dc; animation: map-in 0.16s ease-out; }
@keyframes map-in { from { opacity: 0; transform: scale(0.97); } }
#map-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.map-bar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; padding: 8px; }
.map-bar .ui-input { width: min(320px, 50vw); }
.map-hint { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; }
.map-hint kbd { height: 18px; min-width: 18px; font-size: 10px; }
#map-tip { position: absolute; left: 0; top: 0; }

#minimap, #online, #attribution { transition: transform 0.22s ease; }
body.menu-open #minimap, body.menu-open #speedo, body.menu-open #online, body.menu-open #attribution, body.menu-open #pb-panel,
body:has(#character:not([hidden])) #minimap, body:has(#character:not([hidden])) #online, body:has(#character:not([hidden])) #attribution { transform: translateX(calc(-1 * var(--ui-panel-w) - 16px)); }
body.menu-open #toast, body.menu-open #prompt, body.menu-open #players, body.menu-open #npc-card, body:has(#character:not([hidden])) #toast { left: calc(50% - (var(--ui-panel-w) + 16px) / 2); }
@media (max-width: 720px) { body.menu-open #minimap, body.menu-open #speedo, body.menu-open #pb-panel, body.menu-open #attribution, body:has(#character:not([hidden])) #minimap { visibility: hidden; } }
body.ui-off #labels, body.ui-off #npc-tags, body.ui-off #hud > :not(#chat):not(#players), body.ui-off #chat:not(.open) { display: none !important; }
body.no-labels .label.building, body.no-labels .label.poi, body.no-labels .label.player, body.no-labels .npc-tag.name,
body.no-lbl-buildings .label.building, body.no-lbl-places .label.poi, body.no-lbl-people .label.player, body.no-lbl-people .npc-tag.name { display: none !important; }
#online.alone .ui-dot { background: var(--ui-ink-3); }
#fish-power { left: 50%; bottom: 112px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 7px 14px; border-radius: 999px; background: var(--ui-paper-a); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2); font-size: 12px; font-weight: 700; color: var(--ui-navy); text-transform: uppercase; letter-spacing: 0.08em; }
#fish-power div { width: 180px; height: 8px; border-radius: 4px; background: rgba(0, 33, 69, 0.12); overflow: hidden; }
#fish-power i { display: block; height: 100%; width: 0; border-radius: 4px; background: linear-gradient(90deg, #7fc8a9, var(--ui-gold) 70%, #e8743b); }
#fish-bite { left: 0; top: 0; }
#fish-bite b { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--ui-gold); color: var(--ui-navy); border: 3px solid #fff; font-size: 22px; font-weight: 900; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3); animation: fish-bite 0.32s ease-in-out infinite alternate; }
@keyframes fish-bite { from { transform: scale(0.9) rotate(-6deg); } to { transform: scale(1.12) rotate(6deg); } }
#fish-reel { left: calc(50% + 110px); top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 14px; background: var(--ui-paper-a); box-shadow: 0 4px 18px rgba(0, 0, 0, 0.22); }
.fr-hint { font-size: 12px; color: var(--ui-navy); white-space: nowrap; }
#fish-reel.tier2 .fr-hint { color: #c8102e; }
#fish-reel.tier3 .fr-hint { color: #b07800; }
#fish-reel.tier3 { box-shadow: 0 0 0 3px var(--ui-gold), 0 4px 22px rgba(242, 169, 0, 0.5); }
.fr-body { display: flex; gap: 8px; }
.fr-track { position: relative; width: 42px; height: 250px; border-radius: 11px; border: 3px solid #fff; background: linear-gradient(#8ccbe0, #2f7896 60%, #1d5470); box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.25); overflow: hidden; }
.fr-zone { position: absolute; left: 3px; right: 3px; border-radius: 8px; background: rgba(168, 230, 160, 0.45); border: 2px solid rgba(255, 255, 255, 0.75); }
.fr-zone.on { background: rgba(140, 230, 120, 0.75); border-color: #fff; }
.fr-fish { position: absolute; left: 50%; transform: translate(-50%, 50%); line-height: 0; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35)); }
.fr-prog { position: relative; width: 10px; height: 256px; border-radius: 5px; background: rgba(0, 33, 69, 0.12); overflow: hidden; }
.fr-prog i { position: absolute; left: 0; right: 0; bottom: 0; height: 0; border-radius: 5px; }
.fr-keys { font-size: 11px; color: #5b6570; white-space: nowrap; }
#fish-card { left: 50%; bottom: 118px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 10px 18px 10px 10px; min-width: 300px; max-width: min(460px, 90vw); border-radius: 14px; background: var(--ui-paper-a); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25); color: var(--ui-ink); }
#fish-card.pop { animation: fish-pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes fish-pop { from { transform: translateX(-50%) scale(0.8); opacity: 0; } }
#fish-card canvas { flex: none; width: 96px; height: 72px; border-radius: 10px; background: radial-gradient(circle, #ffffff, #e6eef3); }
.fc-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fc-tier { align-self: flex-start; padding: 1px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: #fff; background: #7a8290; }
#fish-card.tier1 .fc-tier { background: #2e7d4f; }
#fish-card.tier2 .fc-tier { background: var(--ui-navy); }
#fish-card.tier3 .fc-tier { background: var(--ui-gold); color: var(--ui-navy); }
#fish-card.tier3 { box-shadow: 0 0 0 3px var(--ui-gold), 0 6px 28px rgba(242, 169, 0, 0.55); }
#fish-card.junk .fc-tier { background: #9a6c3c; }
#fish-card.lost .fc-tier { background: #c8102e; }
#fish-card.lost canvas { opacity: 0.7; }
.fc-text b { font-size: 17px; color: var(--ui-navy); line-height: 1.2; }
.fc-size { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.fc-note { font-size: 12px; color: #5b6570; font-style: italic; }
.fc-note:empty { display: none; }
.fc-best { font-size: 11px; font-weight: 700; color: #9a6c00; }
