@font-face {
  font-family: 'Just Another Hand';
  src: url('../assets/JustAnotherHand.ttf') format('truetype');
  font-display: block;
}
:root {
  --red: #fa0d0d;
  --gold: #ffcd77;
  --dark: #161616;
  --glass: rgba(22, 22, 22, 0.72);
  --line: rgba(255, 205, 119, 0.28);
  --btn: 56px;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  /* visible viewport size: JS keeps these in sync with window.visualViewport */
  --app-w: 100vw;
  --app-h: 100vh;
}
@supports (height: 100dvh) { :root { --app-h: 100dvh; --app-w: 100dvw; } }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; width: 100%; position: fixed; inset: 0; overflow: hidden; background: var(--dark); color: #fff;
  font-family: 'Just Another Hand', cursive; letter-spacing: 0.04em;
  user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none;
}
button, input { font-family: 'Just Another Hand', cursive; letter-spacing: 0.05em; }
#game, #hud, #bars, #popups, .overlay { position: fixed; top: 0; left: 0; width: var(--app-w); height: var(--app-h); }
#game { display: block; }
.hidden { display: none !important; }
.muted { color: rgba(255,255,255,0.6); }
.gold { color: var(--gold); }
.red { color: var(--red); }
.label { color: var(--gold); font-size: 0.85em; opacity: 0.9; margin-right: 4px; }

