/* Offshore.fun · paper, ink and turquoise over a live island. */
:root {
  --paper: #E9DDC3;
  --paper-2: #F3EAD4;
  --paper-3: #DCCDAA;
  --ink: #232820;
  --ink-2: #4B5046;
  --ink-3: #7A7B6C;
  --turq: #56B9BC;
  --turq-2: #8FD6CC;
  --sand: #DCC37F;
  --palm: #517342;
  --frog: #71984A;
  --red: #C45A42;
  --gold: #DDB14E;
  --blue-line: #3F7FC4;
  --hand: "Kalam", "Comic Sans MS", cursive;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: clamp(14px, 2.4vw, 28px);
  --panel-w: 420px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); color: var(--ink); font: 500 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

#scene { position: fixed; inset: 0; }
#scene canvas { width: 100%; height: 100%; display: block; outline: none; }
.grain { position: fixed; inset: 0; pointer-events: none; opacity: .07; mix-blend-mode: multiply; background: url("../img/paper.webp?v=6") 0 0 / 1024px repeat; }

/* ------------------------------------------------------------------ top bar */
.top { position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: var(--gutter); pointer-events: none; z-index: 20; }
.top > * { pointer-events: auto; }
.brand { text-decoration: none; color: var(--ink); display: grid; gap: 0; padding: 8px 16px 10px; background: var(--paper-2); border: 2px solid var(--ink); border-radius: 18px 14px 20px 12px / 12px 20px 14px 18px; box-shadow: 3px 4px 0 rgba(35,40,32,.18); transform: rotate(-1.2deg); }
.brand .word { font: 700 30px/1 var(--hand); letter-spacing: -.01em; }
.brand .word em { font-style: normal; color: var(--turq); }
.brand .motto { font: 700 13px/1.1 var(--hand); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); position: relative; padding-bottom: 6px; }
.brand .motto::after { content: ""; position: absolute; left: 0; right: 10px; bottom: 0; height: 6px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='6'%3E%3Cpath d='M0 3 Q5 0 10 3 T20 3 T30 3 T40 3' fill='none' stroke='%233F7FC4' stroke-width='2'/%3E%3C/svg%3E") repeat-x; }
.top-right { display: flex; gap: 8px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; background: var(--paper-2); border: 2px solid var(--ink); border-radius: 999px; font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--frog); border: 1.5px solid var(--ink); }

