/* styles.css: how every screen looks. Colours are set once at the top. */

:root {
  --ui: 1;
  --ink: #2a1d12;
  --paper: #f3e6c8;
  --paper2: #e8d6ae;
  --edge: #8a6a3a;
  --sea: #0e2a44;
  --gold: #f2d377;
  --red: #c8432f;
  --green: #3f8f3a;
  --blue: #2f5f8a;
  --text: #fff8e6;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  --display: 'Pirata One', Georgia, 'Times New Roman', serif;
  --body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: calc(16px * var(--ui));
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--sea); color: var(--text); font-family: var(--body); }
body { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none; }
input, select { -webkit-user-select: text; user-select: text; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--gold); }
p { margin: 0.4em 0; line-height: 1.4; }
.small { font-size: 0.82rem; opacity: 0.85; }

#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; image-rendering: pixelated; }
#loading, .noscript { position: fixed; inset: 0; display: grid; place-items: center; font-family: var(--display); font-size: 2rem; background: var(--sea); z-index: 50; text-align: center; padding: 1em; }

/* ------------------------------------------------------------ buttons */

.btn {
  background: linear-gradient(#fff4d8, #e2cc9a); color: var(--ink); border: 2px solid var(--edge); border-radius: 8px;
  padding: 0.45em 0.9em; font-weight: 600; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); min-height: 2.4em;
}
.btn:hover:not(:disabled) { filter: brightness(1.06); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: 0.5; }
.btn:focus-visible, .choice:focus-visible, .tab:focus-visible, .slot:focus-visible { outline: 3px solid #4ab0ff; outline-offset: 2px; }
.btn.primary { background: linear-gradient(#ffe08a, #e5a93a); border-color: #8a5a1a; }
.btn.danger { background: linear-gradient(#ffb8a8, #d9705a); border-color: #7a2a1a; }
.btn.big { font-size: 1.1rem; padding: 0.6em 1.2em; }
.btn.close { min-width: 2.4em; padding: 0.3em 0.6em; }
.small-btn { min-width: 2.4em; }
.btn-row { display: flex; gap: 0.5em; flex-wrap: wrap; margin-top: 0.6em; align-items: center; }

/* ------------------------------------------------------------ title and new captain */

#title { position: fixed; inset: 0; z-index: 40; overflow-y: auto; display: flex; justify-content: center; align-items: flex-start; padding: max(4vh, env(safe-area-inset-top)) 1em 2em; touch-action: pan-y; }
.title-inner { margin: auto; text-align: center; display: flex; flex-direction: column; gap: 2rem; align-items: center; }
.logo-main { font-family: var(--display); font-size: clamp(3.5rem, 13vw, 7rem); color: var(--gold); text-shadow: 0 4px 0 #6a3a10, 0 8px 24px rgba(0, 0, 0, 0.6); line-height: 1; letter-spacing: 0.03em; }
.logo-sub { font-family: var(--display); font-size: clamp(1.3rem, 4.5vw, 2rem); color: #f3e6c8; margin-top: 0.2em; }
.menu-buttons { display: flex; flex-direction: column; gap: 0.6rem; width: min(320px, 80vw); }
.title-foot { display: flex; gap: 0.6em; flex-wrap: wrap; justify-content: center; font-size: 0.85rem; opacity: 0.85; }

.create { background: var(--paper); color: var(--ink); border: 3px solid var(--edge); border-radius: 14px; padding: 1.2em; width: min(980px, 100%); box-shadow: var(--shadow); margin: auto; }
.create h1 { font-family: var(--display); margin: 0 0 0.5em; font-size: 2.2rem; text-align: center; }
.create-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4em; }
.create-left, .create-right { display: flex; flex-direction: column; gap: 0.5em; }
.row { display: flex; align-items: center; gap: 0.6em; flex-wrap: wrap; }
.row-label { font-weight: 700; min-width: 4em; }
.name-row { display: flex; gap: 0.5em; }
.name-word { flex: 1; font: inherit; padding: 0.5em; border: 2px solid var(--edge); border-radius: 8px; background: #fffaf0; color: var(--ink); min-width: 0; }
.preview { display: flex; gap: 0.6em; justify-content: center; background: #cfe4c0; border-radius: 10px; padding: 0.5em; border: 2px solid var(--edge); }
.preview canvas { image-rendering: pixelated; width: 48px; height: 72px; }
.swatches, .opts { display: flex; gap: 0.35em; flex-wrap: wrap; }
.swatch { width: 2em; height: 2em; border-radius: 50%; border: 2px solid rgba(0, 0, 0, 0.4); }
.swatch.on { outline: 3px solid var(--ink); outline-offset: 2px; }
.opt { background: #fffaf0; color: var(--ink); border: 2px solid var(--edge); border-radius: 8px; padding: 0.3em 0.7em; }
.opt.on, .style-card.on { background: #ffe08a; border-color: #8a5a1a; }
.style-cards { display: flex; flex-direction: column; gap: 0.5em; }
.style-card { text-align: left; background: #fffaf0; color: var(--ink); border: 2px solid var(--edge); border-radius: 10px; padding: 0.6em 0.8em; display: flex; flex-direction: column; gap: 0.2em; }
.create-buttons { display: flex; justify-content: space-between; margin-top: 1em; gap: 1em; }
.controls table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.controls td { padding: 0.15em 0.4em; border-bottom: 1px solid rgba(0, 0, 0, 0.1); }
.controls td.k { font-weight: 700; white-space: nowrap; }

/* ------------------------------------------------------------ pop-ups */

#modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(5, 15, 25, 0.55); padding: 1em; }
.modal-box { background: var(--paper); color: var(--ink); border: 3px solid var(--edge); border-radius: 14px; padding: 1.1em 1.3em; width: min(520px, 100%); max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow); touch-action: pan-y; }
.modal-box.wide { width: min(720px, 100%); }
.modal-box h2 { font-family: var(--display); font-size: 1.9rem; margin: 0 0 0.3em; }
.modal-text { margin-bottom: 0.8em; }
.modal-buttons { display: flex; gap: 0.5em; flex-wrap: wrap; justify-content: flex-end; }
.modal-box.choices .modal-buttons, .modal-box.pause .modal-buttons { flex-direction: column; align-items: stretch; }
.choice-btn { text-align: left; }
.slot { display: flex; justify-content: space-between; align-items: center; gap: 0.6em; padding: 0.6em 0; border-bottom: 1px solid rgba(0, 0, 0, 0.12); }
.slot-btns { display: flex; gap: 0.4em; flex-wrap: wrap; justify-content: flex-end; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 1em; padding: 0.5em 0; border-bottom: 1px solid rgba(0, 0, 0, 0.1); }
.setting input[type=range] { width: 50%; }
.setting select { font: inherit; padding: 0.3em; }
.setting input[type=checkbox] { width: 1.4em; height: 1.4em; }

/* ------------------------------------------------------------ HUD */

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; font-size: 0.9rem; }
#hud button { pointer-events: auto; }
.hud-top-left { position: absolute; left: max(10px, env(safe-area-inset-left)); top: max(10px, env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 6px; max-width: min(340px, 60vw); }
#hud-bars { display: flex; flex-direction: column; gap: 4px; width: min(220px, 48vw); }
.hbar { display: flex; align-items: center; gap: 5px; }
.hbar-label { width: 1.3em; text-align: center; font-size: 0.85rem; }
.hbar-track { flex: 1; height: 12px; background: rgba(0, 0, 0, 0.55); border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 6px; overflow: hidden; }
.hbar-fill { height: 100%; width: 100%; transition: width 0.15s; }
.hp .hbar-fill { background: linear-gradient(#ff7a6a, #c8332a); }
.st .hbar-fill { background: linear-gradient(#ffe27a, #d9a01a); }
.hu .hbar-fill { background: linear-gradient(#ffc08a, #c8742a); }
.hbar-num { font-weight: 700; font-size: 0.8rem; min-width: 2em; text-shadow: 0 1px 2px #000; }
#hud-bars.starving .hu .hbar-track { animation: pulse 0.8s infinite alternate; border-color: #ff4a3a; }
@keyframes pulse { to { box-shadow: 0 0 10px #ff4a3a; } }
.hud-row { display: flex; gap: 5px; flex-wrap: wrap; }
.hud-chip { background: rgba(10, 20, 30, 0.7); border-radius: 12px; padding: 2px 9px; font-weight: 600; white-space: nowrap; }
.hud-chip.bounty { color: #ff9a8a; }
.hud-chip.online { color: #bfe8ff; border: 0; font: inherit; font-weight: 600; cursor: pointer; pointer-events: auto; }
/* Emotes while online: a row at the bottom in the middle, or above the stick on touch screens. */
#emotes { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(10px, env(safe-area-inset-bottom)); z-index: 21; display: flex; gap: 4px; }
#emotes button { width: 38px; height: 38px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.35); background: rgba(10, 20, 30, 0.7); font-size: 18px; line-height: 1; cursor: pointer; padding: 0; }
#emotes button:active { transform: scale(0.92); }
body.touch #emotes { left: max(18px, env(safe-area-inset-left)); transform: none; bottom: calc(max(18px, env(safe-area-inset-bottom)) + 142px); }
@media (max-height: 480px) { body.touch #emotes { bottom: calc(max(18px, env(safe-area-inset-bottom)) + 118px); } #emotes button { width: 34px; height: 34px; font-size: 16px; } }
/* The online menu */
.online-list { list-style: none; padding: 0; margin: 0.5em 0; }
.online-list li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.online-list .seat { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.code-big { font-size: 2.2rem; letter-spacing: 0.3em; font-weight: 800; text-align: center; margin: 0.3em 0; color: #8a4a10; }
.code-input { font-size: 1.8rem; letter-spacing: 0.3em; text-transform: uppercase; text-align: center; width: 7em; display: block; margin: 0.4em auto; padding: 0.2em; border-radius: 8px; border: 2px solid var(--gold); background: #fffaf0; color: #2a1a0a; }
#hud-quest { background: rgba(10, 20, 30, 0.72); border-left: 4px solid var(--gold); border-radius: 6px; padding: 5px 9px; }
#hud-quest-title { color: var(--gold); font-weight: 700; font-size: 0.85rem; }
#hud-quest-text { font-size: 0.85rem; }
.hud-top-right { position: absolute; right: max(10px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); display: flex; gap: 6px; }
.hud-btn { width: 2.6em; height: 2.6em; border-radius: 10px; background: rgba(10, 20, 30, 0.75); color: var(--text); border: 2px solid rgba(255, 255, 255, 0.3); font-size: 1.1rem; }
.hud-bottom-left { position: absolute; left: max(10px, env(safe-area-inset-left)); bottom: max(10px, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 6px; background: rgba(10, 20, 30, 0.7); border-radius: 10px; padding: 4px 10px 4px 4px; }
#hud-weapon-icon { width: 32px; height: 32px; image-rendering: pixelated; }
body.touch .hud-bottom-left { display: none; }
#hud-ship { position: absolute; right: max(10px, env(safe-area-inset-right)); top: calc(max(10px, env(safe-area-inset-top)) + 3.2em); background: rgba(10, 20, 30, 0.75); border-radius: 10px; padding: 6px 10px; display: flex; flex-direction: column; gap: 3px; width: min(230px, 45vw); font-size: 0.82rem; }
.ship-line { display: flex; align-items: center; gap: 6px; }
#bar-ship { background: linear-gradient(#c8a070, #8a5a33); }
#hud-prov.low { color: #ff9a6a; font-weight: 700; }
#hud-wind { display: inline-block; color: #9fd8ff; transition: transform 0.4s; }
#bossbar { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(max(10px, env(safe-area-inset-bottom)) + 3.4em); width: min(480px, 80vw); text-align: center; }
#boss-name { font-family: var(--display); font-size: 1.3rem; text-shadow: 0 2px 4px #000; }
.boss-track { height: 14px; background: rgba(0, 0, 0, 0.6); border: 2px solid #c9a03a; border-radius: 7px; overflow: hidden; }
#boss-fill { height: 100%; background: linear-gradient(#ff5a4a, #8a1a1a); transition: width 0.15s; }
#prompt { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(max(14px, env(safe-area-inset-bottom)) + 4.5em); background: rgba(10, 20, 30, 0.85); border: 2px solid var(--gold); border-radius: 10px; padding: 5px 14px; font-weight: 700; white-space: nowrap; max-width: 90vw; overflow: hidden; text-overflow: ellipsis; }
body.touch #prompt { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 10.5em); }
#saved { position: absolute; right: 12px; bottom: 12px; background: rgba(10, 20, 30, 0.75); padding: 3px 10px; border-radius: 8px; font-size: 0.8rem; }
body.touch #saved { bottom: auto; top: 3.6em; }

/* ------------------------------------------------------------ messages */

#toasts { position: fixed; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 30; display: flex; flex-direction: column; gap: 6px; align-items: center; width: min(520px, 46vw); pointer-events: none; }
.toast { background: rgba(10, 20, 30, 0.88); border-left: 4px solid #9fb8c8; border-radius: 6px; padding: 6px 12px; font-size: 0.88rem; box-shadow: var(--shadow); animation: toastIn 0.25s ease-out; transition: opacity 0.4s, transform 0.4s; max-width: 100%; }
.toast.out { opacity: 0; transform: translateY(-8px); }
.toast.good { border-color: #6ad05a; }
.toast.warn { border-color: #f2b33a; }
.toast.bad { border-color: #ff5a4a; }
.toast.quest { border-color: var(--gold); color: var(--gold); font-weight: 700; }
.toast.tip { border-color: #4ab0ff; }
.toast.crew { border-color: #c88aff; font-style: italic; }
.toast.rep { border-color: #8ad0c8; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }
@media (max-width: 760px) { #toasts { width: min(92vw, 520px); top: auto; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 13em); } }

#banner { position: fixed; left: 50%; top: 26%; transform: translateX(-50%); z-index: 25; text-align: center; pointer-events: none; animation: bannerIn 0.6s ease-out; transition: opacity 0.6s; width: 90vw; }
#banner.out { opacity: 0; }
.b-small { font-size: 0.9rem; letter-spacing: 0.3em; text-transform: uppercase; opacity: 0.85; text-shadow: 0 2px 4px #000; }
.b-title { font-family: var(--display); font-size: clamp(2.4rem, 8vw, 4.2rem); color: var(--gold); text-shadow: 0 3px 0 #6a3a10, 0 6px 20px rgba(0, 0, 0, 0.7); }
.b-text { font-size: 1rem; text-shadow: 0 2px 4px #000; }
@keyframes bannerIn { from { opacity: 0; transform: translateX(-50%) scale(0.9); } }

/* ------------------------------------------------------------ dialogue */

#dialogue {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: max(10px, env(safe-area-inset-bottom)); z-index: 35;
  width: min(760px, calc(100vw - 20px)); max-height: 60vh; overflow-y: auto; background: var(--paper); color: var(--ink);
  border: 3px solid var(--edge); border-radius: 14px; padding: 0.9em 1.1em; box-shadow: var(--shadow); touch-action: pan-y;
}
.dlg-head { display: flex; align-items: center; gap: 0.7em; }
.portrait { width: 56px; height: 56px; image-rendering: pixelated; border-radius: 10px; border: 2px solid var(--edge); background: #cfe4c0; flex-shrink: 0; }
.portrait.big { width: 80px; height: 80px; }
.portrait.blank { display: grid; place-items: center; font-size: 1.6rem; background: #2a3a4a; color: #3ad08a; }
.dlg-name { font-family: var(--display); font-size: 1.6rem; }
.dlg-text { margin: 0.5em 0; font-size: 1.02rem; -webkit-user-select: text; user-select: text; }
.dlg-choices { display: flex; flex-direction: column; gap: 0.35em; }
.choice { text-align: left; background: #fffaf0; color: var(--ink); border: 2px solid var(--edge); border-radius: 8px; padding: 0.5em 0.7em; display: flex; gap: 0.6em; align-items: baseline; }
.choice:hover { background: #ffe9b0; }
.choice .key { background: var(--edge); color: #fff; border-radius: 4px; padding: 0 0.4em; font-size: 0.8rem; font-weight: 700; flex-shrink: 0; }
body.touch .choice .key { display: none; }

/* ------------------------------------------------------------ the captain's book and other panels */

#panel { position: fixed; inset: 0; z-index: 45; background: rgba(5, 15, 25, 0.55); display: grid; place-items: center; padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
.panel-box { background: var(--paper); color: var(--ink); border: 3px solid var(--edge); border-radius: 14px; width: min(1040px, 100%); height: min(720px, 100%); display: flex; flex-direction: column; box-shadow: var(--shadow); overflow: hidden; }
.panel-chooser, .panel-shop, .panel-shipyard, .panel-build { height: auto; max-height: 100%; }
.panel-head { display: flex; align-items: center; gap: 0.5em; padding: 0.5em 0.6em; background: var(--paper2); border-bottom: 2px solid var(--edge); }
.panel-title { font-family: var(--display); font-size: 1.7rem; margin: 0; flex: 1; }
.panel-gold { font-weight: 700; white-space: nowrap; font-size: 0.9rem; margin-left: auto; }
.tabs { display: flex; gap: 0.25em; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tab { background: transparent; border: 2px solid transparent; border-radius: 8px; padding: 0.35em 0.7em; color: var(--ink); font-weight: 700; white-space: nowrap; }
.tab.on { background: #fffaf0; border-color: var(--edge); }
.tab-key { font-size: 0.7rem; opacity: 0.55; margin-left: 0.35em; }
body.touch .tab-key { display: none; }
.panel-body { flex: 1; overflow-y: auto; padding: 0.8em 1em 1.2em; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2em; align-items: start; }
.psec { margin-top: 0.8em; }
.psec h3 { font-family: var(--display); font-size: 1.35rem; margin: 0 0 0.3em; border-bottom: 1px solid rgba(0, 0, 0, 0.15); }
h3 { margin: 0.2em 0; }
.cats { display: flex; gap: 0.3em; flex-wrap: wrap; margin-bottom: 0.6em; }
.chip { background: #fffaf0; border: 2px solid var(--edge); border-radius: 14px; padding: 0.2em 0.7em; color: var(--ink); font-size: 0.85rem; }
.chip.on { background: #ffe08a; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 5px; }
.slots .slot, .qbag .slot { position: relative; aspect-ratio: 1; display: grid; place-items: center; background: #fffaf0; border: 2px solid var(--edge); border-radius: 8px; padding: 0; }
.slots .slot.empty { background: rgba(255, 255, 255, 0.35); border-style: dashed; }
.slot.on { background: #ffe08a !important; }
.slot.worn::after { content: 'E'; position: absolute; top: 1px; left: 3px; font-size: 0.65rem; font-weight: 800; color: var(--blue); }
.qty { position: absolute; right: 3px; bottom: 1px; font-size: 0.75rem; font-weight: 800; text-shadow: 0 0 2px #fff, 0 0 2px #fff; }
.qbag { display: flex; gap: 5px; flex-wrap: wrap; }
.qbag .slot { width: 52px; }
.icon { width: 32px; height: 32px; image-rendering: pixelated; flex-shrink: 0; }
.icon.sm { width: 18px; height: 18px; vertical-align: middle; }
.icon.big { width: 44px; height: 44px; }
.icon.blank { display: inline-block; }
.equips { display: flex; flex-direction: column; gap: 4px; }
.equip-slot { display: grid; grid-template-columns: 4.5em 32px 1fr; align-items: center; gap: 0.5em; text-align: left; background: #fffaf0; border: 2px solid var(--edge); border-radius: 8px; padding: 0.25em 0.5em; color: var(--ink); }
.detail { background: #fffaf0; border: 2px solid var(--edge); border-radius: 10px; padding: 0.8em; }
.detail.empty { opacity: 0.75; font-style: italic; }
.detail-head { display: flex; gap: 0.6em; align-items: center; }
.recipe, .shop-row { display: flex; align-items: center; gap: 0.7em; padding: 0.5em 0.3em; border-bottom: 1px solid rgba(0, 0, 0, 0.1); }
.recipe.can { background: rgba(120, 200, 90, 0.12); }
.recipe-main, .shop-main { flex: 1; min-width: 0; }
.costs { display: flex; gap: 0.3em 0.8em; flex-wrap: wrap; margin-top: 0.2em; }
.cost { font-size: 0.82rem; font-weight: 600; white-space: nowrap; }
.cost.ok { color: #2a6a22; }
.cost.no { color: #a8301f; }
.block { color: #a8301f; font-size: 0.82rem; font-weight: 600; }
.good-text { color: #2a6a22; font-weight: 600; }
.qlist { display: flex; flex-direction: column; gap: 4px; }
.qitem { text-align: left; background: #fffaf0; border: 2px solid var(--edge); border-radius: 8px; padding: 0.4em 0.6em; color: var(--ink); display: flex; gap: 0.5em; align-items: center; }
.qitem.on { background: #ffe08a; }
.qitem.done { opacity: 0.65; }
.qtype { font-size: 0.7rem; font-weight: 800; text-transform: uppercase; padding: 0.1em 0.4em; border-radius: 4px; background: #c9b890; white-space: nowrap; }
.t-main { background: #e5a93a; }
.t-companion { background: #c8a0f0; }
.t-bounty { background: #f0a090; }
.t-treasure { background: #f2d377; }
.t-side { background: #a8d8a0; }
.tracked { margin-left: auto; color: #8a5a1a; }
.qdone summary { cursor: pointer; font-weight: 700; margin: 0.6em 0 0.3em; }
.objs { padding-left: 0.2em; list-style: none; }
.objs li { margin: 0.25em 0; }
.objs li.done { color: #2a6a22; text-decoration: line-through; opacity: 0.8; }
.map-wrap { background: #0d1a26; border: 3px solid var(--edge); border-radius: 10px; overflow: hidden; }
.map-wrap { display: flex; justify-content: center; }
.worldmap { width: 100%; max-height: calc(100vh - 13em); object-fit: contain; display: block; image-rendering: pixelated; }
.legend { display: flex; gap: 1em; flex-wrap: wrap; font-size: 0.82rem; margin-top: 0.4em; }
.dot { display: inline-block; width: 0.8em; height: 0.8em; border-radius: 50%; margin-right: 0.3em; vertical-align: middle; border: 1px solid #fff; }
.dot.me { background: #ff4a3a; }
.dot.ship { background: #8a5a33; }
.dot.goal { background: #ffd34a; border-radius: 2px; transform: rotate(45deg); border-color: #000; }
.dot.friend { background: linear-gradient(90deg, #6ab0ff 50%, #7ad06a 50%); border-color: #000; }
.dot.storm { background: transparent; border: 2px dashed #a888d8; }
.cap-head { display: flex; gap: 0.8em; align-items: center; }
.cap-head > div { flex: 1; }
.mbar { height: 10px; background: rgba(0, 0, 0, 0.18); border-radius: 5px; overflow: hidden; margin: 0.2em 0; min-width: 60px; }
.mbar-fill { height: 100%; background: #6a9ad0; }
.mbar.xp .mbar-fill { background: #4ab0ff; }
.mbar.good .mbar-fill { background: #5ab04a; }
.mbar.bad .mbar-fill { background: #d0503a; }
.mbar.gold .mbar-fill { background: #e5a93a; }
.mbar.hp .mbar-fill { background: #d0503a; }
.stat-row, .skill { display: flex; align-items: center; justify-content: space-between; gap: 0.6em; padding: 0.35em 0; border-bottom: 1px solid rgba(0, 0, 0, 0.08); }
.skill.have strong { color: #2a6a22; }
.skill-tree { margin-bottom: 0.5em; }
.tree-name { font-weight: 800; text-transform: uppercase; font-size: 0.78rem; letter-spacing: 0.08em; color: var(--edge); margin-top: 0.4em; }
.rep-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 0.6em; align-items: center; font-size: 0.88rem; }
.crew-card { display: flex; gap: 0.8em; align-items: flex-start; background: #fffaf0; border: 2px solid var(--edge); border-radius: 10px; padding: 0.7em; margin: 0.5em 0; }
.crew-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.15em; }
.crew-bars { display: grid; grid-template-columns: auto 1fr; gap: 0.1em 0.6em; align-items: center; margin-top: 0.3em; max-width: 340px; }
.crew-btns { display: flex; flex-direction: column; gap: 0.4em; }
table.stats { border-collapse: collapse; margin: 0.6em 0; }
table.stats td { padding: 0.2em 0.8em 0.2em 0; }
table.stats td:first-child { font-weight: 700; }
.stage { padding: 0.5em; border-radius: 8px; margin: 0.3em 0; background: rgba(255, 255, 255, 0.4); border: 2px solid transparent; }
.stage.now { border-color: #e5a93a; background: #fffaf0; }
.stage.done { opacity: 0.65; }
.btn-row.wrap .btn { font-size: 0.85rem; display: inline-flex; gap: 0.3em; align-items: center; }
.choose-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.8em; margin-top: 0.6em; }
.choose-card { background: #fffaf0; border: 2px solid var(--edge); border-radius: 12px; padding: 0.8em; display: flex; flex-direction: column; gap: 0.2em; }
.choose-card.on { border-color: #e5a93a; box-shadow: 0 0 0 3px rgba(229, 169, 58, 0.4); }
.choose-card h3 { font-family: var(--display); font-size: 1.5rem; }
.choose-card .role { font-weight: 800; text-transform: uppercase; font-size: 0.8rem; color: var(--edge); }
.choose-card .btn { margin-top: auto; }

/* ------------------------------------------------------------ touch controls */

#touch { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
#stick { position: absolute; left: max(18px, env(safe-area-inset-left)); bottom: max(18px, env(safe-area-inset-bottom)); width: 132px; height: 132px; border-radius: 50%; background: rgba(255, 255, 255, 0.12); border: 2px solid rgba(255, 255, 255, 0.35); pointer-events: auto; touch-action: none; }
#stick .knob { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; background: rgba(255, 255, 255, 0.45); border: 2px solid rgba(255, 255, 255, 0.7); }
.tbtns { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(2, 56px); gap: 10px; pointer-events: auto; }
.tbtn { width: 56px; height: 56px; border-radius: 50%; background: rgba(10, 20, 30, 0.6); color: #fff; border: 2px solid rgba(255, 255, 255, 0.45); font-size: 1.4rem; touch-action: none; padding: 0; }
.tbtn.big { background: rgba(200, 130, 40, 0.7); }
.tbtn.down { transform: scale(0.92); background: rgba(255, 210, 100, 0.8); }
#btn-interact.ready { background: rgba(80, 200, 90, 0.85); box-shadow: 0 0 12px rgba(120, 255, 120, 0.8); }
body.at-sea .tbtn[data-act=block], body.at-sea .tbtn[data-act=special] { opacity: 0.35; }

/* ------------------------------------------------------------ small screens */

@media (max-width: 760px) {
  .create-grid, .two-col, .choose-cards { grid-template-columns: 1fr; }
  .panel-box { height: 100%; }
  .panel-gold { display: none; }
  .hud-top-left { max-width: 62vw; }
  #hud-quest { font-size: 0.8rem; }
  .rep-row { grid-template-columns: 1fr 1fr; }
  .rep-row .small { grid-column: 1 / -1; }
}
@media (max-height: 480px) {
  #dialogue { max-height: 75vh; }
  .portrait { width: 40px; height: 40px; }
  #stick { width: 110px; height: 110px; }
  .tbtns { grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(2, 48px); }
  .tbtn { width: 48px; height: 48px; font-size: 1.2rem; }
  body.touch #prompt { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 8em); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