/* ---------- HUD ---------- */
#hud { pointer-events: none; }
#hud button, #hud canvas { pointer-events: auto; }
#hud-tl { position: absolute; top: calc(12px + var(--safe-t)); left: calc(14px + var(--safe-l)); display: flex; flex-direction: column; gap: 6px; }
#hud-logo { width: 170px; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.8)); }
#captain { display: flex; gap: 10px; align-items: center; background: var(--glass); border: 1px solid var(--line); border-radius: 14px; padding: 6px 12px 6px 6px; backdrop-filter: blur(6px); }
#captain-img { width: 58px; height: 58px; border-radius: 10px; border: 2px solid var(--gold); object-fit: cover; }
.cap-info { display: flex; flex-direction: column; gap: 3px; min-width: 130px; }
#captain-name { font-size: 22px; color: var(--gold); line-height: 1; }
#wallet-short { font-size: 16px; line-height: 1; }
.bar { height: 10px; width: 140px; background: rgba(255,255,255,0.12); border-radius: 6px; overflow: hidden; }
.fill { height: 100%; width: 100%; transition: width 0.2s; }
.fill.red { background: linear-gradient(90deg, #a00, var(--red)); }

#hud-top { position: absolute; top: calc(14px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; gap: 22px; font-size: 30px; background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 4px 26px; text-shadow: 0 2px 4px #000; white-space: nowrap; }

#hud-tr { position: absolute; top: calc(12px + var(--safe-t)); right: calc(14px + var(--safe-r)); display: grid; grid-template-columns: repeat(4, 44px); gap: 8px; justify-items: center; }
button.icon { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--glass); color: #fff; font-size: 19px; cursor: pointer; display: grid; place-items: center; backdrop-filter: blur(6px); font-family: system-ui, sans-serif; }
button.icon:hover { border-color: var(--gold); }
#radar { grid-column: 1 / span 4; width: 150px; height: 150px; border-radius: 50%; border: 1px solid var(--line); background: rgba(10, 20, 26, 0.6); margin-top: 4px; justify-self: end; pointer-events: none !important; }
#enemies-left { grid-column: 1 / span 4; justify-self: end; font-size: 20px; text-shadow: 0 2px 3px #000; }

#controls { position: absolute; bottom: calc(18px + var(--safe-b)); left: 50%; transform: translateX(-50%); display: flex; gap: 14px; align-items: center; }
#pill { display: flex; align-items: center; gap: 10px; background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; backdrop-filter: blur(8px); box-shadow: 0 6px 24px rgba(0,0,0,0.45); }
button.round { width: var(--btn); height: var(--btn); border-radius: 50%; border: 1px solid rgba(255,255,255,0.18); background: rgba(255,255,255,0.08); color: #fff; font-size: 26px; cursor: pointer; font-family: system-ui, sans-serif; touch-action: none; }
button.round:active, button.round.on { background: rgba(250,13,13,0.35); border-color: var(--red); }
#anchor.on { background: rgba(255,205,119,0.3); border-color: var(--gold); }
#sail-box { display: flex; align-items: center; gap: 6px; }
button.mini { width: 40px; height: 40px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.18); background: rgba(255,255,255,0.06); color: #fff; cursor: pointer; font-size: 16px; font-family: system-ui, sans-serif; touch-action: none; }
#sail-readout { text-align: center; min-width: 92px; line-height: 1; }
#sail-readout .label { font-size: 20px; margin: 0; }
#knots { font-size: 34px; }
button.fire { position: relative; isolation: isolate; overflow: hidden; height: 64px; min-width: 110px; padding: 0 16px; border-radius: 999px; border: 2px solid var(--red); background: rgba(22,22,22,0.78); color: #fff; font-size: 30px; cursor: pointer; text-shadow: 0 2px 3px #000; touch-action: none; }
button.fire .cd { position: absolute; left: 0; bottom: 0; height: 100%; width: 0; background: rgba(250,13,13,0.35); z-index: -1; transition: none; }
button.fire.ready { box-shadow: 0 0 16px rgba(250,13,13,0.6); }
button.fire:active { transform: scale(0.97); }

#banner { position: absolute; top: 26%; left: 50%; transform: translate(-50%, -50%); font-size: 84px; color: var(--gold); text-shadow: 0 4px 0 #000, 0 0 30px rgba(250,13,13,0.6); white-space: nowrap; animation: pop 0.5s ease-out; }
@keyframes pop { from { transform: translate(-50%, -50%) scale(0.6); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
#hint { position: absolute; bottom: calc(96px + var(--safe-b)); left: 50%; transform: translateX(-50%); font-size: 20px; color: rgba(255,255,255,0.65); text-shadow: 0 2px 3px #000; white-space: nowrap; transition: opacity 1s; }

#bars, #popups { pointer-events: none; overflow: hidden; }
.ehp { position: absolute; transform: translate(-50%, -100%); text-align: center; font-size: 18px; color: #fff; text-shadow: 0 2px 3px #000; white-space: nowrap; }
.ehp .bar { width: 70px; height: 7px; margin: 2px auto 0; border: 1px solid rgba(0,0,0,0.6); }
.ehp .fill { background: linear-gradient(90deg, #2f9e44, #8ce99a); }
.ehp.flee .name::after { content: ' (fleeing)'; color: var(--gold); }
.ehp .name { display: none; } /* health bars only over enemies (names hidden) */
.popup { position: absolute; transform: translate(-50%, -50%); font-size: 34px; color: var(--gold); -webkit-text-stroke: 1.5px #161616; paint-order: stroke fill; text-shadow: 0 3px 0 #161616, 0 0 14px rgba(255,205,119,0.45); animation: rise 1.4s ease-out forwards; white-space: nowrap; }
.popup.dmg { color: var(--red); font-size: 30px; text-shadow: 0 3px 0 #161616, 0 0 14px rgba(250,13,13,0.5); }
.popup.hit { color: #fff; font-size: 26px; text-shadow: 0 3px 0 #161616, 0 0 10px rgba(255,205,119,0.5); }
@keyframes rise { 0% { opacity: 0; margin-top: 0; scale: 0.4; } 12% { opacity: 1; scale: 1.35; } 25% { scale: 1; } 100% { opacity: 0; margin-top: -64px; scale: 1; } }

/* ---------- overlays ---------- */
.overlay { display: flex; align-items: flex-start; justify-content: center; -webkit-overflow-scrolling: touch; background: radial-gradient(ellipse at center, rgba(22,22,22,0.35), rgba(22,22,22,0.85)); overflow-y: auto; overflow-x: hidden; padding: calc(12px + var(--safe-t)) calc(12px + var(--safe-r)) calc(16px + var(--safe-b)) calc(12px + var(--safe-l)); touch-action: pan-y; }
#title { background: radial-gradient(ellipse at center, rgba(22,22,22,0.15), rgba(22,22,22,0.75)); }
.panel { width: min(560px, 96vw); background: rgba(22,22,22,0.82); border: 1px solid var(--line); border-radius: 22px; padding: 18px 26px 16px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.6); backdrop-filter: blur(8px); margin: auto; }
.panel.small { width: min(420px, 94vw); }
.panel h1 { font-weight: normal; font-size: 58px; margin: 4px 0 8px; color: var(--gold); }
.title-panel .skull { width: 70px; margin-top: -4px; filter: drop-shadow(0 0 18px rgba(250,13,13,0.45)); }
.title-panel .wordmark { width: 220px; display: block; margin: -6px auto 0; }
.subtitle { font-size: 24px; color: var(--gold); margin: 2px 0 10px; }
.field { display: flex; flex-direction: column; gap: 3px; text-align: left; margin: 8px 0; font-size: 21px; }
.field em { font-style: normal; color: rgba(255,255,255,0.5); font-size: 0.85em; }
.field small { font-size: 16px; }
.field input { font-size: 22px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0,0,0,0.45); color: #fff; outline: none; user-select: text; -webkit-user-select: text; }
.field input:focus { border-color: var(--gold); }
.field input.bad { border-color: var(--red); }
.field input.good { border-color: #2f9e44; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; justify-content: center; }
.field.inline input { width: 200px; }
button { cursor: pointer; }
button.big { font-size: 40px; padding: 6px 40px; margin: 8px 6px 4px; border-radius: 999px; border: none; background: var(--red); color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,0.4); box-shadow: 0 6px 0 #8f0000, 0 10px 24px rgba(250,13,13,0.35); }
button.big:active { transform: translateY(3px); box-shadow: 0 3px 0 #8f0000; }
button.big:disabled { background: #444; box-shadow: 0 6px 0 #222; color: #999; cursor: not-allowed; }
button.ghost, #btn-save { font-size: 22px; padding: 6px 16px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255,255,255,0.05); color: #fff; margin: 4px; }
button.ghost:disabled { color: rgba(255,255,255,0.45); cursor: not-allowed; border-style: dashed; }
#btn-save { border-color: var(--gold); color: var(--gold); }
.row { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; }
/* [daily] DAILY challenge button: gold ghost pill next to the wallet-connect pill */
button.daily-btn { border-color: var(--gold); color: var(--gold); }
button.daily-btn:disabled { color: rgba(255,205,119,0.6); border-color: rgba(255,205,119,0.45); }
.board-wrap { margin: 10px 0 6px; text-align: left; background: rgba(0,0,0,0.3); border: 1px solid var(--line); border-radius: 14px; padding: 8px 14px; }
.board-title { font-size: 26px; color: var(--gold); text-align: center; }
.board-title .muted { font-size: 16px; }
.lb-tabs { display: flex; gap: 3px; width: max-content; max-width: 100%; margin: 4px auto 2px; padding: 3px; background: rgba(0,0,0,0.4); border: 1px solid var(--line); border-radius: 999px; overflow-x: auto; scrollbar-width: none; touch-action: pan-x; -webkit-overflow-scrolling: touch; }
.lb-tabs::-webkit-scrollbar { display: none; }
.lb-tabs button { flex: 0 0 auto; font-size: 18px; line-height: 1; padding: 4px 11px 3px; border-radius: 999px; border: none; background: transparent; color: rgba(255,255,255,0.7); }
.lb-tabs button:hover { color: var(--gold); }
.lb-tabs button.on { background: var(--red); color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,0.4); box-shadow: 0 2px 0 #8f0000; }
.board { margin: 4px 0 0; padding-left: 30px; font-size: 21px; columns: 2; column-gap: 26px; }
.board li { break-inside: avoid; line-height: 1.25; }
.board li b { color: var(--gold); font-weight: normal; float: right; }
.board li.me { color: var(--gold); }
.board .empty { list-style: none; margin-left: -30px; text-align: center; color: rgba(255,255,255,0.5); columns: 1; }
.controls-help { font-size: 18px; color: rgba(255,255,255,0.7); margin: 8px 0 4px; }
.disclaimer { font-size: 15px; color: rgba(255,255,255,0.45); margin-top: 6px; line-height: 1.15; }
.stats { display: flex; justify-content: center; gap: 22px; font-size: 38px; margin: 4px 0; }
.stats > div { display: flex; flex-direction: column; line-height: 1; }
.stats .label { font-size: 20px; margin: 0; }
.stats b { font-weight: normal; }
#go-wallet, #save-msg { font-size: 18px; min-height: 20px; }

/* ---------- touch / small screens ---------- */
@media (pointer: coarse) {
  :root { --btn: 64px; }
  button.fire { height: 76px; min-width: 120px; font-size: 32px; }
  button.mini { width: 48px; height: 48px; }
  #hint { display: none; }
}
@media (max-height: 820px) {
  .title-panel .wordmark { width: 190px; }
  .title-panel .skull { width: 56px; }
  .field { margin: 4px 0; }
  .board-wrap { margin: 6px 0 4px; }
}
@media (orientation: landscape) and (max-height: 520px), (orientation: landscape) and (max-width: 760px) {
  #hud-logo { width: 110px; }
  #captain-img { width: 42px; height: 42px; }
  #captain { padding: 4px 8px 4px 4px; }
  .cap-info { min-width: 96px; }
  .bar { width: 96px; }
  #captain-name { font-size: 18px; }
  #wallet-short { font-size: 14px; }
  #hud-top { font-size: 22px; gap: 12px; padding: 2px 14px; top: calc(8px + var(--safe-t)); }
  #hud-tr { grid-template-columns: repeat(4, 38px); gap: 5px; top: calc(8px + var(--safe-t)); }
  button.icon { width: 38px; height: 38px; font-size: 16px; }
  #radar { width: 96px; height: 96px; }
  #enemies-left { font-size: 16px; }
  /* split the controls: steering pill centered, fire buttons in the thumb corners */
  #controls { left: 0; right: 0; transform: none; justify-content: center; bottom: calc(10px + var(--safe-b)); }
  #fire-port { position: absolute; left: calc(14px + var(--safe-l)); bottom: 0; }
  #fire-star { position: absolute; right: calc(14px + var(--safe-r)); bottom: 0; }
  #pill { gap: 6px; padding: 6px 8px; }
  #sail-readout { min-width: 64px; }
  #knots { font-size: 26px; }
  #sail-readout .label { font-size: 16px; }
  #banner { font-size: 56px; }
  .panel { padding: 10px 16px; }
  .panel h1 { font-size: 40px; }
  .title-panel .skull { width: 56px; }
  .title-panel .wordmark { width: 190px; }
  .subtitle { font-size: 19px; margin-bottom: 4px; }
  .field { margin: 4px 0; font-size: 18px; }
  .field input { font-size: 19px; padding: 5px 10px; }
  button.big { font-size: 32px; padding: 3px 30px; }
  .board { font-size: 18px; }
  .stats { font-size: 30px; }
}
/* ---------- PORTRAIT (phones held upright): fully playable ---------- */
@media (orientation: portrait) {
  #hud-tl { top: calc(8px + var(--safe-t)); left: calc(8px + var(--safe-l)); flex-direction: row; align-items: center; gap: 6px; max-width: calc(var(--app-w) - 190px - var(--safe-r)); }
  #hud-logo { width: 78px; }
  #captain { padding: 3px 8px 3px 3px; gap: 6px; border-radius: 12px; min-width: 0; }
  #captain-img { width: 38px; height: 38px; border-radius: 8px; }
  .cap-info { min-width: 0; gap: 2px; }
  #captain-name { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 108px; }
  #wallet-short { font-size: 13px; }
  .bar { width: 84px; height: 8px; }
  #hud-tr { top: calc(8px + var(--safe-t)); right: calc(8px + var(--safe-r)); grid-template-columns: repeat(4, 36px); gap: 5px; }
  button.icon { width: 36px; height: 36px; font-size: 15px; }
  #radar { width: 84px; height: 84px; }
  #enemies-left { font-size: 15px; }
  /* stats: one compact row under the top bar, left side (radar sits on the right) */
  #hud-top { top: calc(66px + var(--safe-t)); left: calc(8px + var(--safe-l)); transform: none; font-size: 19px; gap: 10px; padding: 2px 12px; }
  #hud-top .label { font-size: 15px; margin-right: 2px; }
  /* bottom: fire buttons in a row ABOVE a full-width steering pill */
  #controls { left: calc(8px + var(--safe-l)); right: calc(8px + var(--safe-r)); transform: none; bottom: calc(8px + var(--safe-b)); display: grid; grid-template-columns: 1fr 1fr; grid-template-areas: "port star" "pill pill"; gap: 8px; }
  #fire-port { grid-area: port; position: relative; height: 60px; min-width: 0; width: 100%; font-size: 28px; }
  #fire-star { grid-area: star; position: relative; height: 60px; min-width: 0; width: 100%; font-size: 28px; }
  #pill { grid-area: pill; justify-content: space-between; gap: 4px; padding: 6px 8px; width: 100%; }
  button.round { width: 56px; height: 56px; font-size: 24px; }
  button.mini { width: 40px; height: 40px; }
  #sail-readout { min-width: 62px; }
  #knots { font-size: 26px; }
  #sail-readout .label { font-size: 16px; }
  #banner { font-size: 50px; top: 30%; }
  #hint { display: none; }
  .ehp { font-size: 15px; }
  .ehp .bar { width: 54px; }
  .panel { width: min(560px, 100%); padding: 12px 14px; border-radius: 18px; }
  .panel h1 { font-size: 40px; }
  .title-panel .skull { width: 54px; }
  .title-panel .wordmark { width: 180px; }
  .subtitle { font-size: 19px; }
  .field { font-size: 18px; }
  .field input { font-size: 19px; }
  .field.inline { flex-wrap: wrap; }
  .field.inline input { width: 100%; }
  button.big { font-size: 34px; padding: 4px 32px; }
  button.ghost { font-size: 18px; }
  .board { columns: 1; font-size: 19px; }
  .stats { font-size: 30px; gap: 14px; }
}
@media (orientation: portrait) and (max-height: 820px) {
  #hud-logo { display: none; }
  #hud-tl { max-width: calc(var(--app-w) - 180px); }
}
/* dismissible rotate hint (portrait stays fully playable) */
#rotate { display: none; }
#rotate.show { display: flex; align-items: center; gap: 8px; position: fixed; top: calc(104px + var(--safe-t)); left: 50%; transform: translateX(-50%); background: var(--glass); border: 1px solid var(--line); padding: 4px 6px 4px 14px; border-radius: 999px; font-size: 18px; color: var(--gold); white-space: nowrap; pointer-events: auto; z-index: 5; }
#rotate button { background: none; border: none; color: #fff; font-size: 20px; padding: 2px 8px; font-family: system-ui, sans-serif; }
.txt { font-family: system-ui, -apple-system, sans-serif; font-variant-emoji: text; }

/* short landscape screens (phones): title in two columns so SET SAIL is always visible */
@media (max-height: 520px) and (orientation: landscape) {
  .title-panel { width: min(900px, 96vw); display: grid; grid-template-columns: 1.05fr 1fr; gap: 16px; align-items: start; text-align: center; }
  .title-panel .board { columns: 1; font-size: 17px; }
  .title-panel .board-wrap { margin-top: 0; }
  .title-panel .skull { width: 44px; }
  .title-panel .wordmark { width: 150px; margin-top: -4px; }
  .title-panel .field small { font-size: 14px; }
  .title-panel button.ghost { font-size: 17px; padding: 4px 12px; }
  #gameover .panel { width: min(760px, 96vw); }
  #gameover .board { columns: 2; }
}

/* ---------- leaderboard: holds the top 100, shows exactly 5 rows, the rest scroll inside the list ---------- */
.board, .title-panel .board, #gameover .board {
  --lb-row: 1.3em; position: relative; columns: auto; list-style: none; padding: 0 4px 0 0; margin: 4px 0 0;
  height: calc(var(--lb-row) * 5); overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain; touch-action: pan-y; scrollbar-width: thin; scrollbar-color: rgba(255,205,119,0.45) transparent;
}
.board::-webkit-scrollbar { width: 4px; }
.board::-webkit-scrollbar-thumb { background: rgba(255,205,119,0.45); border-radius: 4px; }
.board li { display: flex; align-items: baseline; gap: 6px; height: var(--lb-row); line-height: var(--lb-row); white-space: nowrap; }
.board li i { font-style: normal; flex: 0 0 2.1em; text-align: right; color: rgba(255,255,255,0.55); }
.board li span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.board li b { float: none; flex: 0 0 auto; }
.board li.me { color: var(--gold); background: rgba(250,13,13,0.18); border-radius: 8px; box-shadow: inset 3px 0 0 var(--red); }
.board li.me i { color: var(--gold); }
.board .empty { display: block; height: auto; white-space: normal; line-height: 1.25; margin: 0; padding-top: 0.6em; }
.board.more { -webkit-mask-image: linear-gradient(to bottom, #000 72%, rgba(0,0,0,0.25)); mask-image: linear-gradient(to bottom, #000 72%, rgba(0,0,0,0.25)); }
.lb-more { height: 18px; line-height: 18px; font-size: 16px; text-align: center; color: var(--gold); opacity: 0; transition: opacity 0.2s; pointer-events: none; }
.lb-more.on { opacity: 0.8; }
/* wide-but-short desktop/laptop windows: title in two columns so the 5-row board + SET SAIL fit without scrolling */
@media (orientation: landscape) and (min-width: 900px) and (max-height: 960px) and (min-height: 521px) {
  .title-panel { width: min(940px, 94vw); display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: center; text-align: center; }
  .title-panel .board-wrap { margin-top: 0; }
}

/* iOS 27 installed web apps: the OS blurs whatever the page draws near the top (status bar and well below it).
   A solid position:fixed bar at top:0 (>=6px tall, >=80% wide) makes iOS paint a solid status bar instead of the blur.
   Covers only the status-bar strip, then fades softly into the scene. */
#status-plate { display: none; }
html.ios-pwa #status-plate {
  display: block; position: fixed; top: 0; left: 0; width: 100%; height: max(6px, var(--safe-t));
  background-color: #0d1118; z-index: 1000; pointer-events: none;
}
html.ios-pwa #status-plate::after {
  content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 14px;
  background: linear-gradient(#0d1118, rgba(13,17,24,0)); pointer-events: none;
}

/* ---------- title: $AHOY CA chip + socials ---------- */
.token-row { display: flex; justify-content: center; align-items: center; gap: 6px; margin: 0 0 6px; flex-wrap: nowrap; }
.ca-chip { display: inline-flex; align-items: center; gap: 7px; min-width: 0; height: 36px; padding: 0 5px 0 12px; border-radius: 999px; border: 1px solid var(--gold); background: rgba(0,0,0,0.5); color: #fff; font-size: 20px; line-height: 1; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.ca-chip:hover { box-shadow: 0 0 0 2px rgba(255,205,119,0.25); }
.ca-chip:active { transform: translateY(1px); }
.ca-chip .tk { color: var(--gold); font-size: 22px; }
.ca-chip .ca { color: rgba(255,255,255,0.85); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; letter-spacing: 0.02em; }
.ca-chip .ca-full { display: none; }
.ca-chip .cp { flex: 0 0 auto; font-size: 17px; padding: 4px 9px 3px; border-radius: 999px; background: var(--red); color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,0.4); box-shadow: 0 2px 0 #8f0000; min-width: 52px; }
.ca-chip.copied { border-color: #2f9e44; }
.ca-chip.copied .cp { background: #2f9e44; box-shadow: 0 2px 0 #1b5e28; }
.ca-chip.failed .cp { background: #555; box-shadow: none; }
.soc { flex: 0 0 auto; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.18); background: rgba(255,255,255,0.08); color: var(--gold); touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.soc:hover { border-color: var(--gold); }
.soc svg { width: 17px; height: 17px; display: block; }
.title-panel .col-a { min-width: 0; }
.ca-chip.full .ca-full { display: inline; } .ca-chip.full .ca-short { display: none; } /* tokenChip.js shows the full CA only when it fits */
@media (max-width: 380px) { .token-row { gap: 4px; } .ca-chip { gap: 5px; padding-left: 9px; font-size: 18px; } .soc { width: 32px; height: 32px; } .soc svg { width: 15px; height: 15px; } }
/* small portrait phones (iPhone SE / 8, 375x667): compact title so the whole screen fits without scrolling */
@media (orientation: portrait) and (max-height: 700px) {
  #title { padding-top: calc(8px + var(--safe-t)); padding-bottom: calc(8px + var(--safe-b)); }
  .title-panel { padding: 8px 12px 10px; }
  .title-panel .skull { display: none; }
  .title-panel .wordmark { width: 132px; margin-top: 0; }
  .title-panel .subtitle { font-size: 17px; margin: 0 0 5px; }
  .title-panel .token-row { margin-bottom: 2px; }
  .title-panel .field { margin: 2px 0; font-size: 17px; gap: 2px; }
  .title-panel .field input { padding: 5px 10px; font-size: 18px; }
  .title-panel .field small { font-size: 14px; }
  .title-panel button.big { font-size: 30px; padding: 2px 30px; margin: 5px 6px 4px; }
  .title-panel button.ghost { font-size: 16px; padding: 3px 12px; margin: 2px; }
  .title-panel .board-wrap { margin: 4px 0 2px; padding: 4px 12px; }
  .title-panel .board-title { font-size: 22px; }
  .title-panel .board { font-size: 17px; }
  .title-panel .controls-help { display: none; } /* keyboard/mouse tips; phones use the on-screen buttons */
  .title-panel .disclaimer { font-size: 13px; margin-top: 3px; }
}
.share-btn { border-color: var(--gold) !important; color: var(--gold) !important; touch-action: manipulation; }
/* [enemy variety] telegraphs on the health bar: wind-up flash before a ram / boss barrage, solid red while charging */
.ehp.windup .bar { animation: ev-warn 0.18s steps(2) infinite; }
.ehp.charging .bar { box-shadow: 0 0 0 2px var(--red), 0 0 12px rgba(250,13,13,0.8); }
.ehp.repairing .bar { animation: ev-repair 1.2s ease-in-out infinite; } /* [repair] fleeing ship patching its hull */
.bar.repairing { animation: ev-repair 1.2s ease-in-out infinite; } /* [repair] captain-card hull bar while self-repairing */
.ehp.repair-tick .bar { box-shadow: 0 0 0 2px #4ee37a, 0 0 14px rgba(78,227,122,0.9); }
.ehp.repairing .fill { background: linear-gradient(90deg, #4ee37a, #c9ffd6); }
@keyframes ev-repair { 0%, 100% { box-shadow: 0 0 0 1px rgba(78,227,122,0.4); } 50% { box-shadow: 0 0 0 2px #4ee37a, 0 0 10px rgba(78,227,122,0.8); } }
.ehp.charging .fill, .ehp.windup .fill { background: linear-gradient(90deg, #a00, var(--red)); }
@keyframes ev-warn { 0% { box-shadow: 0 0 0 2px var(--red), 0 0 14px rgba(250,13,13,0.9); } 100% { box-shadow: none; } }

/* [qa2] title fit: nothing overlaps or clips at 568x320 .. desktop */
.start-row { align-items: center; flex-wrap: nowrap; gap: 4px; }
.start-row button.big { flex: 0 1 auto; min-width: 0; }
.start-row .daily-btn { flex: 0 0 auto; white-space: nowrap; }
.token-row { flex-wrap: wrap; row-gap: 5px; }
.ca-chip { min-width: auto; flex: 0 1 auto; max-width: 100%; } /* never narrower than $AHOY + COPY; only the address part shrinks (ellipsis) */
.ca-chip .tk, .ca-chip .cp { flex: 0 0 auto; white-space: nowrap; }
.ca-chip .ca { flex: 0 1 auto; }
.lb-tabs button { padding: 4px 8px 3px; }
@media (max-width: 420px), (max-height: 520px) and (orientation: landscape) { .lb-tabs { gap: 1px; } .lb-tabs button { font-size: 16px; padding: 4px 6px 3px; } }
@media (max-height: 520px) and (orientation: landscape) {
  .title-panel { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
  .title-panel > .col-a, .title-panel > .col-b { min-width: 0; }
}
@media (max-width: 380px) { .start-row button.big { padding-left: 22px; padding-right: 22px; } }
.token-row .socs { display: inline-flex; gap: 6px; flex: 0 0 auto; } /* the three links wrap together, never 1 + 2 */
@media (max-width: 380px) { .token-row .socs { gap: 4px; } }
@media (max-height: 520px) and (orientation: landscape) { .lb-tabs { flex-wrap: wrap; justify-content: center; width: auto; border-radius: 14px; overflow: visible; } } /* narrow board column: tabs wrap instead of scrolling out of view */
@media (pointer: coarse) and (orientation: portrait), (pointer: coarse) and (max-height: 520px) { .title-panel .controls-help { display: none; } } /* keyboard/mouse tips: phones use the on-screen buttons */
/* [qa2] very short landscape phones (SE 667x375, 568x320): compact left column so SET SAIL stays on screen */
@media (max-height: 400px) and (orientation: landscape) {
  #title { padding-top: calc(6px + var(--safe-t)); padding-bottom: calc(6px + var(--safe-b)); }
  .title-panel { padding: 6px 12px 8px; gap: 12px; }
  .title-panel .skull { display: none; }
  .title-panel .wordmark { width: 118px; margin-top: 0; }
  .title-panel .subtitle { font-size: 15px; margin: 0 0 3px; }
  .title-panel .token-row { margin-bottom: 2px; row-gap: 3px; }
  .title-panel .ca-chip { height: 30px; font-size: 17px; } .title-panel .ca-chip .tk { font-size: 18px; } .title-panel .ca-chip .cp { font-size: 15px; padding: 3px 8px 2px; }
  .title-panel .soc { width: 30px; height: 30px; } .title-panel .soc svg { width: 14px; height: 14px; }
  .title-panel .field { margin: 2px 0; font-size: 15px; gap: 1px; }
  .title-panel .field em { display: none; }
  .title-panel .field input { padding: 3px 9px; font-size: 16px; }
  .title-panel .field small { font-size: 12px; }
  .title-panel button.big { font-size: 26px; padding: 1px 24px; margin: 4px 4px 3px; }
  .title-panel button.ghost { font-size: 15px; padding: 2px 10px; margin: 2px; }
  .title-panel .board-title { font-size: 20px; }
  .title-panel .disclaimer { font-size: 12px; }
}
@media (max-height: 340px) and (orientation: landscape) {
  .title-panel .subtitle, .title-panel .field small { display: none; }
  .title-panel .wordmark { width: 100px; }
}
@media (max-height: 400px) and (orientation: landscape) { .lb-tabs button { font-size: 15px; padding: 3px 5px 2px; } }
/* [qa2] game over on short landscape phones: two columns (stats + name | board), buttons along the bottom, no scrolling */
@media (max-height: 520px) and (orientation: landscape) {
  #gameover .panel { width: min(900px, 96vw); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); column-gap: 14px; align-items: start;
    grid-template-areas: "h1 board" "stats board" "wallet board" "field board" "msg board" "row row"; padding: 8px 14px; }
  #gameover .panel > h1 { grid-area: h1; font-size: 34px; margin: 0; }
  #gameover .stats { grid-area: stats; font-size: 26px; gap: 10px; margin: 2px 0; }
  #gameover #go-wallet { grid-area: wallet; font-size: 15px; }
  #gameover .field { grid-area: field; margin: 3px 0; }
  #gameover #save-msg { grid-area: msg; font-size: 14px; }
  #gameover .board-wrap { grid-area: board; margin: 0; padding: 4px 10px; min-width: 0; }
  #gameover .board-title { font-size: 21px; }
  #gameover .board { columns: auto; font-size: 17px; }
  #gameover .row { grid-area: row; margin-top: 4px; }
  #gameover button.big { font-size: 28px; padding: 2px 26px; margin: 3px 4px; }
  #gameover button.ghost { font-size: 17px; padding: 3px 12px; margin: 3px; }
}
@media (max-height: 360px) and (orientation: landscape) {
  #gameover .panel > h1 { font-size: 28px; } #gameover .stats { font-size: 22px; } #gameover #save-msg { display: none; }
  #gameover .board { font-size: 15px; } #gameover .lb-more { height: 14px; line-height: 14px; }
}
@media (max-height: 520px) and (orientation: landscape) { #gameover .field > span { white-space: nowrap; font-size: 16px; } #gameover #btn-save { white-space: nowrap; font-size: 17px; padding: 4px 12px; } #gameover .field input { min-width: 0; } }

/* [wave break] NEXT WAVE IN countdown */
#next-wave { position: absolute; top: 40%; left: 50%; transform: translateX(-50%); z-index: 5; pointer-events: none; font-size: 34px; color: #fff; text-shadow: 0 3px 0 #000, 0 0 14px rgba(0,0,0,0.6); white-space: nowrap; }
@media (max-height: 520px) and (orientation: landscape) { #next-wave { top: 44%; font-size: 26px; } }
