/* Saltmere — in-game UI */
[hidden] { display: none !important; }
.g-panel .note, .g-modal .note { margin: 0 0 12px; max-width: none; text-align: left; color: var(--ink); }
html, body.game { height: 100%; overflow: hidden; overscroll-behavior: none; }
body.game { margin: 0; background: #1a557a; font-family: var(--font); color: var(--ink); -webkit-tap-highlight-color: transparent; user-select: none; }
#world { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; image-rendering: pixelated; }
canvas[data-icon] { image-rendering: pixelated; }

/* loading */
.g-load { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: radial-gradient(120% 90% at 50% 30%, #1f8aa3, #0d2a3a); transition: opacity .5s ease, visibility .5s; }
body:not(.is-loading) .g-load { opacity: 0; visibility: hidden; }
.g-load__in { display: grid; justify-items: center; gap: 8px; color: var(--cream); }
.g-load__in b { font-size: 34px; font-weight: 700; letter-spacing: .5px; text-shadow: 0 3px 0 var(--ink); }
.g-load__in span { opacity: .8; }
.g-load__in i { width: 180px; height: 10px; border: 3px solid var(--ink); border-radius: 99px; background: var(--sea-900); overflow: hidden; }
.g-load__in em { display: block; height: 100%; width: 30%; background: var(--sea-300); border-radius: 99px; animation: gl 1.1s ease-in-out infinite alternate; }
@keyframes gl { to { width: 100%; } }

/* shared bits */
.g-card { background: linear-gradient(180deg, #fffaf0, var(--cream)); border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 5px 0 var(--ink); }
.g-ico { width: 40px; height: 40px; display: grid; place-items: center; border: 3px solid var(--ink); border-radius: 12px; background: var(--cream); color: var(--ink); font: 700 22px/1 var(--font); box-shadow: 0 4px 0 var(--ink); cursor: pointer; padding: 0; }
.g-ico svg { width: 20px; height: 20px; }
.g-ico:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.gbtn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; font: 600 15px/1 var(--font); color: var(--ink); background: linear-gradient(180deg, #fffaf0, var(--cream) 60%, #f1e2c4); border: 3px solid var(--ink); border-radius: 12px; box-shadow: 0 4px 0 var(--ink); cursor: pointer; white-space: nowrap; transition: transform .1s, box-shadow .1s, filter .15s; }
.gbtn:hover { filter: brightness(1.04); }
.gbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.gbtn--go { color: var(--cream); text-shadow: 0 2px 0 rgba(29,36,51,.35); background: linear-gradient(180deg, #ff9372, var(--coral) 55%, var(--coral-d)); }
.gbtn--sea { color: var(--cream); text-shadow: 0 2px 0 rgba(29,36,51,.35); background: linear-gradient(180deg, #6fe0e4, var(--sea-500) 60%, #187085); }
.gbtn--gold { background: linear-gradient(180deg, #ffe08a, var(--gold) 60%, #e3a52c); }
.gbtn[disabled] { filter: grayscale(.7) opacity(.6); cursor: not-allowed; transform: none; box-shadow: 0 4px 0 var(--ink); }
.gbtn--sm { padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.gbtn--wide { width: 100%; }
.chip { display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px 2px 3px; border-radius: 99px; background: rgba(29,36,51,.08); font: 600 13px/1.2 var(--font); white-space: nowrap; }
.chip img { width: 18px; height: 18px; image-rendering: pixelated; }
.chip.is-short { background: rgba(226,88,58,.16); color: #b83a22; }
.muted { color: #5b6275; }

/* top bar */
.g-top { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); pointer-events: none; }
.g-top > * { pointer-events: auto; }
.g-home { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border: 3px solid var(--ink); border-radius: 14px; background: var(--night); box-shadow: 0 4px 0 var(--ink); }
.g-town { flex: none; position: relative; display: flex; align-items: center; gap: 8px; padding: 5px 14px 9px 6px; border: 3px solid var(--ink); border-radius: 14px; background: linear-gradient(180deg, #fffaf0, var(--cream)); box-shadow: 0 4px 0 var(--ink); cursor: pointer; text-align: left; font-family: var(--font); color: var(--ink); max-width: 260px; }
.g-town__txt { display: grid; line-height: 1.1; min-width: 0; }
.g-town b { font-size: 17px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-town small { font-size: 12px; color: #5b6275; font-weight: 500; white-space: nowrap; }
.g-town__bar { position: absolute; left: 10px; right: 10px; bottom: 3px; height: 4px; border-radius: 9px; background: rgba(29,36,51,.12); overflow: hidden; }
.g-town__bar i { display: block; height: 100%; width: 0; background: var(--leaf); border-radius: 9px; transition: width .4s; }
.g-res { flex: 1; min-width: 0; display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.g-pill { display: inline-flex; align-items: center; gap: 4px; height: 36px; padding: 0 10px 0 4px; border: 3px solid var(--ink); border-radius: 99px; background: rgba(21,26,51,.9); color: var(--cream); font: 600 15px/1 var(--font); box-shadow: 0 3px 0 var(--ink); white-space: nowrap; position: relative; }
.g-pill canvas { width: 26px; height: 26px; }
.g-pill small { font-size: 11px; font-weight: 500; opacity: .75; }
.g-pill small.neg { color: #ff9f8a; opacity: 1; }
.g-pill.is-full { background: rgba(120,60,20,.92); }
.g-pill.bump { animation: bump .35s ease; }
@keyframes bump { 40% { transform: scale(1.12); } }
.g-top__end { flex: none; display: flex; align-items: center; gap: 8px; }
.g-wallet { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px 0 8px; border: 3px solid var(--ink); border-radius: 12px; background: linear-gradient(180deg, #b493c4, #7e5b8d); color: var(--cream); font: 600 14px/1 var(--font); box-shadow: 0 4px 0 var(--ink); cursor: pointer; text-shadow: 0 2px 0 rgba(29,36,51,.35); white-space: nowrap; }
.g-wallet.is-on { background: linear-gradient(180deg, #fffaf0, var(--cream)); color: var(--ink); text-shadow: none; }
.g-wallet .tier { padding: 2px 7px; border-radius: 99px; background: var(--gold); color: var(--ink); font-size: 12px; text-shadow: none; }
.g-logout { height: 40px; padding: 0 12px; border: 3px solid var(--ink); border-radius: 12px; background: var(--cream); color: #b83a22; font: 600 14px/1 var(--font); box-shadow: 0 4px 0 var(--ink); cursor: pointer; }
.g-logout:active, .g-wallet:active, .g-town:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

/* hint + toasts + event */
.g-hint { position: fixed; z-index: 15; left: 50%; top: 74px; transform: translateX(-50%); max-width: min(560px, calc(100vw - 24px)); padding: 9px 14px 9px 40px; border: 3px solid var(--ink); border-radius: 14px; background: #fff3c9; box-shadow: 0 4px 0 var(--ink); font: 500 15px/1.3 var(--font); animation: hintIn .4s ease; }
.g-hint::before { content: '!'; position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; border-radius: 50%; background: var(--coral); color: var(--cream); font-weight: 700; display: grid; place-items: center; border: 2px solid var(--ink); }
@keyframes hintIn { from { opacity: 0; transform: translate(-50%, -8px); } }
.g-toasts { position: fixed; z-index: 40; left: 50%; top: 120px; transform: translateX(-50%); display: grid; gap: 6px; justify-items: center; pointer-events: none; }
.g-toast { padding: 8px 14px; border: 3px solid var(--ink); border-radius: 12px; background: var(--night); color: var(--cream); font: 600 14px/1.2 var(--font); box-shadow: 0 4px 0 var(--ink); animation: tIn .3s ease, tOut .4s ease 2.6s forwards; display: flex; gap: 6px; align-items: center; }
.g-toast.err { background: #8a2f1f; }
.g-toast.good { background: #1f6b4a; }
.g-toast img { width: 18px; height: 18px; image-rendering: pixelated; }
@keyframes tIn { from { opacity: 0; transform: translateY(-6px) scale(.96); } }
@keyframes tOut { to { opacity: 0; transform: translateY(-6px); } }
.g-event { position: fixed; z-index: 16; right: 12px; top: 74px; width: min(320px, calc(100vw - 24px)); padding: 12px; animation: evIn .4s cubic-bezier(.2,1.4,.4,1); }
@keyframes evIn { from { opacity: 0; transform: translateX(20px); } }
.g-event h4 { margin: 0 0 4px; font-size: 17px; display: flex; gap: 8px; align-items: center; }
.g-event h4 canvas { width: 30px; height: 30px; }
.g-event p { margin: 0 0 10px; font-size: 14px; line-height: 1.35; }
.g-event .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.g-event .timer { height: 6px; border-radius: 9px; background: rgba(29,36,51,.12); overflow: hidden; margin-top: 10px; }
.g-event .timer i { display: block; height: 100%; background: var(--coral); border-radius: 9px; }

/* zoom */
.g-zoom { position: fixed; z-index: 14; right: 12px; bottom: 104px; display: grid; gap: 8px; }

/* bottom bar */
.g-bar { position: fixed; z-index: 20; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 8px; padding: 8px; border: 3px solid var(--ink); border-radius: 20px; background: rgba(21,26,51,.92); box-shadow: 0 5px 0 var(--ink); }
.g-bar button { position: relative; display: grid; justify-items: center; gap: 2px; min-width: 72px; padding: 6px 8px 7px; border: 3px solid var(--ink); border-radius: 14px; background: linear-gradient(180deg, #fffaf0, var(--cream) 60%, #f1e2c4); color: var(--ink); font: 600 13px/1 var(--font); box-shadow: 0 4px 0 #0b0f1e; cursor: pointer; transition: transform .1s, box-shadow .1s; }
.g-bar button:hover { transform: translateY(-2px); box-shadow: 0 6px 0 #0b0f1e; }
.g-bar button:active, .g-bar button.is-on { transform: translateY(3px); box-shadow: 0 1px 0 #0b0f1e; }
.g-bar button.is-on { background: linear-gradient(180deg, #ffe08a, var(--gold)); }
.g-bar canvas { width: 34px; height: 34px; }
.g-badge { position: absolute; top: -9px; right: -7px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 99px; background: var(--coral); color: var(--cream); border: 2px solid var(--ink); font: 700 12px/18px var(--font); text-align: center; animation: pop .5s ease infinite alternate; }
@keyframes pop { to { transform: scale(1.12); } }

/* panel */
.g-panel { position: fixed; z-index: 30; right: 12px; top: 74px; bottom: 104px; width: min(400px, calc(100vw - 24px)); display: flex; flex-direction: column; background: linear-gradient(180deg, #fffaf0, var(--cream)); border: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 6px 0 var(--ink); animation: pIn .32s cubic-bezier(.2,1.2,.4,1); overflow: hidden; }
@keyframes pIn { from { opacity: 0; transform: translateX(26px) scale(.98); } }
.g-panel__x { position: absolute; top: 8px; right: 8px; z-index: 2; width: 34px; height: 34px; border: 3px solid var(--ink); border-radius: 10px; background: var(--cream); font: 700 22px/1 var(--font); color: var(--ink); cursor: pointer; box-shadow: 0 3px 0 var(--ink); padding: 0; }
.g-panel__body { overflow-y: auto; overscroll-behavior: contain; padding: 14px 14px 18px; user-select: text; -webkit-overflow-scrolling: touch; }
.g-panel h2 { margin: 0 44px 2px 0; font-size: 22px; font-weight: 700; line-height: 1.15; }
.g-panel h3 { margin: 16px 0 8px; font-size: 16px; font-weight: 700; }
.g-panel .lead { text-align: left; max-width: none; margin: 0 0 12px; color: #5b6275; font-size: 14px; line-height: 1.4; }
.g-panel hr { border: 0; border-top: 2px dashed rgba(29,36,51,.15); margin: 14px 0; }

.bcard { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 10px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; margin-bottom: 10px; align-items: center; }
.bcard > * { min-width: 0; }
.bcard img.spr { width: 64px; height: 64px; object-fit: contain; image-rendering: pixelated; background: linear-gradient(180deg, #d7f1f2, #bfe6d0); border-radius: 10px; border: 2px solid rgba(29,36,51,.15); }
.bcard h4 { margin: 0; font-size: 16px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.bcard h4 small { font-size: 12px; color: #5b6275; font-weight: 500; }
.bcard p { margin: 2px 0 6px; font-size: 13px; line-height: 1.35; color: #4a5162; }
.bcard .row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.bcard .row .gbtn { margin-left: auto; }
.bcard.is-locked { opacity: .55; }
.bcard.is-on { border-color: var(--coral); box-shadow: 0 0 0 3px rgba(255,122,89,.25); }
.lvl { display: inline-flex; gap: 2px; }
.lvl i { width: 10px; height: 10px; border-radius: 3px; background: rgba(29,36,51,.15); border: 1px solid rgba(29,36,51,.3); }
.lvl i.on { background: var(--gold); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.stat { padding: 8px 10px; border-radius: 12px; background: rgba(29,36,51,.06); }
.stat small { display: block; font-size: 12px; color: #5b6275; }
.stat b { font-size: 17px; }
.prog { height: 10px; border-radius: 99px; background: rgba(29,36,51,.12); overflow: hidden; border: 2px solid rgba(29,36,51,.25); }
.prog i { display: block; height: 100%; background: linear-gradient(90deg, var(--sea-300), var(--leaf)); border-radius: 99px; transition: width .3s; }
.check { display: grid; grid-template-columns: 24px 1fr auto; gap: 8px; align-items: center; padding: 6px 0; font-size: 14px; }
.check img { width: 22px; height: 22px; image-rendering: pixelated; }
.check .ok { color: #1f6b4a; font-weight: 700; }
.check .no { color: #b83a22; font-weight: 600; }

/* captain's desk */
.desk-addr { display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 12px; background: var(--night); color: var(--cream); font: 500 14px/1.2 var(--mono); }
.desk-addr span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tier-card { margin: 10px 0; padding: 12px; border: 3px solid var(--ink); border-radius: 14px; background: linear-gradient(135deg, #ffe9a8, #ffd166); }
.tier-card.none { background: linear-gradient(135deg, #e8edf3, #cdd6e0); }
.tier-card b { font-size: 20px; }
.tier-card p { margin: 4px 0 8px; font-size: 13px; }
.tiers { width: 100%; border-collapse: collapse; font-size: 13px; }
.tiers td, .tiers th { padding: 6px 4px; border-bottom: 2px dashed rgba(29,36,51,.12); text-align: left; }
.tiers tr.is-me td { background: rgba(255,201,74,.25); font-weight: 600; }
.wlist { display: grid; gap: 8px; }
.wopt { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 3px solid var(--ink); border-radius: 12px; background: #fff; font: 600 15px/1 var(--font); color: var(--ink); cursor: pointer; text-align: left; }
.wopt img { width: 28px; height: 28px; border-radius: 7px; }
.wopt small { margin-left: auto; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 99px; background: rgba(95,184,90,.2); color: #1f6b4a; }
.wopt small.inst { background: rgba(29,36,51,.08); color: #5b6275; }
.wopt:active { transform: translateY(2px); }
.g-panel .note, .g-modal .note { padding: 10px 12px; border-radius: 12px; background: rgba(31,138,163,.12); font-size: 13px; line-height: 1.4; }
.g-panel .note.warn, .g-modal .note.warn { background: rgba(255,201,74,.25); }
.hist { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.hist li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 2px dashed rgba(29,36,51,.1); }
.hist a { color: var(--sea-700); font-weight: 600; }
.field { display: flex; gap: 8px; }
.field input { flex: 1; min-width: 0; height: 40px; padding: 0 10px; border: 3px solid var(--ink); border-radius: 12px; font: 500 14px/1 var(--mono); background: #fff; color: var(--ink); }

/* modal */
.g-modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(13,20,40,.55); animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; } }
.g-modal__box { width: min(460px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 18px; background: linear-gradient(180deg, #fffaf0, var(--cream)); border: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 7px 0 var(--ink); animation: mIn .35s cubic-bezier(.2,1.3,.4,1); user-select: text; }
@keyframes mIn { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.g-modal h2 { margin: 0 0 6px; font-size: 26px; }
.g-modal p { margin: 0 0 12px; line-height: 1.45; }
.g-modal ul { margin: 0 0 14px; padding-left: 20px; line-height: 1.5; }
.g-modal input[type=text] { width: 100%; box-sizing: border-box; height: 46px; padding: 0 12px; border: 3px solid var(--ink); border-radius: 12px; font: 600 18px/1 var(--font); margin-bottom: 12px; background: #fff; color: var(--ink); }
.g-modal .acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.g-modal textarea { width: 100%; box-sizing: border-box; min-height: 90px; border: 3px solid var(--ink); border-radius: 12px; padding: 8px; font: 12px/1.3 var(--mono); }
.away { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }

@media (max-width: 900px) {
  .g-top { flex-wrap: wrap; gap: 8px; padding: 8px; }
  .g-res { order: 3; flex-basis: 100%; justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
  .g-res::-webkit-scrollbar { display: none; }
  .g-town { flex: 1; min-width: 0; max-width: none; }
  .g-pill { height: 32px; font-size: 14px; }
  .g-pill canvas { width: 22px; height: 22px; }
  .g-hint, .g-event { top: 112px; }
  .g-toasts { top: 160px; }
  .g-panel { left: 8px; right: 8px; width: auto; top: auto; bottom: 0; max-height: 64dvh; border-radius: 20px 20px 0 0; border-bottom: 0; animation: pUp .32s cubic-bezier(.2,1.1,.4,1); padding-bottom: env(safe-area-inset-bottom); }
  @keyframes pUp { from { transform: translateY(40px); opacity: 0; } }
  .g-event { left: 8px; right: 8px; width: auto; }
  .g-zoom { display: none; }
}
@media (max-width: 520px) {
  .g-home { display: none; }
  .g-wallet span { max-width: 92px; overflow: hidden; text-overflow: ellipsis; }
  .g-wallet .tier { display: none; }
  .g-bar { left: 8px; right: 8px; transform: none; justify-content: space-between; gap: 4px; padding: 6px; }
  .g-bar button { min-width: 0; flex: 1; padding: 5px 2px 6px; font-size: 11px; }
  .g-bar canvas { width: 28px; height: 28px; }
  .g-logout { padding: 0 8px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