/* ------------------------------------------------------------------ buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border: 2px solid var(--ink); border-radius: 14px 12px 15px 11px / 11px 15px 12px 14px; background: var(--paper-2); cursor: pointer; font-weight: 700; box-shadow: 2px 3px 0 var(--ink); transition: transform .12s, box-shadow .12s, background .12s; white-space: nowrap; }
.btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 4px 0 var(--ink); }
.btn:active { transform: translate(2px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn.primary { background: linear-gradient(170deg, #A8E0D8, #7CCFC7); }
.btn.gold { background: linear-gradient(170deg, #F0CF79, #DDB14E); }
.btn.icon { width: 40px; padding: 0; }
.btn svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: 2px 3px 0 var(--ink); }
kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border: 1.5px solid var(--ink); border-bottom-width: 3px; border-radius: 6px; background: var(--paper-2); font: 700 11px/1 var(--sans); }

/* ------------------------------------------------------------------ floating tags */
.tags { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.tag { position: absolute; left: 0; top: 0; pointer-events: auto; border: 2px solid var(--ink); background: var(--paper-2); padding: 4px 11px 5px; border-radius: 10px 12px 9px 13px; font: 700 15px/1.1 var(--hand); cursor: pointer; box-shadow: 2px 3px 0 rgba(35,40,32,.25); transition: opacity .25s, background .2s; white-space: nowrap; will-change: transform; }
.tag::after { content: ""; position: absolute; left: 50%; bottom: -9px; width: 2px; height: 8px; background: var(--ink); }
.tag.near { background: var(--turq-2); }

/* ------------------------------------------------------------------ proximity card */
.near-card { position: fixed; left: 50%; bottom: calc(var(--gutter) + 8px); transform: translate(-50%, 140%); display: flex; align-items: center; gap: 14px; width: min(560px, calc(100vw - 2 * var(--gutter))); padding: 10px 12px 10px 10px; background: var(--paper-2); border: 2px solid var(--ink); border-radius: 18px 14px 20px 13px / 13px 20px 14px 18px; box-shadow: 4px 5px 0 rgba(35,40,32,.22); z-index: 25; transition: transform .35s cubic-bezier(.2,.9,.3,1.2); }
.near-card { visibility: hidden; opacity: 0; }
.near-card.on { transform: translate(-50%, 0); visibility: visible; opacity: 1; }
.near-card img { width: 58px; height: 58px; border-radius: 12px; border: 2px solid var(--ink); object-fit: cover; flex: none; }
.near-card div { display: grid; gap: 1px; min-width: 0; flex: 1; }
.near-card b { font: 700 20px/1.1 var(--hand); }
.near-card span { color: var(--ink-2); font-size: 13px; }
.near-card .btn { flex: none; }

/* ------------------------------------------------------------------ destinations menu */
.menu { position: fixed; top: calc(var(--gutter) + 52px); right: var(--gutter); width: min(360px, calc(100vw - 2 * var(--gutter))); display: grid; gap: 4px; padding: 8px; background: var(--paper-2); border: 2px solid var(--ink); border-radius: 16px 14px 18px 12px; box-shadow: 4px 5px 0 rgba(35,40,32,.22); z-index: 30; opacity: 0; transform: translateY(-8px) rotate(.4deg); pointer-events: none; transition: .2s; }
.menu.on { opacity: 1; transform: none; pointer-events: auto; }
.menu button { display: flex; gap: 10px; align-items: center; text-align: left; padding: 6px 8px; border: 0; background: transparent; border-radius: 10px; cursor: pointer; }
.menu button:hover { background: rgba(86,185,188,.18); }
.menu img { width: 40px; height: 40px; border-radius: 9px; border: 1.5px solid var(--ink); object-fit: cover; }
.menu b { display: block; font: 700 16px/1.1 var(--hand); }
.menu small { color: var(--ink-3); font-size: 12px; }

/* ------------------------------------------------------------------ panel */
.panel { position: fixed; top: var(--gutter); right: var(--gutter); bottom: var(--gutter); width: min(var(--panel-w), calc(100vw - 2 * var(--gutter))); display: grid; grid-template-rows: auto minmax(0, 1fr); background: var(--paper-2) url("../img/paper.webp?v=6") 0 0 / 1024px repeat; background-blend-mode: multiply; border: 2.5px solid var(--ink); border-radius: 22px 16px 24px 14px / 14px 24px 16px 22px; box-shadow: 6px 8px 0 rgba(35,40,32,.2); z-index: 40; transform: translateX(calc(100% + 40px)) rotate(1.5deg); transition: transform .45s cubic-bezier(.2,.9,.25,1); }
.panel.on { transform: none; }
.panel-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 16px 16px 12px; border-bottom: 2px dashed rgba(35,40,32,.35); }
.panel-head img { width: 64px; height: 64px; border-radius: 14px; border: 2px solid var(--ink); object-fit: cover; }
.panel-head h2 { margin: 0; font: 700 28px/1 var(--hand); }
.panel-head p { margin: 4px 0 0; color: var(--ink-2); font-size: 13px; }
.panel-body { overflow-y: auto; overflow-x: hidden; padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-content: start; }
.muted { color: var(--ink-3); }

