/* LetsFish Round = jf open 粉圓 (SIL OFL 1.1) subset to the game's characters + MOE 4,808 common
   characters, renamed per the OFL Reserved Font Name clause (see fonts/OFL.txt).
   Rebuild with: npm run build:font */
@font-face {
  font-family: 'LetsFish Round';
  src: url('/fonts/letsfish-round.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
:root {
  --ink: #2b1d2e;
  --ink2: #4a3550;
  --cream: #fff6e0;
  --cream2: #ffeccb;
  --sun: #ffd23f;
  --coral: #ff5d8f;
  --sea: #3fa7ff;
  --deep: #1b4f8f;
  --mint: #5bd96a;
  --orange: #ff9f1c;
  --purple: #9b6bff;
  --red: #ff4d4d;
  --shadow: 0 5px 0 var(--ink);
  --font-title: 'Lilita One', 'LetsFish Round', 'PingFang TC', 'Microsoft JhengHei', 'Arial Black', sans-serif;
  --font: 'LetsFish Round', 'Fredoka', 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0e2a4a; color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; }
button { font-family: inherit; }
kbd { display: inline-block; min-width: 1.6em; padding: 0 0.35em; border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 6px; background: #fff; color: var(--ink); text-shadow: none; -webkit-text-stroke: 0; font-family: var(--font); font-weight: 700; font-size: 0.8em; text-align: center; line-height: 1.3; }

/* ---------------------------------------------------------------- buttons/panels */
.btn { position: relative; border: 3px solid var(--ink); border-radius: 14px; background: var(--sun); color: var(--ink); font-family: var(--font-title); font-size: 18px; letter-spacing: 0.5px; padding: 10px 18px; cursor: pointer; box-shadow: 0 4px 0 var(--ink); transition: transform .06s, box-shadow .06s, filter .15s; }
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 5px 0 var(--ink); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { filter: grayscale(0.8) brightness(0.9); cursor: not-allowed; transform: none; }
.btn.small { font-size: 14px; padding: 6px 12px; border-radius: 10px; }
.btn.ghost { background: #fff; }
.btn.coral { background: var(--coral); color: #fff; text-shadow: 0 2px 0 var(--ink); }
.btn.sea { background: var(--sea); color: #fff; text-shadow: 0 2px 0 var(--ink); }
.btn.mint { background: var(--mint); }
.btn.big { font-size: 22px; padding: 12px 26px; }
.panel { background: var(--cream); border: 4px solid var(--ink); border-radius: 22px; box-shadow: 0 8px 0 var(--ink), 0 14px 40px rgba(0,0,0,.25); }

/* ---------------------------------------------------------------- lobby */
#lobby { overflow: auto; }
#lobby-bg { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.lobby-wrap { position: relative; min-height: 100%; display: flex; flex-direction: column; align-items: center; padding: 18px 16px 10px; }
.logo { text-align: center; margin: 4px 0 14px; }
.logo h1 { margin: 0; font-family: var(--font-title); font-size: clamp(46px, 8.5vw, 96px); line-height: 1.05; letter-spacing: 4px; color: var(--sun); -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; text-shadow: 0 8px 0 var(--ink); transform: rotate(-3deg); animation: logoBob 3s ease-in-out infinite; }
.logo .l2 { color: var(--coral); display: inline-block; animation: wiggle 2.4s ease-in-out infinite; }
.logo .tagline { margin: 10px 0 0; font-weight: 700; font-size: 18px; color: #fff; text-shadow: 0 2px 0 var(--ink), 0 0 12px rgba(0,0,0,.4); }
@keyframes logoBob { 0%,100% { transform: rotate(-3deg) translateY(0); } 50% { transform: rotate(-2deg) translateY(-6px); } }
@keyframes wiggle { 0%,100% { transform: rotate(0); } 25% { transform: rotate(4deg) scale(1.04); } 75% { transform: rotate(-4deg); } }
.lobby-grid { display: grid; grid-template-columns: minmax(280px, 380px) minmax(300px, 640px); gap: 20px; width: 100%; max-width: 1060px; }
@media (max-width: 820px) { .lobby-grid { grid-template-columns: 1fr; } }
.panel h2 { margin: 0 0 8px; font-family: var(--font-title); font-weight: 400; font-size: 26px; }
.customize, .play { padding: 16px; }
#preview { width: 100%; aspect-ratio: 1; max-height: 260px; display: block; border-radius: 16px; border: 3px solid var(--ink); background: linear-gradient(#8fd3ff, #d9f3ff); margin-bottom: 10px; cursor: grab; }
.field { display: block; margin: 8px 0; }
.field > span { display: block; font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--ink2); margin-bottom: 4px; }
.field input { width: 100%; padding: 10px 12px; border: 3px solid var(--ink); border-radius: 12px; font: 600 18px var(--font); background: #fff; outline: none; }
.field input:focus { box-shadow: 0 0 0 3px var(--sun); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 2.5px solid var(--ink); border-radius: 999px; background: #fff; padding: 4px 10px; font: 600 13px var(--font); cursor: pointer; transition: transform .08s; }
.chip:hover { transform: translateY(-2px); }
.chip.on { background: var(--sun); box-shadow: 0 3px 0 var(--ink); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--ink); cursor: pointer; transition: transform .08s; }
.swatch.on { transform: scale(1.18); box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--ink); }
.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tab { flex: 1; border: 3px solid var(--ink); border-radius: 14px; background: #fff; padding: 10px; font: 400 17px var(--font-title); cursor: pointer; }
.tab.active { background: var(--sea); color: #fff; text-shadow: 0 2px 0 var(--ink); box-shadow: 0 4px 0 var(--ink); }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.hint { margin: 0 0 8px; font-size: 14px; color: var(--ink2); }
.worlds, .slots { display: flex; flex-direction: column; gap: 10px; max-height: 46vh; overflow: auto; padding: 4px 2px 8px; }
.world, .slot { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 12px 14px; box-shadow: 0 4px 0 var(--ink); }
.world h3, .slot h3 { margin: 0; font-family: var(--font-title); font-weight: 400; font-size: 21px; }
.world .meta, .slot .meta { font-size: 13px; color: var(--ink2); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; border: 2px solid var(--ink); font-weight: 700; font-size: 12px; background: var(--cream2); }
.pill.full { background: var(--red); color: #fff; }
.pill.live { background: var(--mint); }
.islandbar { display: flex; gap: 3px; margin-top: 6px; }
.islandbar i { width: 18px; height: 8px; border-radius: 4px; border: 2px solid var(--ink); background: #ddd; }
.islandbar i.on { background: var(--mint); }
.empty { text-align: center; padding: 26px 10px; border: 3px dashed var(--ink2); border-radius: 16px; color: var(--ink2); font-weight: 600; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; margin-top: 8px; color: var(--ink2); }
.controls { margin-top: 12px; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 8px 12px; }
.controls summary { cursor: pointer; font-family: var(--font-title); font-size: 17px; }
.keys { font-size: 13px; line-height: 2; }
.foot { margin-top: auto; padding-top: 14px; font-size: 13px; color: #fff; text-shadow: 0 1px 0 var(--ink); }
.foot a { color: var(--sun); }

/* ---------------------------------------------------------------- loading */
#loading { display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #3fa7ff, #12407a); }
.loader { text-align: center; color: #fff; text-shadow: 0 3px 0 var(--ink); }
.loader h2 { font: 400 40px var(--font-title); margin: 10px 0 4px; }
.loader p { font-weight: 600; margin: 4px; }
.loader .tip { opacity: 0.9; font-size: 14px; max-width: 420px; margin: 16px auto; }
.loader-fish { font-size: 90px; animation: flop 0.7s ease-in-out infinite alternate; filter: drop-shadow(0 6px 0 var(--ink)); }
@keyframes flop { from { transform: rotate(-25deg) translateY(0); } to { transform: rotate(25deg) translateY(-20px) scaleX(-1); } }

/* ---------------------------------------------------------------- game */
#game { background: #000; cursor: crosshair; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#tags, #popups { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.nametag { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; will-change: transform; }
.nt-name { font: 400 15px var(--font-title); color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; white-space: nowrap; }
.nt-hp { width: 46px; height: 7px; background: var(--ink); border-radius: 4px; padding: 1px; }
.nt-hp i { display: block; height: 100%; width: 100%; border-radius: 3px; background: var(--mint); }

.pop { position: absolute; left: 0; top: 0; font: 400 22px var(--font-title); color: #fff; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; white-space: nowrap; will-change: transform, opacity; letter-spacing: 0.5px; }
.pop.dmg { font-size: 20px; }
.pop.hs { color: #ff4d6d; font-size: 26px; }
.pop.style { color: var(--sun); font-size: 26px; }
.pop.mult { color: #ffef5a; font-size: 34px; }
.pop.money { color: #7dff7a; font-size: 28px; }
.pop.onoma { color: #ffdd33; font-size: 30px; }
.pop.bad { color: #ff8080; font-size: 22px; }
.pop.bite { color: #ffe14d; font-size: 64px; }
.pop.boss { color: #ff3355; font-size: 72px; }
.pop.big { color: #ffe14d; font-size: 48px; }
.pop.info { color: #bfe8ff; font-size: 20px; }
.pop.say { color: #fff; font: 600 16px var(--font); -webkit-text-stroke: 0; background: #fff; color: var(--ink); padding: 6px 12px; border: 3px solid var(--ink); border-radius: 14px; max-width: 320px; white-space: normal; text-align: center; }

#vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 55%, rgba(255,0,40,.55)); opacity: 0; transition: opacity .25s; }
#ink { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at 40% 45%, rgba(30,10,40,.95) 0 18%, transparent 19%), radial-gradient(circle at 62% 58%, rgba(30,10,40,.95) 0 22%, transparent 23%), radial-gradient(circle at 50% 50%, rgba(30,10,40,.85) 0 30%, transparent 55%); opacity: 0; transition: opacity .6s; }
#scope { position: absolute; inset: 0; pointer-events: none; display: none; background: radial-gradient(circle at center, transparent 0 32vmin, rgba(10,8,16,.96) 32.3vmin); }
#scope .reticle { position: absolute; left: 50%; top: 50%; width: 64vmin; height: 64vmin; transform: translate(-50%,-50%); border-radius: 50%; background: linear-gradient(transparent calc(50% - 1px), #111 calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)), linear-gradient(90deg, transparent calc(50% - 1px), #111 calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)); }
#scope.on { display: block; }

#hud { position: absolute; inset: 0; pointer-events: none; user-select: none; }
#hud > * { position: absolute; }
#topleft { left: 14px; top: 12px; display: flex; flex-direction: column; gap: 6px; }
#bank { display: inline-flex; align-items: center; gap: 8px; background: var(--cream); border: 3px solid var(--ink); border-radius: 14px; padding: 4px 14px 4px 8px; box-shadow: var(--shadow); font: 400 28px var(--font-title); }
#bank.bump { animation: bump .35s ease-out; }
#bank .coin { font-size: 24px; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.18) rotate(-3deg); background: #eaffd8; } 100% { transform: scale(1); } }
#worldinfo { font: 600 13px var(--font); color: #fff; text-shadow: 0 1px 0 var(--ink), 0 0 6px rgba(0,0,0,.6); }
#stash { display: flex; gap: 6px; flex-wrap: wrap; max-width: 300px; }
#stash .s { background: rgba(255,246,224,.92); border: 2px solid var(--ink); border-radius: 9px; padding: 1px 7px; font: 700 12px var(--font); }

#topcenter { left: 50%; top: 10px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; }
#compass { width: min(520px, 60vw); height: 30px; background: rgba(255,246,224,.9); border: 3px solid var(--ink); border-radius: 12px; overflow: hidden; position: relative; box-shadow: 0 3px 0 var(--ink); }
#compass-strip { position: absolute; inset: 0; }
#compass-strip span { position: absolute; top: 50%; transform: translate(-50%,-50%); font: 400 15px var(--font-title); white-space: nowrap; }
#compass-strip span.tick { font-size: 11px; opacity: .5; }
#compass-strip span.isl { font: 700 11px var(--font); background: var(--sea); color: #fff; padding: 0 6px; border-radius: 8px; border: 2px solid var(--ink); }
#compass-strip span.isl.locked { background: #999; }
#compass-strip span.mate { font-size: 14px; }
#compass .needle { position: absolute; left: 50%; top: -2px; width: 0; height: 0; border-left: 7px solid transparent; border-right: 7px solid transparent; border-top: 10px solid var(--coral); transform: translateX(-50%); }
#boss { width: min(560px, 70vw); text-align: center; }
.boss-name { font: 400 26px var(--font-title); color: #fff; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; }
.boss-name small { display: block; font: 600 13px var(--font); -webkit-text-stroke: 0; color: #ffe3ea; text-shadow: 0 1px 0 var(--ink); }
#boss .bar { height: 18px; background: var(--ink); border-radius: 10px; padding: 3px; margin-top: 4px; position: relative; }
#boss .bar i { display: block; height: 100%; border-radius: 7px; background: linear-gradient(#ff6b8a, #e0244a); transition: width .2s; }
#boss .bar.bored { height: 12px; width: 60%; margin: 4px auto 0; }
#boss .bar.bored i { background: linear-gradient(#d9d9d9, #a0a0a0); }
#boss .bar.bored span { position: absolute; inset: 0; font: 700 8px var(--font); color: #fff; letter-spacing: 2px; line-height: 12px; }

#quests { right: 14px; top: 12px; width: 300px; display: flex; flex-direction: column; gap: 6px; }
.quest { background: rgba(255,246,224,.94); border: 3px solid var(--ink); border-radius: 14px; padding: 7px 11px; box-shadow: 0 3px 0 var(--ink); }
.quest h4 { margin: 0; font: 400 15px var(--font-title); display: flex; justify-content: space-between; gap: 8px; }
.quest h4 small { font: 700 10px var(--font); background: var(--sun); border: 2px solid var(--ink); border-radius: 8px; padding: 0 5px; }
.quest p { margin: 2px 0 0; font-size: 13px; font-weight: 500; line-height: 1.3; }
.quest.done { opacity: .6; }
.quest.flash { animation: bump .5s; }

#banner { left: 50%; top: 22%; transform: translateX(-50%); text-align: center; animation: bannerIn 3.6s ease forwards; }
#banner h2 { margin: 0; font: 400 clamp(36px, 6vw, 70px) var(--font-title); color: var(--sun); -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink); white-space: nowrap; }
#banner p { margin: 4px 0 0; font: 700 20px var(--font); color: #fff; text-shadow: 0 2px 0 var(--ink); }
@keyframes bannerIn { 0% { opacity: 0; transform: translateX(-50%) scale(.4) rotate(-8deg); } 12% { opacity: 1; transform: translateX(-50%) scale(1.08) rotate(2deg); } 20% { transform: translateX(-50%) scale(1) rotate(0); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateX(-50%) translateY(-30px); } }

#crosshair { left: 50%; top: 50%; width: 30px; height: 30px; transform: translate(-50%,-50%); }
#crosshair i { position: absolute; background: #fff; box-shadow: 0 0 0 1.5px var(--ink); border-radius: 2px; transition: all .08s; }
#crosshair i:nth-child(1) { left: 14px; top: 0; width: 3px; height: 9px; }
#crosshair i:nth-child(2) { left: 14px; bottom: 0; width: 3px; height: 9px; }
#crosshair i:nth-child(3) { top: 14px; left: 0; width: 9px; height: 3px; }
#crosshair i:nth-child(4) { top: 14px; right: 0; width: 9px; height: 3px; }
#crosshair.dot i { opacity: 0; }
#crosshair.dot::after { content: ''; position: absolute; left: 12px; top: 12px; width: 7px; height: 7px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px var(--ink); }
#hitmarker { left: 50%; top: 50%; width: 34px; height: 34px; transform: translate(-50%,-50%) rotate(45deg); opacity: 0; background: linear-gradient(#fff,#fff) center/3px 100% no-repeat, linear-gradient(#fff,#fff) center/100% 3px no-repeat; -webkit-mask: radial-gradient(circle, transparent 7px, #000 8px); mask: radial-gradient(circle, transparent 7px, #000 8px); }
#hitmarker.on { animation: hit .25s ease-out; }
#hitmarker.hs { background: linear-gradient(#ff4d6d,#ff4d6d) center/4px 100% no-repeat, linear-gradient(#ff4d6d,#ff4d6d) center/100% 4px no-repeat; }
@keyframes hit { 0% { opacity: 1; transform: translate(-50%,-50%) rotate(45deg) scale(1.4); } 100% { opacity: 0; transform: translate(-50%,-50%) rotate(45deg) scale(1); } }
#prompt { left: 50%; top: calc(50% + 46px); transform: translateX(-50%); font: 700 16px var(--font); color: #fff; text-shadow: 0 2px 0 var(--ink), 0 0 8px rgba(0,0,0,.7); white-space: nowrap; text-align: center; }
#prompt kbd { color: var(--ink); text-shadow: none; }
#castmeter { left: calc(50% + 40px); top: calc(50% - 60px); width: 18px; height: 120px; background: var(--ink); border-radius: 10px; padding: 3px; display: flex; align-items: flex-end; }
#castmeter i { display: block; width: 100%; border-radius: 7px; background: linear-gradient(to top, var(--mint), var(--sun), var(--coral)); }
#castmeter span { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); font: 700 10px var(--font); color: #fff; text-shadow: 0 1px 0 var(--ink); margin-top: 3px; }

#fishui { left: calc(50% + 70px); top: 50%; transform: translateY(-50%); width: 230px; background: rgba(255,246,224,.95); border: 3px solid var(--ink); border-radius: 18px; padding: 10px 12px; box-shadow: 0 5px 0 var(--ink); }
#fishui.boss { background: #ffe0e6; }
#fishui.legendary { background: linear-gradient(135deg, #fff3c4, #ffe0f7, #d8f3ff); }
.fish-title { font: 400 20px var(--font-title); text-align: center; margin-bottom: 6px; }
.tension { position: relative; height: 26px; background: linear-gradient(90deg, #8ecae6 0 28%, #5bd96a 28% 78%, #ff4d4d 78%); border: 3px solid var(--ink); border-radius: 13px; }
.tension i { position: absolute; top: -6px; width: 6px; height: 32px; background: var(--ink); border-radius: 3px; transform: translateX(-50%); box-shadow: 0 0 0 2px #fff; }
.tension .warn { position: absolute; right: -10px; top: -26px; font: 400 26px var(--font-title); color: var(--red); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; opacity: 0; }
.tension .warn.on { opacity: 1; animation: wiggle .3s infinite; }
.distance { position: relative; height: 12px; margin: 12px 0 6px; background: #d9e8f0; border: 2.5px solid var(--ink); border-radius: 8px; overflow: visible; }
.distance i { display: block; height: 100%; width: 0; background: var(--sea); border-radius: 6px; }
.distance .fish-icon { position: absolute; top: 50%; transform: translate(-50%,-50%); font-size: 20px; transition: left .1s; }
.fish-help { font-size: 11px; font-weight: 600; text-align: center; line-height: 1.35; }
.fish-help .g { color: #2a9d3a; } .fish-help .r { color: #d62828; }

#toasts { left: 50%; top: 32%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.toast { background: var(--cream); border: 3px solid var(--ink); border-radius: 14px; padding: 6px 14px; font: 600 15px var(--font); box-shadow: 0 4px 0 var(--ink); animation: toastIn .25s ease-out; max-width: 520px; text-align: center; }
.toast.bad { background: #ffd6d6; }
.toast.good { background: #d9ffd9; }
.toast.boss { background: #ffd0dc; font-family: var(--font-title); font-weight: 400; font-size: 18px; }
.toast.style { background: #fff1b8; }
.toast.out { animation: toastOut .4s forwards; }
@keyframes toastIn { from { transform: scale(.6) translateY(10px); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes toastOut { to { transform: translateY(-14px); opacity: 0; } }

#bottomcenter { left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
#lure { font: 700 13px var(--font); color: #fff; text-shadow: 0 1px 0 var(--ink), 0 0 6px rgba(0,0,0,.7); min-height: 18px; }
#bars { display: flex; gap: 12px; }
#bars .bar { display: flex; align-items: center; gap: 6px; background: rgba(255,246,224,.94); border: 3px solid var(--ink); border-radius: 12px; padding: 3px 9px; box-shadow: 0 3px 0 var(--ink); }
#bars .track { width: 150px; height: 12px; background: #3a2b3e; border-radius: 7px; padding: 2px; }
#bars .track i { display: block; height: 100%; border-radius: 5px; transition: width .25s; }
#hp-fill { background: linear-gradient(#7dff7a, #2fbf4a); }
#hunger-fill { background: linear-gradient(#ffd27a, #ff9f1c); }
#bars b { font: 400 15px var(--font-title); min-width: 30px; text-align: right; }
#bars .low { animation: pulse .6s infinite alternate; }
@keyframes pulse { from { background: rgba(255,246,224,.94); } to { background: #ffb3b3; } }
#hotbar { display: flex; gap: 5px; pointer-events: auto; }
.slot-h { position: relative; width: 58px; height: 58px; background: rgba(255,246,224,.92); border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 3px 0 var(--ink); display: grid; place-items: center; transition: transform .1s; }
.slot-h.sep { margin-left: 10px; }
.slot-h.on { background: var(--sun); transform: translateY(-6px) scale(1.06); box-shadow: 0 6px 0 var(--ink); }
.slot-h.empty { opacity: .55; }
.slot-h.locked { opacity: .35; }
.slot-h img { width: 48px; height: 48px; image-rendering: auto; pointer-events: none; }
.slot-h .k { position: absolute; left: 4px; top: 1px; font: 400 12px var(--font-title); }
.slot-h .n { position: absolute; right: 4px; bottom: 1px; font: 700 11px var(--font); background: var(--ink); color: #fff; border-radius: 6px; padding: 0 4px; }
.slot-h .cook { position: absolute; left: 3px; bottom: 2px; font-size: 12px; }
.slot-h .lbl { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); white-space: nowrap; font: 400 15px var(--font-title); color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; display: none; }
.slot-h.on .lbl { display: none; }

#feed { left: 14px; bottom: 210px; width: 380px; display: flex; flex-direction: column; gap: 3px; }
.fl { font: 600 13px var(--font); color: #fff; text-shadow: 0 1px 0 var(--ink), 0 0 6px rgba(0,0,0,.8); animation: toastIn .2s; transition: opacity 1s; }
.fl.quest { color: #ffe066; } .fl.boss { color: #ff8fa3; } .fl.style { color: #ffd23f; } .fl.buy { color: #9fe0ff; } .fl.bad { color: #ffb0b0; } .fl.good { color: #b6ffb0; } .fl.admin { color: #ff9f1c; font-weight: 700; } .fl.join, .fl.leave { color: #d0d0d0; }
#chat { left: 14px; bottom: 14px; width: 380px; }
#chat-log { max-height: 150px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; }
.cl { font: 500 14px var(--font); color: #fff; text-shadow: 0 1px 0 var(--ink), 0 0 6px rgba(0,0,0,.8); transition: opacity 1s; }
.cl b { color: var(--sun); }
#chat-input { pointer-events: auto; width: 100%; margin-top: 4px; padding: 7px 10px; border: 3px solid var(--ink); border-radius: 12px; font: 600 14px var(--font); background: rgba(255,255,255,.95); display: none; outline: none; }
#chat.open #chat-input { display: block; }
#chat.open .cl { opacity: 1 !important; }
#net { right: 12px; bottom: 10px; font: 600 11px var(--font); color: #fff; text-shadow: 0 1px 0 var(--ink); text-align: right; opacity: .85; }
#click-to-play { left: 50%; top: 58%; transform: translateX(-50%); text-align: center; font: 400 26px var(--font-title); color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; animation: pulseText 1.2s ease-in-out infinite alternate; }
#click-to-play small { display: block; font: 600 14px var(--font); -webkit-text-stroke: 0; text-shadow: 0 1px 0 var(--ink); }
@keyframes pulseText { from { transform: translateX(-50%) scale(1); } to { transform: translateX(-50%) scale(1.06); } }

#ko { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(circle, rgba(60,0,30,.2), rgba(40,0,20,.65)); color: #fff; text-align: center; pointer-events: auto; }
#ko h1 { font: 400 72px var(--font-title); margin: 0; color: var(--coral); -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; animation: wiggle 1s infinite; }
#ko p { font-weight: 700; font-size: 18px; text-shadow: 0 2px 0 var(--ink); margin: 6px; }

/* ---------------------------------------------------------------- modals */
#modal { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(20,10,30,.45); pointer-events: auto; z-index: 20; }
#modal-box { width: min(760px, 94vw); max-height: 88vh; overflow: auto; padding: 18px 20px; position: relative; }
#modal-box h2 { font: 400 30px var(--font-title); margin: 0 0 4px; }
.mclose { position: absolute; right: 14px; top: 12px; }
.shop-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 10px; }
.shop-item { display: grid; grid-template-columns: 56px 1fr; gap: 4px 10px; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 8px; box-shadow: 0 3px 0 var(--ink); }
.shop-item img { width: 56px; height: 56px; grid-row: span 3; background: var(--cream2); border-radius: 10px; border: 2px solid var(--ink); }
.shop-item h4 { margin: 0; font: 400 16px var(--font-title); }
.shop-item p { margin: 0; font-size: 12px; color: var(--ink2); line-height: 1.25; }
.shop-item .buyrow { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.shop-item .price { font: 400 18px var(--font-title); color: #1f7a2e; }
.shop-item.owned { opacity: .6; }
.shop-item.poor .price { color: #c1121f; }
.shop-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.shop-head .bankline { font: 400 22px var(--font-title); }
.section-title { font: 400 18px var(--font-title); margin: 14px 0 0; color: var(--ink2); }

#dialog { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); width: min(720px, 92vw); display: flex; gap: 12px; align-items: flex-start; background: var(--cream); border: 4px solid var(--ink); border-radius: 22px; padding: 14px 16px; box-shadow: 0 7px 0 var(--ink); pointer-events: auto; z-index: 15; animation: toastIn .2s; }
.dlg-portrait { width: 84px; height: 84px; flex: none; border-radius: 16px; border: 3px solid var(--ink); background: var(--cream2) center/cover; }
.dlg-body { flex: 1; }
.dlg-name { font: 400 22px var(--font-title); }
.dlg-name small { font: 600 13px var(--font); color: var(--ink2); margin-left: 8px; }
#dlg-text { margin: 6px 0 10px; font-size: 16px; font-weight: 500; line-height: 1.4; min-height: 44px; }
.dlg-actions { display: flex; flex-wrap: wrap; gap: 8px; }

#tabmenu { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); width: min(980px, 95vw); max-height: 86vh; overflow: auto; padding: 14px 18px; z-index: 18; pointer-events: auto; }
#tabmenu h2 { margin: 0; font: 400 28px var(--font-title); }
.tm-tabs { display: flex; gap: 8px; margin: 8px 0 12px; }
.crew { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.crew .mate { background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 8px 10px; }
.crew .mate b { font: 400 17px var(--font-title); }
.dex { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.dex .card { background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 6px; text-align: center; position: relative; }
.dex .card img { width: 80px; height: 80px; }
.dex .card.unknown img { filter: brightness(0) opacity(.5); }
.dex .card h5 { margin: 2px 0 0; font: 400 13px var(--font-title); line-height: 1.1; }
.dex .card small { display: block; font-size: 10.5px; color: var(--ink2); }
.dex .card .rar { position: absolute; top: 4px; right: 5px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--ink); }
.dex-isl { font: 400 18px var(--font-title); margin: 12px 0 6px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.stats div { background: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 8px 10px; }
.stats b { display: block; font: 400 22px var(--font-title); }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; margin: 10px 0; }
.settings label { display: flex; flex-direction: column; font-weight: 700; font-size: 13px; gap: 4px; }
.settings input[type=range] { accent-color: var(--coral); }
.cannon-map { position: relative; width: 100%; aspect-ratio: 1.15; max-height: calc(100vh - 230px); min-height: 300px; background: radial-gradient(circle at 50% 50%, #4cc3ff, #1b6db8); border: 4px solid var(--ink); border-radius: 18px; overflow: hidden; margin-top: 8px; }
.cannon-map .isle { position: absolute; transform: translate(-50%,-50%); text-align: center; cursor: pointer; }
.cannon-map .isle .blob { margin: 0 auto; border-radius: 50%; border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); transition: transform .12s; }
.cannon-map .isle:hover .blob { transform: scale(1.1); }
.cannon-map .isle span { display: block; margin-top: 4px; font: 400 15px var(--font-title); color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; white-space: nowrap; }
.cannon-map .isle.locked { cursor: not-allowed; filter: grayscale(1) brightness(.7); }
.cannon-map .isle.here { cursor: default; }
.cannon-map .isle.here .blob { animation: isle-here 1.2s ease-in-out infinite; box-shadow: 0 4px 0 var(--ink), 0 0 0 6px rgba(255,255,255,.55); }
@keyframes isle-here { 50% { transform: scale(1.08); } }
.cannon-map .isle.poor { cursor: not-allowed; }
.cannon-map .isle.poor .blob { filter: saturate(.45) brightness(.85); }
.cannon-map .isle.poor span { color: #ffb3b3; }
.cannon-map svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.credits { text-align: center; }
.credits h1 { font: 400 54px var(--font-title); color: var(--sun); -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; margin: 0; }

.name-hint { margin: -6px 2px 10px; font-size: 12px; line-height: 1.45; color: var(--ink); opacity: .65; }

/* ======================= touch screens (landscape only) ======================= */
body.touch #game { cursor: default; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.touch { overscroll-behavior: none; }
#touch { position: absolute; inset: 0; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#touch.blocked { pointer-events: none; opacity: .3; }
.tc-stick { position: absolute; width: 0; height: 0; pointer-events: none; }
.tc-stick.idle { left: calc(env(safe-area-inset-left) + 96px); top: calc(100% - 96px); opacity: .5; }
.tc-base { position: absolute; width: 124px; height: 124px; left: -62px; top: -62px; border-radius: 50%; background: rgba(255,255,255,.18); border: 3px solid rgba(255,255,255,.6); box-shadow: 0 0 0 3px rgba(43,29,46,.35); }
.tc-knob { position: absolute; left: 0; top: 0; width: 58px; height: 58px; border-radius: 50%; background: rgba(255,246,224,.92); border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink); transform: translate(-50%,-50%); }
.tc-btn { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 50%; background: rgba(255,246,224,.85); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); color: var(--ink); font: 400 24px var(--font-title); padding: 0; line-height: 1; }
.tc-btn small { font: 700 10px var(--font); margin-top: 2px; }
.tc-btn.down { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); background: var(--sun); }
.tc-btn.dim { opacity: .45; }
.tc-btn.ready { background: var(--mint); animation: tcPulse .8s ease-in-out infinite alternate; }
@keyframes tcPulse { to { box-shadow: 0 4px 0 var(--ink), 0 0 0 8px rgba(91,217,106,.5); } }
/* an arc of buttons around the big use button, clear of the hotbar */
.tc-use { width: 88px; height: 88px; right: calc(env(safe-area-inset-right) + 20px); bottom: 20px; font-size: 34px; }
.tc-jump { width: 62px; height: 62px; right: calc(env(safe-area-inset-right) + 118px); bottom: 14px; }
.tc-act { width: 58px; height: 58px; right: calc(env(safe-area-inset-right) + 104px); bottom: 94px; }
.tc-aim { width: 54px; height: 54px; right: calc(env(safe-area-inset-right) + 22px); bottom: 124px; font-size: 20px; }
.tc-reload { width: 48px; height: 48px; right: calc(env(safe-area-inset-right) + 170px); bottom: 150px; font-size: 18px; }
.tc-throw { width: 48px; height: 48px; right: calc(env(safe-area-inset-right) + 100px); bottom: 170px; font-size: 18px; }
.tc-top { position: absolute; top: calc(env(safe-area-inset-top) + 6px); right: calc(env(safe-area-inset-right) + 6px); display: flex; gap: 4px; }
.tc-mini { width: 36px; height: 36px; border-radius: 11px; background: rgba(255,246,224,.88); border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink); font-size: 16px; padding: 0; line-height: 1; }
.tc-mini.down { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); background: var(--sun); }

/* HUD squeezed around the thumbs */
body.touch #topleft { left: calc(env(safe-area-inset-left) + 10px); top: 8px; transform: scale(.82); transform-origin: top left; }
body.touch #topcenter { top: 6px; }
body.touch #compass { width: min(220px, 28vw); height: 24px; }
body.touch #topcenter { left: 44%; }
body.touch #quests { left: calc(env(safe-area-inset-left) + 10px); right: auto; top: 96px; width: 230px; transform: scale(.8); transform-origin: top left; }
body.touch #quests > :not(:first-child) { display: none; }
body.touch #bottomcenter { bottom: 6px; gap: 4px; }
body.touch #bars { gap: 6px; }
body.touch #bars .bar { padding: 1px 6px; }
body.touch #bars .track { width: 72px; height: 10px; }
body.touch #bars b { font-size: 13px; min-width: 24px; }
body.touch #hotbar { gap: 2px; }
body.touch .slot-h { width: 34px; height: 34px; border-radius: 9px; border-width: 2px; box-shadow: 0 2px 0 var(--ink); }
body.touch .slot-h.on { transform: translateY(-3px) scale(1.06); box-shadow: 0 4px 0 var(--ink); }
body.touch .slot-h.sep { margin-left: 4px; }
body.touch .slot-h img { width: 26px; height: 26px; }
body.touch .slot-h .n { font-size: 9px; padding: 0 3px; }
body.touch #lure kbd { display: none; }
body.touch .slot-h .k, body.touch .slot-h .lbl { display: none; }
body.touch #feed { left: calc(env(safe-area-inset-left) + 10px); bottom: auto; top: 46%; width: 260px; transform: scale(.85); transform-origin: top left; }
body.touch #chat { left: 50%; bottom: auto; top: 70px; transform: translateX(-50%); width: min(420px, 60vw); }
body.touch #chat:not(.open) { display: none; }
body.touch #prompt { font-size: 14px; top: calc(50% + 34px); }
body.touch #net { right: auto; left: calc(env(safe-area-inset-left) + 10px); bottom: 2px; font-size: 9px; }
body.touch #dialog { bottom: 12px; }

/* ======================= emote wheel ======================= */
#emote-wheel { position: absolute; inset: 0; z-index: 25; background: radial-gradient(circle, rgba(20,10,30,.2), rgba(20,10,30,.55)); pointer-events: auto; touch-action: none; }
#emote-wheel .ew-center { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); width: 118px; height: 118px; border-radius: 50%; background: var(--cream); border: 4px solid var(--ink); box-shadow: 0 5px 0 var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; }
#emote-wheel .ew-center b { font: 400 18px var(--font-title); }
#emote-wheel .ew-center small { font: 700 10px var(--font); opacity: .6; padding: 2px 10px 0; }
.ew-item { --r: min(150px, 34vmin); position: absolute; left: 50%; top: 50%; width: 66px; height: 66px; margin: -33px 0 0 -33px; transform: translate(calc(var(--x) * var(--r)), calc(var(--y) * var(--r))); border-radius: 50%; background: rgba(255,246,224,.96); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); font-size: 32px; display: grid; place-items: center; padding: 0; cursor: pointer; transition: transform .1s, background .1s; }
.ew-item i { position: absolute; right: 5px; bottom: 2px; font: 400 11px var(--font-title); font-style: normal; opacity: .55; }
.ew-item.on { background: var(--sun); transform: translate(calc(var(--x) * var(--r)), calc(var(--y) * var(--r))) scale(1.16); }
body.touch .ew-item i { display: none; }

/* ======================= emoji bubbles over players ======================= */
.emoji-bubble { position: absolute; left: 0; top: 0; pointer-events: none; will-change: transform; }
.emoji-bubble span { position: relative; display: block; font-size: 34px; line-height: 1; padding: 6px 9px; background: rgba(255,246,224,.96); border: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 4px 0 var(--ink); animation: emojiPop 2.6s ease-out forwards; }
.emoji-bubble span::after { content: ''; position: absolute; left: 50%; bottom: -13px; transform: translateX(-50%); border: 8px solid transparent; border-top-color: var(--ink); }
@keyframes emojiPop {
  0% { transform: scale(0) rotate(-20deg); opacity: 0; }
  12% { transform: scale(1.25) rotate(8deg); opacity: 1; }
  22% { transform: scale(1) rotate(0); }
  80% { transform: translateY(-6px); opacity: 1; }
  100% { transform: translateY(-18px); opacity: 0; }
}

/* ======================= rotate your phone ======================= */
#rotate { display: none; }
@media (orientation: portrait) {
  body.touch #rotate { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: linear-gradient(#5ec8ff, #1b6db8); color: #fff; text-align: center; font: 400 26px var(--font-title); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
  body.touch #rotate p { margin: 0; }
  body.touch #rotate .phone { font-size: 76px; -webkit-text-stroke: 0; animation: rotatePhone 1.8s ease-in-out infinite; }
  body.touch #rotate small { font: 700 14px var(--font); -webkit-text-stroke: 0; text-shadow: 0 1px 0 var(--ink); }
}
@keyframes rotatePhone { 0%, 25% { transform: rotate(0); } 55%, 100% { transform: rotate(-90deg); } }

/* ======================= short landscape screens: compact lobby ======================= */
@media (max-height: 520px) {
  .lobby-wrap { padding: 6px 10px; }
  .logo { margin: 0 0 4px; }
  .logo h1 { font-size: 34px; letter-spacing: 2px; text-shadow: 0 3px 0 var(--ink); -webkit-text-stroke: 3px var(--ink); }
  .logo .tagline { display: none; }
  #preview { max-height: 120px; }
}
/* landscape phones: keep character and world list side by side, each scrolling on its own */
@media (max-height: 520px) and (orientation: landscape) {
  .lobby-grid { grid-template-columns: minmax(220px, 300px) 1fr; gap: 10px; }
  .lobby-grid > .panel { max-height: calc(100vh - 60px); overflow: auto; padding: 10px 12px; }
  .panel h2 { font-size: 20px; margin-bottom: 4px; }
}
