:root {
  color-scheme: dark;
  --bg: #061016;
  --panel: rgba(11, 27, 35, 0.92);
  --panel-2: rgba(15, 38, 48, 0.9);
  --line: rgba(126, 214, 214, 0.2);
  --text: #eef8f4;
  --muted: #9eb8b4;
  --accent: #58d6ba;
  --accent-2: #d9b861;
  --danger: #ff6e6e;
  --good: #70e29d;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.36);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: radial-gradient(circle at top, #102c38 0, #061016 52%, #03080b 100%); color: var(--text); }
body { min-height: 100vh; overflow-x: hidden; }
button, input, select { font: inherit; }
button { border: 1px solid rgba(109, 215, 201, 0.28); background: linear-gradient(180deg, rgba(38, 95, 100, 0.9), rgba(14, 49, 57, 0.95)); color: var(--text); border-radius: 10px; padding: 0.65rem 0.85rem; cursor: pointer; transition: transform .15s ease, border-color .15s ease, filter .15s ease; }
button:hover { border-color: rgba(108, 255, 228, 0.72); filter: brightness(1.1); transform: translateY(-1px); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
button.primary { background: linear-gradient(180deg, #58d6ba, #247a71); color: #031311; font-weight: 800; }
button.wide { width: 100%; }
button.small-button { padding: .35rem .55rem; font-size: .8rem; }
input, select { width: 100%; padding: .66rem .7rem; border-radius: 9px; border: 1px solid rgba(109, 215, 201, 0.22); background: rgba(2, 13, 18, 0.82); color: var(--text); outline: none; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(88, 214, 186, .12); }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { display: grid; grid-template-columns: minmax(250px, 1fr) auto auto; gap: 1rem; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid var(--line); background: rgba(4, 15, 20, .92); backdrop-filter: blur(18px); position: sticky; top: 0; z-index: 20; }
.brand-block { display: flex; gap: .8rem; align-items: center; min-width: 0; }
.brand-mark { width: 48px; height: 48px; border-radius: 50% 44% 58% 46%; display: grid; place-items: center; font-size: .72rem; font-weight: 900; letter-spacing: .08em; background: radial-gradient(circle at 35% 30%, #bbffe8 0 7%, #48c9b0 8% 26%, #1b635f 27% 60%, #081d24 61%); box-shadow: inset -8px -10px 20px rgba(0,0,0,.35), 0 0 24px rgba(65, 216, 186, .22); }
.brand-block h1 { margin: 0; font-size: clamp(1.12rem, 2vw, 1.5rem); }
.brand-block p { margin: .1rem 0 0; color: var(--muted); font-size: .78rem; }
.version { color: var(--accent-2); margin-left: .35rem; }
.top-stats { display: flex; gap: .55rem; }
.top-stats > div { min-width: 72px; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 10px; background: rgba(9, 28, 36, .8); text-align: center; }
.top-stats span { display: block; color: var(--muted); font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; }
.top-stats strong { font-size: .92rem; }
.top-actions { display: flex; gap: .45rem; }
.icon-button { width: 42px; padding-inline: 0; }

.main-layout { display: grid; grid-template-columns: minmax(220px, 270px) minmax(0, 1fr) minmax(230px, 290px); gap: .75rem; padding: .75rem; flex: 1; min-height: 0; }
.panel { border: 1px solid var(--line); background: var(--panel); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.left-rail, .right-rail { padding: .85rem; overflow-y: auto; max-height: calc(100vh - 86px); }
.left-rail section, .right-rail section { padding-bottom: .95rem; margin-bottom: .95rem; border-bottom: 1px solid rgba(126, 214, 214, .12); }
.left-rail section:last-child, .right-rail section:last-child { border-bottom: 0; margin-bottom: 0; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.section-heading h2 { margin: 0; font-size: .95rem; letter-spacing: .02em; }
.field-label { display: block; color: var(--muted); font-size: .7rem; margin: .5rem 0 .25rem; text-transform: uppercase; letter-spacing: .08em; }
.inline-field { display: grid; grid-template-columns: 1fr auto; gap: .4rem; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: .22rem .48rem; font-size: .67rem; font-weight: 800; background: rgba(92, 211, 185, .13); color: #a8f4df; border: 1px solid rgba(92, 211, 185, .22); }
.badge.offline { color: #c6d0d0; background: rgba(170, 190, 190, .08); }
.badge.danger { color: #ffd0d0; background: rgba(255, 91, 91, .12); border-color: rgba(255, 91, 91, .3); }
.safe-space { font-size: .67rem; color: #a9e8d8; }
.muted { color: var(--muted); font-size: .8rem; line-height: 1.45; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.game-stage { min-width: 0; display: flex; flex-direction: column; min-height: calc(100vh - 90px); position: relative; }
.stage-toolbar { min-height: 56px; padding: .65rem .8rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); background: rgba(6, 21, 27, .9); }
.stage-toolbar strong { display: block; font-size: .95rem; }
.stage-toolbar span { color: var(--muted); font-size: .72rem; }
.mode-tabs { display: flex; gap: .35rem; }
.mode-tabs button { padding: .4rem .65rem; font-size: .75rem; background: rgba(14, 42, 50, .8); }
.mode-tabs button.active { border-color: var(--accent); color: #bffff0; }
.view { display: none; position: relative; flex: 1; min-height: 0; }
.view.active { display: block; }
#worldCanvas, #fishingGL, #fishingOverlay { width: 100%; height: 100%; min-height: 560px; display: block; background: #07161a; touch-action: none; }
.fishing-view canvas { position: absolute; inset: 0; }
.fishing-view { min-height: 560px; overflow: hidden; }
.fishing-hud { position: absolute; inset: auto 0 0; padding: .75rem; display: grid; grid-template-columns: auto 1fr auto; gap: .7rem; align-items: center; background: linear-gradient(180deg, transparent, rgba(2,8,11,.95) 45%); z-index: 2; }
#fishingStatus { text-align: center; font-weight: 700; text-shadow: 0 2px 8px #000; }
.world-prompt { position: absolute; left: 50%; bottom: 72px; transform: translateX(-50%); padding: .55rem .85rem; border-radius: 999px; background: rgba(1, 10, 14, .9); border: 1px solid rgba(110, 230, 210, .35); font-size: .8rem; pointer-events: none; }
.hidden { display: none !important; }
.touch-controls { display: none; position: absolute; inset: auto 14px 14px 14px; justify-content: space-between; align-items: end; pointer-events: none; }
.touch-controls button { pointer-events: auto; touch-action: none; }
.dpad { display: grid; grid-template-columns: 46px 46px 46px; grid-template-rows: 46px 46px; gap: 4px; }
.dpad button:nth-child(1) { grid-column: 2; }
.dpad button:nth-child(2) { grid-column: 1; grid-row: 2; }
.dpad button:nth-child(3) { grid-column: 2; grid-row: 2; }
.dpad button:nth-child(4) { grid-column: 3; grid-row: 2; }
.action-button { width: 70px; height: 70px; border-radius: 50%; font-weight: 900; }

.player-list { display: grid; gap: .35rem; margin-top: .65rem; }
.player-row { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .45rem .55rem; border: 1px solid rgba(126,214,214,.12); border-radius: 9px; background: rgba(2,15,19,.5); font-size: .77rem; }
.player-status { color: var(--muted); font-size: .67rem; }
.loadout-summary { display: grid; gap: .45rem; }
.loadout-card { border: 1px solid rgba(126,214,214,.13); border-radius: 10px; padding: .55rem; background: rgba(4,20,25,.65); }
.loadout-card strong { display: block; font-size: .8rem; }
.loadout-card span { color: var(--muted); font-size: .7rem; }
.ground-summary { font-size: .78rem; color: var(--muted); line-height: 1.5; margin-bottom: .7rem; }
.ground-summary strong { color: var(--text); }

.chat-section { display: flex; flex-direction: column; min-height: 340px; }
.chat-log { min-height: 230px; max-height: 38vh; overflow-y: auto; border: 1px solid rgba(126,214,214,.13); border-radius: 10px; padding: .55rem; background: rgba(1,10,14,.62); display: flex; flex-direction: column; gap: .45rem; }
.chat-message { font-size: .76rem; line-height: 1.35; overflow-wrap: anywhere; }
.chat-message .meta { color: var(--muted); font-size: .64rem; margin-right: .35rem; }
.chat-message.system { color: #d8c882; font-style: italic; }
.chat-message.warning { color: #ffb4b4; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: .4rem; margin-top: .5rem; }
.chat-warning { margin-top: .45rem; padding: .5rem; border-radius: 8px; font-size: .72rem; background: rgba(255, 94, 94, .12); border: 1px solid rgba(255,94,94,.28); color: #ffd0d0; }
.nearby-panel { color: var(--muted); font-size: .8rem; min-height: 56px; }

.content-view { padding: 1rem; overflow-y: auto; }
.content-grid { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 1rem; }
.item-grid, .card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .65rem; }
.item-tile { position: relative; min-height: 122px; border: 1px solid rgba(126,214,214,.14); border-radius: 12px; padding: .65rem; background: linear-gradient(160deg, rgba(14,48,56,.8), rgba(4,18,24,.9)); overflow: hidden; }
.item-tile img { width: 100%; height: 76px; object-fit: contain; border-radius: 8px; background: rgba(0,0,0,.15); }
.item-tile h3 { font-size: .76rem; margin: .45rem 0 .15rem; }
.item-tile p { font-size: .66rem; color: var(--muted); margin: 0; }
.card-tile { aspect-ratio: .71; border-radius: 14px; overflow: hidden; border: 1px solid rgba(255,255,255,.15); box-shadow: 0 12px 28px rgba(0,0,0,.3); background: #091419; position: relative; }
.card-tile img { width: 100%; height: 100%; display: block; object-fit: cover; }
.card-tile button { position: absolute; inset: auto 8px 8px; width: calc(100% - 16px); padding: .35rem; font-size: .7rem; background: rgba(4,13,17,.85); }
.journal-layout { display: grid; grid-template-columns: 1.25fr .75fr; gap: 1rem; }
.journal-entries { display: grid; gap: .55rem; }
.journal-entry { border: 1px solid rgba(126,214,214,.13); border-radius: 10px; padding: .65rem; background: rgba(4,18,23,.65); }
.journal-entry h3 { margin: 0 0 .25rem; font-size: .85rem; }
.journal-entry p { margin: 0; font-size: .75rem; color: var(--muted); line-height: 1.45; }
.seed-details { white-space: pre-wrap; color: #b9d8d3; background: rgba(0,8,11,.66); border: 1px solid rgba(126,214,214,.13); padding: .75rem; border-radius: 10px; font-size: .73rem; }

.modal-root { position: fixed; z-index: 100; inset: 0; pointer-events: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 5, 8, .78); backdrop-filter: blur(8px); display: grid; place-items: center; padding: 1rem; pointer-events: auto; }
.modal { width: min(1050px, 96vw); max-height: 92vh; overflow: auto; position: relative; border-radius: 18px; border: 1px solid rgba(115, 235, 215, .24); background: linear-gradient(160deg, rgba(15,43,51,.98), rgba(4,16,22,.99)); box-shadow: 0 30px 100px rgba(0,0,0,.65); }
.modal-close { position: sticky; top: .7rem; float: right; margin: .7rem .7rem 0 0; z-index: 2; width: 38px; height: 38px; padding: 0; border-radius: 50%; }
.modal-content { padding: 1.2rem; clear: both; }
.modal-content h2 { margin-top: 0; }
.ground-choice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
.ground-card { border: 1px solid rgba(126,214,214,.16); background: rgba(4,18,24,.72); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.ground-preview { height: 190px; width: 100%; display: block; }
.ground-card .body { padding: .75rem; display: flex; flex-direction: column; gap: .55rem; flex: 1; }
.ground-card h3 { margin: 0; font-size: .95rem; }
.ground-card p { color: var(--muted); font-size: .74rem; line-height: 1.45; margin: 0; }
.ground-tags { display: flex; gap: .35rem; flex-wrap: wrap; }
.ground-tags span { font-size: .62rem; padding: .22rem .42rem; border-radius: 999px; background: rgba(92,211,185,.11); border: 1px solid rgba(92,211,185,.18); }
.shop-layout { display: grid; grid-template-columns: 1fr .85fr; gap: 1rem; }
.shop-stock { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px,1fr)); gap: .65rem; }
.shop-item { border: 1px solid rgba(126,214,214,.13); border-radius: 11px; padding: .65rem; background: rgba(2,14,19,.58); }
.shop-item h3 { margin: 0 0 .25rem; font-size: .82rem; }
.shop-item p { color: var(--muted); font-size: .7rem; min-height: 40px; }
.shop-item .price { display: flex; justify-content: space-between; align-items: center; font-size: .74rem; }
.pack-reveal { display: grid; grid-template-columns: repeat(3, minmax(160px, 230px)); justify-content: center; gap: 1rem; margin-top: 1rem; }
.pack-reveal img { width: 100%; border-radius: 14px; box-shadow: 0 20px 45px rgba(0,0,0,.45); }
.loadout-editor { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.trade-box { padding: .8rem; border: 1px solid rgba(126,214,214,.13); border-radius: 12px; background: rgba(2,14,19,.58); }

.toast-root { position: fixed; right: 1rem; bottom: 1rem; z-index: 130; display: grid; gap: .55rem; width: min(360px, calc(100vw - 2rem)); }
.toast { padding: .75rem .85rem; border: 1px solid rgba(126,214,214,.24); border-radius: 11px; background: rgba(6,23,29,.96); box-shadow: 0 15px 40px rgba(0,0,0,.45); animation: toast-in .25s ease; font-size: .8rem; }
.toast.good { border-color: rgba(108, 240, 161, .4); }
.toast.bad { border-color: rgba(255, 100, 100, .45); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

@media (max-width: 1180px) {
  .main-layout { grid-template-columns: 230px minmax(0,1fr); }
  .right-rail { grid-column: 1 / -1; max-height: none; display: grid; grid-template-columns: 1.5fr .8fr .8fr; gap: .8rem; }
  .right-rail section { border-bottom: 0; border-right: 1px solid rgba(126,214,214,.12); padding-right: .8rem; }
  .right-rail section:last-child { border-right: 0; }
}

@media (max-width: 820px) {
  .topbar { grid-template-columns: 1fr auto; }
  .top-stats { grid-column: 1 / -1; overflow-x: auto; }
  .main-layout { display: flex; flex-direction: column; }
  .left-rail, .right-rail { max-height: none; }
  .left-rail { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
  .left-rail section { border-bottom: 0; }
  .right-rail { display: block; }
  .right-rail section { border-right: 0; border-bottom: 1px solid rgba(126,214,214,.12); }
  .game-stage { min-height: 620px; }
  #worldCanvas, #fishingGL, #fishingOverlay { min-height: 540px; }
  .content-grid, .journal-layout, .shop-layout, .loadout-editor { grid-template-columns: 1fr; }
  .ground-choice-grid, .pack-reveal { grid-template-columns: 1fr; }
  .ground-preview { height: 150px; }
  .touch-controls { display: flex; }
}

@media (max-width: 560px) {
  .brand-block p { display: none; }
  .top-actions button:not(.icon-button) { display: none; }
  .top-stats > div { min-width: 65px; }
  .left-rail { display: block; }
  .stage-toolbar { align-items: flex-start; flex-direction: column; }
  .mode-tabs { width: 100%; }
  .mode-tabs button { flex: 1; }
  .fishing-hud { grid-template-columns: 1fr 1fr; }
  #fishingStatus { grid-column: 1 / -1; grid-row: 1; }
  .item-grid, .card-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}


/* v0.2.2 — classic interface + modern fishing */
.fishing-hud { grid-template-columns: auto minmax(260px, 1fr) auto; align-items: end; padding-top: 3.5rem; }
.fishing-center { display: grid; gap: .4rem; min-width: 0; }
.fishing-copy { display: flex; justify-content: center; align-items: baseline; gap: .65rem; text-align: center; text-shadow: 0 2px 8px #000; }
.fishing-copy strong { color: var(--accent, #72e4cf); letter-spacing: .12em; font-size: .78rem; }
.fishing-copy span { font-weight: 750; }
.fishing-meter-row, .reel-panel { display: grid; gap: .25rem; }
.fishing-meter-row label, .reel-panel label { color: #b8d0ca; font-size: .65rem; font-weight: 800; letter-spacing: .12em; }
.fishing-meter { position: relative; height: 13px; overflow: hidden; border-radius: 999px; background: rgba(0,0,0,.62); border: 1px solid rgba(255,255,255,.18); box-shadow: inset 0 2px 7px rgba(0,0,0,.55); }
.fishing-meter i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg,#4bc895,#e8ce5a,#ed6b62); border-radius: inherit; transition: width .06s linear; }
.fishing-meter b { position: absolute; top: -2px; bottom: -2px; pointer-events: none; }
.cast-sweet { left: 66%; width: 24%; border-left: 2px solid #fff8a5; border-right: 2px solid #fff8a5; background: rgba(255,244,135,.13); }
.tension-safe { left: 28%; width: 42%; border-left: 2px solid #6cf0b9; border-right: 2px solid #6cf0b9; background: rgba(108,240,185,.12); }
.bite-panel { display: flex; justify-content: center; gap: .65rem; align-items: baseline; color: #f8e8a5; }
.bite-panel strong { letter-spacing: .08em; animation: bitePulse .7s ease-in-out infinite alternate; }
.bite-panel small { color: #bdd0cb; }
.reel-panel { grid-template-columns: 1fr 1fr; align-items: end; column-gap: .65rem; }
.reel-panel small { grid-column: 1 / -1; text-align: center; color: #d5e5df; }
.battle-panel { display: flex; justify-content: center; gap: .75rem; font-size: .76rem; color: #ffe99b; font-weight: 800; letter-spacing: .04em; }
.battle-help { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .7rem; margin: 1rem 0; }
.battle-help div { display: grid; gap: .15rem; padding: .75rem; border: 1px solid rgba(115,235,215,.18); border-radius: 12px; background: rgba(5,20,25,.7); }
.battle-help span { color: #adc7c0; font-size: .85rem; }
.pack-reveal img { animation: packCardIn .55s cubic-bezier(.2,.8,.2,1) both; transform-origin: center bottom; }
.pack-reveal img:nth-child(2) { animation-delay: .16s; }
.pack-reveal img:nth-child(3) { animation-delay: .32s; }
@keyframes packCardIn { from { opacity: 0; transform: translateY(28px) rotateY(75deg) scale(.82); filter: brightness(2); } to { opacity: 1; transform: none; filter: none; } }
@keyframes bitePulse { from { transform: scale(.98); text-shadow: 0 0 4px rgba(255,220,80,.2); } to { transform: scale(1.05); text-shadow: 0 0 16px rgba(255,220,80,.8); } }
@media (max-width: 700px) {
  .fishing-hud { grid-template-columns: 1fr 1fr; align-items: center; }
  .fishing-center { grid-column: 1 / -1; grid-row: 1; }
  .reel-panel { grid-template-columns: 1fr; }
  .reel-panel small { grid-column: auto; }
  .bite-panel { flex-direction: column; align-items: center; gap: .1rem; }
  .battle-help { grid-template-columns: 1fr; }
}

/* v0.2.3 — fixed 3D fishing view + polished storefront */
.fishing-view::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 46%, transparent 35%, rgba(0, 8, 12, .16) 72%, rgba(0, 4, 7, .48) 100%),
    linear-gradient(180deg, rgba(255,255,255,.025), transparent 35%);
  box-shadow: inset 0 0 90px rgba(0,0,0,.35);
}
.fishing-view::after {
  content: "FIXED 3D SHORE VIEW";
  position: absolute;
  z-index: 2;
  top: .75rem;
  left: .75rem;
  pointer-events: none;
  padding: .3rem .5rem;
  border: 1px solid rgba(160, 240, 224, .2);
  border-radius: 999px;
  background: rgba(1, 11, 15, .55);
  color: rgba(221, 247, 240, .76);
  font-size: .6rem;
  font-weight: 850;
  letter-spacing: .12em;
}
.shop-modal .modal { width: min(1180px, 97vw); background: #071319; overflow: hidden; }
.shop-modal .modal-content { padding: 0; }
.shop-modal .modal-close { position: absolute; right: .45rem; top: .35rem; float: none; background: rgba(4,16,21,.82); z-index: 5; }
.shop-shell { min-height: 650px; background: linear-gradient(155deg, #102d35, #071419 46%, #050d11); }
.shop-hero { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 1.2rem; align-items: end; padding: 1.35rem 4rem 1.15rem 1.35rem; background: radial-gradient(circle at 12% 0%, rgba(88,214,186,.2), transparent 42%), linear-gradient(100deg, rgba(16,54,62,.96), rgba(6,22,28,.96)); border-bottom: 1px solid rgba(126,214,214,.16); }
.shop-hero h2 { margin: .18rem 0 .35rem; font-size: clamp(1.35rem, 3vw, 2rem); }
.shop-hero p { margin: 0; color: #b6cdc7; max-width: 650px; line-height: 1.45; }
.shop-eyebrow, .shop-kind, .shop-page-heading span { display: block; color: var(--accent); font-size: .62rem; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.shop-wallet { display: flex; gap: .45rem; }
.shop-wallet > div { min-width: 88px; padding: .62rem .72rem; border-radius: 12px; border: 1px solid rgba(126,214,214,.16); background: rgba(2,13,17,.62); text-align: center; }
.shop-wallet span { display: block; color: var(--muted); font-size: .61rem; text-transform: uppercase; letter-spacing: .1em; }
.shop-wallet strong { display: block; margin-top: .15rem; font-size: .92rem; }
.shop-tabs { display: flex; gap: .35rem; padding: .75rem 1rem; border-bottom: 1px solid rgba(126,214,214,.12); background: rgba(4,17,22,.94); overflow-x: auto; }
.shop-tab { display: flex; align-items: center; gap: .45rem; border-radius: 999px; padding: .55rem .78rem; white-space: nowrap; background: rgba(18,48,56,.72); }
.shop-tab span { display: inline-grid; place-items: center; min-width: 21px; height: 21px; padding: 0 .3rem; border-radius: 999px; background: rgba(0,0,0,.3); color: #d8eee8; font-size: .65rem; }
.shop-tab.active { background: linear-gradient(180deg,#64dfc4,#287f75); color: #041512; border-color: transparent; font-weight: 850; }
.shop-page { display: none; padding: 1rem 1.15rem 1.35rem; }
.shop-page.active { display: block; animation: shopPageIn .2s ease; }
.shop-page-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
.shop-page-heading h3 { margin: .2rem 0 0; font-size: 1.05rem; }
.shop-page-heading p { margin: 0; max-width: 380px; color: var(--muted); font-size: .75rem; text-align: right; }
.shop-products { display: grid; grid-template-columns: repeat(auto-fill,minmax(230px,1fr)); gap: .8rem; }
.pack-products { grid-template-columns: repeat(2,minmax(260px,1fr)); }
.shop-product { display: grid; grid-template-rows: 145px 1fr auto; min-height: 345px; overflow: hidden; border: 1px solid rgba(126,214,214,.15); border-radius: 15px; background: linear-gradient(155deg, rgba(16,47,55,.9), rgba(4,17,22,.96)); box-shadow: 0 12px 32px rgba(0,0,0,.24); }
.shop-product.featured-pack { grid-template-rows: 190px 1fr auto; min-height: 410px; }
.shop-product-copy { padding: .8rem .85rem .45rem; }
.shop-product h3 { margin: .2rem 0 .35rem; font-size: .95rem; }
.shop-product p { margin: 0; color: var(--muted); font-size: .72rem; line-height: 1.45; }
.shop-product-buy { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .7rem .8rem; border-top: 1px solid rgba(126,214,214,.1); background: rgba(1,10,14,.45); }
.shop-product-buy > div { display: flex; align-items: baseline; gap: .28rem; flex-wrap: wrap; }
.shop-product-buy strong { font-size: 1.05rem; color: #f4d574; }
.shop-product-buy small, .shop-product-buy span { color: var(--muted); font-size: .66rem; }
.shop-product-buy button { min-width: 94px; }
.shop-card-preview { width: 100%; height: 145px; object-fit: cover; object-position: center 26%; filter: saturate(.9) brightness(.88); }
.shop-pack-art { position: relative; display: grid; place-items: center; overflow: hidden; min-height: 190px; background: radial-gradient(circle at 50% 40%, rgba(95,235,202,.32), transparent 42%), linear-gradient(145deg,#174c52,#07171e 70%); }
.shop-pack-art.night { background: radial-gradient(circle at 50% 35%, rgba(151,106,255,.35), transparent 42%), linear-gradient(145deg,#302350,#090d20 72%); }
.shop-pack-art i { position: absolute; width: 86px; height: 126px; border: 2px solid rgba(255,255,255,.35); border-radius: 10px; background: linear-gradient(155deg,rgba(101,232,205,.55),rgba(5,19,26,.9)); box-shadow: 0 12px 20px rgba(0,0,0,.35); }
.shop-pack-art i:nth-child(1) { transform: translateX(-42px) rotate(-14deg); }
.shop-pack-art i:nth-child(2) { transform: translateY(-8px); z-index: 1; }
.shop-pack-art i:nth-child(3) { transform: translateX(42px) rotate(14deg); }
.shop-pack-art strong { position: relative; z-index: 2; font-size: 2.2rem; filter: drop-shadow(0 4px 8px #000); }
.shop-pack-art span { position: absolute; z-index: 2; bottom: .65rem; font-size: .7rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.shop-service-art { display: grid; place-items: center; align-content: center; gap: .35rem; min-height: 145px; background: radial-gradient(circle,rgba(217,184,97,.17),transparent 58%), repeating-linear-gradient(135deg,rgba(255,255,255,.018) 0 8px,transparent 8px 16px); }
.shop-service-art span { font-size: 2.8rem; }
.shop-service-art b { color: #d9c783; font-size: .62rem; letter-spacing: .16em; }
.sell-list { display: grid; gap: .6rem; }
.sell-card { display: grid; grid-template-columns: 150px minmax(0,1fr) auto; gap: .8rem; align-items: center; padding: .65rem; border: 1px solid rgba(126,214,214,.13); border-radius: 13px; background: rgba(4,20,25,.74); }
.sell-card img { width: 150px; height: 82px; object-fit: cover; border-radius: 9px; }
.sell-card h3 { margin: .15rem 0; font-size: .86rem; }
.sell-card p { margin: 0; color: var(--muted); font-size: .7rem; }
.sell-action { display: grid; grid-template-columns: auto auto; column-gap: .25rem; align-items: baseline; text-align: right; }
.sell-action strong { color: #f4d574; }
.sell-action small { color: var(--muted); font-size: .62rem; }
.sell-action button { grid-column: 1 / -1; margin-top: .3rem; }
.shop-empty { min-height: 230px; display: grid; place-items: center; align-content: center; gap: .3rem; border: 1px dashed rgba(126,214,214,.2); border-radius: 15px; color: var(--muted); }
.shop-empty span { font-size: 2.5rem; }
.shop-empty h3, .shop-empty p { margin: 0; }
@keyframes shopPageIn { from { opacity: 0; transform: translateY(5px); } }
@media (max-width: 760px) {
  .shop-hero { grid-template-columns: 1fr; padding-right: 3.5rem; }
  .shop-wallet { overflow-x: auto; }
  .shop-wallet > div { min-width: 78px; }
  .pack-products, .shop-products { grid-template-columns: 1fr; }
  .shop-page-heading { align-items: flex-start; flex-direction: column; }
  .shop-page-heading p { text-align: left; }
  .sell-card { grid-template-columns: 92px minmax(0,1fr); }
  .sell-card img { width: 92px; height: 66px; }
  .sell-action { grid-column: 1 / -1; display: flex; justify-content: flex-end; align-items: center; gap: .35rem; }
}


/* v0.2.4 — universal responsive-fit hotfix
   Presentation-only branch from v0.2.3 GOLD. Gameplay systems are unchanged. */
:root {
  --viewport-height: 100dvh;
  --topbar-height: 76px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

html, body {
  width: 100%;
  max-width: 100%;
  min-height: 100%;
}

body {
  min-height: var(--viewport-height);
  overscroll-behavior: none;
}

img, canvas, svg, video { max-width: 100%; }

.app-shell {
  height: var(--viewport-height);
  min-height: 0;
  overflow: hidden;
}

.topbar {
  padding-top: calc(.72rem + var(--safe-top));
  padding-right: calc(.9rem + var(--safe-right));
  padding-left: calc(.9rem + var(--safe-left));
  min-width: 0;
}

.brand-block,
.brand-block > div,
.top-stats,
.top-actions,
.main-layout > *,
.stage-toolbar > *,
.content-grid > *,
.journal-layout > *,
.shop-hero > *,
.shop-product,
.sell-card > * {
  min-width: 0;
}

.main-layout {
  height: calc(var(--viewport-height) - var(--topbar-height));
  min-height: 0;
  overflow: hidden;
  grid-template-columns:
    clamp(200px, 18vw, 270px)
    minmax(360px, 1fr)
    clamp(215px, 20vw, 290px);
}

.left-rail,
.right-rail,
.game-stage {
  height: 100%;
  max-height: none;
  min-height: 0;
}

.left-rail,
.right-rail,
.content-view,
.modal,
.shop-shell {
  scrollbar-width: thin;
  scrollbar-color: rgba(88,214,186,.45) rgba(2,13,18,.55);
}

.game-stage { overflow: hidden; }
.view { min-width: 0; min-height: 0; }
.view.active { min-height: 0; }
#worldView,
#fishingView { overflow: hidden; }

#worldCanvas,
#fishingGL,
#fishingOverlay {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.fishing-view { min-height: 0; }

.stage-toolbar {
  flex: 0 0 auto;
  min-height: 54px;
}

.world-prompt {
  max-width: calc(100% - 2rem - var(--safe-left) - var(--safe-right));
  white-space: normal;
  text-align: center;
}

.fishing-hud {
  padding-right: calc(.75rem + var(--safe-right));
  padding-bottom: calc(.75rem + var(--safe-bottom));
  padding-left: calc(.75rem + var(--safe-left));
}

.touch-controls {
  right: calc(14px + var(--safe-right));
  bottom: calc(14px + var(--safe-bottom));
  left: calc(14px + var(--safe-left));
}

.modal-backdrop {
  padding-top: calc(.7rem + var(--safe-top));
  padding-right: calc(.7rem + var(--safe-right));
  padding-bottom: calc(.7rem + var(--safe-bottom));
  padding-left: calc(.7rem + var(--safe-left));
}

.modal {
  width: min(1050px, 100%);
  max-width: 100%;
  max-height: calc(var(--viewport-height) - var(--safe-top) - var(--safe-bottom) - 1.4rem);
}

.shop-modal .modal {
  width: min(1180px, 100%);
  max-height: calc(var(--viewport-height) - var(--safe-top) - var(--safe-bottom) - 1.4rem);
  overflow: auto;
}

.shop-shell {
  min-height: 0;
}

.pack-reveal {
  grid-template-columns: repeat(3, minmax(0, 230px));
}

.pack-reveal img,
.card-tile img,
.item-tile img,
.shop-card-preview,
.sell-card img {
  max-width: 100%;
}

.toast-root {
  right: calc(1rem + var(--safe-right));
  bottom: calc(1rem + var(--safe-bottom));
}

/* Compact desktop and laptop screens retain all three live columns. */
@media (max-width: 1320px) and (min-width: 981px) {
  .main-layout {
    grid-template-columns: clamp(185px, 17vw, 230px) minmax(340px, 1fr) clamp(200px, 19vw, 255px);
    gap: .55rem;
    padding: .55rem;
  }
  .left-rail, .right-rail { padding: .7rem; }
  .topbar { gap: .65rem; }
  .top-stats { gap: .35rem; }
  .top-stats > div { min-width: 62px; padding-inline: .45rem; }
  .stage-toolbar { padding-inline: .65rem; }
}

/* Tablet and narrow-browser layout: game first, support panels below. */
@media (max-width: 980px) {
  body { overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: auto; }
  .app-shell { height: auto; min-height: var(--viewport-height); overflow: visible; }
  .topbar { position: sticky; }
  .main-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    min-height: 0;
    overflow: visible;
    padding-bottom: calc(.75rem + var(--safe-bottom));
  }
  .game-stage {
    order: 1;
    width: 100%;
    height: clamp(440px, 70svh, 760px);
    min-height: 440px;
  }
  .left-rail {
    order: 2;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .75rem;
    width: 100%;
    height: auto;
    overflow: visible;
  }
  .right-rail {
    order: 3;
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(190px, .8fr) minmax(190px, .8fr);
    gap: .75rem;
    width: 100%;
    height: auto;
    overflow: visible;
  }
  .left-rail section,
  .right-rail section {
    margin: 0;
    padding: 0;
    border: 0;
  }
  .chat-section { min-height: 280px; }
  .chat-log { max-height: 260px; }
  .content-view { height: 100%; }
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .5rem;
    padding-block: calc(.5rem + var(--safe-top)) .5rem;
  }
  .brand-mark { width: 40px; height: 40px; }
  .brand-block { gap: .55rem; }
  .brand-block h1 { font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand-block p { display: none; }
  .top-actions { gap: .3rem; }
  .top-actions button { min-height: 40px; }
  .top-stats {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    gap: .35rem;
    overflow: visible;
  }
  .top-stats > div { min-width: 0; padding: .38rem .25rem; }
  .top-stats strong { font-size: .82rem; }
  .main-layout { padding: .45rem; gap: .55rem; }
  .game-stage { height: clamp(390px, 68svh, 620px); min-height: 390px; border-radius: 13px; }
  .left-rail, .right-rail { grid-template-columns: minmax(0, 1fr); }
  .stage-toolbar { gap: .5rem; padding: .5rem .6rem; }
  .stage-toolbar > div:first-child { width: 100%; }
  .stage-toolbar strong { font-size: .86rem; }
  .stage-toolbar span { display: block; white-space: normal; line-height: 1.35; }
  .mode-tabs { width: 100%; }
  .mode-tabs button { flex: 1 1 0; min-width: 0; padding-inline: .35rem; }
  .content-view { padding: .65rem; }
  .item-grid, .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fishing-hud {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: .45rem;
    padding-top: 2.6rem;
  }
  .fishing-center { grid-column: 1 / -1; grid-row: 1; }
  .fishing-copy { align-items: center; flex-direction: column; gap: .1rem; }
  .fishing-copy span { font-size: .78rem; line-height: 1.2; }
  .fishing-hud > button { min-width: 0; padding-inline: .5rem; }
  .reel-panel { grid-template-columns: 1fr; }
  .reel-panel small { grid-column: auto; }
  .bite-panel { align-items: center; flex-direction: column; gap: .05rem; text-align: center; }
  .fishing-view::after { top: .45rem; left: .45rem; font-size: .52rem; }
  .shop-hero { padding: 1rem 3.4rem .9rem .85rem; }
  .shop-tabs { padding-inline: .6rem; }
  .shop-page { padding: .75rem; }
  .shop-products, .pack-products { grid-template-columns: minmax(0, 1fr); }
  .shop-product, .shop-product.featured-pack { min-height: 0; }
  .pack-reveal { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .45rem; }
  .pack-reveal img { border-radius: 9px; }
  .ground-choice-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 460px) {
  .top-actions #saveButton { display: none; }
  .icon-button { width: 40px; }
  .top-stats span { font-size: .55rem; }
  .top-stats strong { font-size: .76rem; }
  .game-stage { height: clamp(360px, 66svh, 540px); min-height: 360px; }
  .stage-toolbar { min-height: 0; }
  .stage-toolbar span { font-size: .66rem; }
  .item-grid, .card-grid { grid-template-columns: minmax(0, 1fr); }
  .fishing-hud { padding-inline: .45rem; }
  .fishing-hud > button { font-size: .72rem; }
  .fishing-meter-row label, .reel-panel label { font-size: .58rem; }
  .dpad { transform: scale(.88); transform-origin: bottom left; }
  .action-button { width: 60px; height: 60px; font-size: .72rem; }
  .modal-content { padding: .8rem; }
  .shop-wallet { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); overflow: visible; }
  .shop-wallet > div { min-width: 0; padding-inline: .35rem; }
  .sell-card { grid-template-columns: 74px minmax(0, 1fr); }
  .sell-card img { width: 74px; height: 58px; }
  .pack-reveal { gap: .28rem; }
}

/* Short laptop / phone landscape support. */
@media (max-height: 620px) and (min-width: 761px) {
  .topbar { padding-block: .42rem; }
  .brand-mark { width: 38px; height: 38px; }
  .brand-block p { display: none; }
  .main-layout { gap: .45rem; padding: .45rem; }
  .left-rail, .right-rail { padding: .55rem; }
  .left-rail section, .right-rail section { padding-bottom: .55rem; margin-bottom: .55rem; }
  .chat-section { min-height: 220px; }
  .chat-log { min-height: 125px; max-height: 28vh; }
  .stage-toolbar { min-height: 46px; padding-block: .4rem; }
  .fishing-hud { padding-top: 2.4rem; }
}

@supports not (height: 100dvh) {
  :root { --viewport-height: 100vh; }
}

/* Final breakpoint correction: 1024-class tablets use the game-first stack,
   and short landscape screens keep the entire active stage visible. */
@media (max-width: 1100px) {
  body { overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: auto; }
  .app-shell { height: auto; min-height: var(--viewport-height); overflow: visible; }
  .main-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    min-height: 0;
    overflow: visible;
  }
  .game-stage { order: 1; width: 100%; height: clamp(440px, 70svh, 760px); min-height: 440px; }
  .left-rail {
    order: 2;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .75rem;
    width: 100%;
    height: auto;
    overflow: visible;
  }
  .right-rail {
    order: 3;
    grid-column: auto;
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(190px, .8fr) minmax(190px, .8fr);
    gap: .75rem;
    width: 100%;
    height: auto;
    overflow: visible;
  }
  .left-rail section, .right-rail section {
    margin: 0;
    padding: 0;
    border-right: 0;
    border-bottom: 0;
  }
}

@media (max-width: 760px) {
  .left-rail, .right-rail { grid-template-columns: minmax(0, 1fr); }
}

@media (max-height: 620px) and (max-width: 1100px) {
  .game-stage {
    height: max(300px, calc(var(--viewport-height) - var(--topbar-height) - 1rem));
    min-height: 300px;
  }
  .stage-toolbar { min-height: 44px; }
  .touch-controls { transform: scale(.82); transform-origin: bottom center; }
}

/* Touch hardware can report a wide landscape viewport; do not hide controls
   merely because the CSS width exceeds the portrait breakpoint. */
@media (pointer: coarse) {
  .touch-controls { display: flex; }
  button, .shop-tab { min-height: 42px; }
}