/* ------------------------------------------------------------------ hints, touch, loader */
.hints { position: fixed; left: var(--gutter); bottom: var(--gutter); display: grid; gap: 6px; padding: 10px 12px; background: rgba(243,234,212,.9); border: 2px solid var(--ink); border-radius: 14px 12px 16px 11px; font-size: 12.5px; font-weight: 600; z-index: 15; transition: opacity .6s, transform .6s; }
.hints.gone { opacity: 0; transform: translateY(10px); pointer-events: none; }
.hints span { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.touch { display: none; }

.loader { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; background: var(--paper) url("../img/paper.webp?v=6") 0 0 / 1024px repeat; transition: opacity .8s, visibility .8s; }
.loader img { width: min(320px, 70vw); height: auto; filter: drop-shadow(3px 6px 0 rgba(35,40,32,.12)); animation: bob 2.4s ease-in-out infinite; }
.loader p { margin: 0; font: 700 22px/1.2 var(--hand); }
.loader.done { opacity: 0; visibility: hidden; }
@keyframes bob { 50% { transform: translateY(-10px) rotate(-2deg); } }

@media (hover: none) and (pointer: coarse) {
  .hints { display: none; }
  .touch { display: block; }
  .stick { position: fixed; left: calc(var(--gutter) + 6px); bottom: calc(var(--gutter) + 10px); width: 112px; height: 112px; border-radius: 50%; border: 2.5px solid var(--ink); background: rgba(243,234,212,.75); z-index: 22; touch-action: none; }
  .knob { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; border: 2.5px solid var(--ink); background: var(--turq-2); box-shadow: 2px 3px 0 var(--ink); }
  .interact { position: fixed; right: calc(var(--gutter) + 6px); bottom: calc(var(--gutter) + 40px); z-index: 22; min-height: 56px; }
  .near-card { bottom: calc(var(--gutter) + 138px); }
}

@media (max-width: 720px) {
  .brand .word { font-size: 24px; }
  .brand .motto { font-size: 10.5px; letter-spacing: .08em; white-space: nowrap; }
  .brand { padding: 6px 12px 8px; }
  .chip { display: none; }
  .panel { top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 78dvh; border-radius: 22px 22px 0 0; border-bottom: 0; transform: translateY(105%); }
  .panel.on { transform: none; }
  .near-card .btn kbd { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ------------------------------------------------------------------ panel content */
.panel-body small { display: block; color: var(--ink-3); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.panel-body em { font-style: normal; color: var(--ink-3); font-size: .7em; font-weight: 600; margin-left: 2px; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stats.one { grid-template-columns: minmax(0, 1fr); }
.stats > div { padding: 10px 12px; background: rgba(255,255,255,.45); border: 2px solid var(--ink); border-radius: 12px 10px 13px 9px; min-width: 0; }
.stats b { display: block; font: 700 21px/1.15 var(--sans); font-variant-numeric: tabular-nums; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.assets { display: grid; gap: 6px; }
.assets button { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 10px; align-items: center; text-align: left; padding: 8px 10px; border: 2px solid var(--ink); border-radius: 12px; background: rgba(255,255,255,.35); cursor: pointer; }
.assets button.on { background: linear-gradient(170deg, rgba(168,224,216,.9), rgba(124,207,199,.8)); }
.assets .sym { grid-row: span 2; font: 700 17px/1 var(--hand); }
.assets .nm { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.assets .px { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.assets .lt { grid-column: 3; font-size: 11.5px; color: var(--ink-2); text-align: right; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border: 2px solid var(--ink); border-radius: 13px; background: rgba(255,255,255,.3); }
.seg button { border: 0; border-radius: 9px; padding: 8px 6px; background: transparent; font-weight: 700; cursor: pointer; }
.seg button.on { background: var(--ink); color: var(--paper-2); }
.amount { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 14px; border: 2.5px solid var(--ink); border-radius: 14px 12px 15px 11px; background: #FBF6EA; }
.amount:focus-within { box-shadow: 0 0 0 3px rgba(86,185,188,.45); }
.amount input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: 700 24px/1.2 var(--sans); font-variant-numeric: tabular-nums; padding: 8px 0; }
.amount span { font-weight: 700; color: var(--ink-2); }
.max { border: 2px solid var(--ink); background: var(--paper-2); border-radius: 9px; padding: 6px 9px; font-weight: 700; font-size: 11.5px; cursor: pointer; }
.hint { margin: -4px 0 0; font-size: 12.5px; color: var(--ink-2); }
.fine { margin: 0; font-size: 12px; color: var(--ink-3); line-height: 1.5; }
.lead { margin: 0; font-size: 14px; line-height: 1.55; }
.terms { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; margin: 0; padding: 10px 12px; border: 2px dashed rgba(35,40,32,.35); border-radius: 12px; font-size: 13px; }
.terms dt { color: var(--ink-2); }
.terms dd { margin: 0; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.btn.block { width: 100%; min-height: 48px; font-size: 15px; }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gate { display: grid; gap: 10px; padding: 14px; border: 2px dashed var(--ink); border-radius: 14px; text-align: center; }
.gate p { margin: 0; color: var(--ink-2); }
.meter { position: relative; height: 12px; border: 2px solid var(--ink); border-radius: 999px; background: rgba(255,255,255,.4); overflow: hidden; }
.meter span { position: absolute; inset: 0 auto 0 0; background: var(--turq); transition: width .6s; }
.meter span.hot { background: var(--red); }
.meter i { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); }
.health { display: grid; justify-items: center; gap: 2px; padding: 16px; border: 2.5px solid var(--ink); border-radius: 18px 14px 20px 13px; background: rgba(143,214,204,.35); text-align: center; }
.health b { font: 700 52px/1 var(--sans); font-variant-numeric: tabular-nums; }
.health span { font: 700 22px/1.1 var(--hand); }
.health p { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); }
.health.watch { background: rgba(221,195,127,.45); }
.health.warn { background: rgba(240,180,90,.5); }
.health.danger { background: rgba(196,90,66,.35); }
.table { border: 2px solid var(--ink); border-radius: 12px; overflow: hidden; font-size: 13px; }
.thead, .tr { display: grid; grid-template-columns: 1.1fr 1fr 1.3fr; gap: 8px; padding: 8px 10px; }
.thead { background: var(--ink); color: var(--paper-2); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }
.tr + .tr { border-top: 1px dashed rgba(35,40,32,.3); }
.tr span:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.pad { padding: 10px; margin: 0; }
.sub { margin: 4px 0 -6px; font: 700 20px/1 var(--hand); }
.evict { display: grid; gap: 6px; }
.ev { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 10px; align-items: center; padding: 6px 8px; border: 2px solid var(--ink); border-radius: 11px; font-size: 13px; background: rgba(255,255,255,.35); }
.ev .bad { color: var(--red); }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.link { border: 0; background: none; padding: 0; color: var(--blue-line); text-decoration: underline; cursor: pointer; font-weight: 700; }
.tiers { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.tiers > div { display: grid; gap: 1px; padding: 8px 6px; border: 2px solid var(--ink); border-radius: 11px; text-align: center; background: rgba(255,255,255,.35); }
.tiers b { font: 700 14px/1.1 var(--hand); }
.tiers small { font-size: 9.5px; letter-spacing: .02em; }
.tiers > div em { font-size: 11px; color: var(--palm); }
.tiers > div.on { background: linear-gradient(170deg, #F0CF79, #DDB14E); }
.slider { display: grid; gap: 6px; font-size: 13px; }
.slider input { accent-color: var(--ink); }
.clocks { display: grid; gap: 8px; }
.clock { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; align-items: center; padding: 8px; border: 2px solid var(--ink); border-radius: 13px; background: rgba(255,255,255,.35); }
.clock div:last-child { display: grid; font-size: 12.5px; color: var(--ink-2); }
.clock div:last-child b { font: 700 18px/1 var(--hand); color: var(--ink); }
.ring { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--ink); background: conic-gradient(var(--turq) calc(var(--p) * 360deg), rgba(255,255,255,.5) 0); }
.ring b { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--paper-2); border: 2px solid var(--ink); font: 700 16px/1 var(--sans); }
.tx { display: grid; gap: 6px; padding: 10px 12px; border: 2px solid var(--ink); border-radius: 12px; background: #FBF6EA; font-size: 13px; }
.tx ol { display: flex; gap: 10px; margin: 0; padding: 0; list-style: none; flex-wrap: wrap; }
.tx li { color: var(--ink-3); }
.tx li::before { content: "○ "; }
.tx li.done { color: var(--palm); }
.tx li.done::before { content: "● "; }
.tx li.now { color: var(--ink); font-weight: 700; }
.tx li.now::before { content: "◐ "; }
.tx.failed { background: rgba(196,90,66,.18); }
.tx.confirmed { background: rgba(143,214,204,.45); }
.chip.warn i { background: var(--red); }
.picker { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; background: rgba(35,40,32,.35); }
.picker .sheet { display: grid; gap: 8px; width: min(360px, calc(100vw - 32px)); padding: 16px; background: var(--paper-2); border: 2.5px solid var(--ink); border-radius: 18px; }
.picker h3 { margin: 0 0 4px; font: 700 24px/1 var(--hand); }
.picker [data-i] { display: flex; gap: 10px; align-items: center; padding: 10px; border: 2px solid var(--ink); border-radius: 12px; background: #FBF6EA; cursor: pointer; font-weight: 700; }
.picker img { width: 28px; height: 28px; }

.acct-menu { position: fixed; top: calc(var(--gutter) + 52px); right: calc(var(--gutter) + 48px); z-index: 60; display: grid; gap: 8px; width: min(300px, calc(100vw - 2 * var(--gutter))); padding: 12px; background: var(--paper-2); border: 2px solid var(--ink); border-radius: 14px 12px 16px 11px; box-shadow: 4px 5px 0 rgba(35,40,32,.22); opacity: 0; transform: translateY(-6px); pointer-events: none; transition: .18s; }
.acct-menu.on { opacity: 1; transform: none; pointer-events: auto; }
.acct-menu code { font-size: 12px; overflow-wrap: anywhere; }
.acct-menu .btn.block { min-height: 40px; font-size: 14px; }

.tiers > div { min-width: 0; }
.tiers small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 460px) { .tiers { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.preview-ribbon { position: fixed; left: 50%; top: calc(var(--gutter) + 4px); transform: translateX(-50%) rotate(-.6deg); z-index: 21; display: flex; gap: 8px; align-items: center; padding: 6px 12px; background: #F6E3A4; border: 2px solid var(--ink); border-radius: 10px 12px 9px 13px; box-shadow: 2px 3px 0 rgba(35,40,32,.2); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.preview-ribbon b { font: 700 15px/1 var(--hand); }
@media (max-width: 980px) { .preview-ribbon { top: auto; bottom: calc(var(--gutter) + 4px); left: auto; right: var(--gutter); transform: none; white-space: normal; max-width: 60vw; font-size: 11.5px; } }
@media (hover: none) and (pointer: coarse) { .preview-ribbon { bottom: auto; top: calc(var(--gutter) + 70px); right: var(--gutter); } }
.panel-note { margin: 0; padding: 8px 10px; border: 2px dashed rgba(35,40,32,.4); border-radius: 10px; font-size: 12px; color: var(--ink-2); background: rgba(246,227,164,.45); }

#soundBtn .off { display: none; }
#soundBtn.muted .on { display: none; }
#soundBtn.muted .off { display: block; }
#soundBtn.muted { background: var(--paper-3); }
