/* ================================================================
   Taipan Redux — Mobile Stylesheet
   Maritime Ledger theme, touch-first layout
   ================================================================ */

/* ── CSS Variables (Maritime Ledger — same as desktop) ── */
:root {
  --fg: #d4c5a9;
  --fg-dim: #8a7e6b;
  --bg: #0c1a2e;
  --bg-surface: #122240;
  --border: #2a4a6b;
  --border-accent: #c8a45c;
  --accent: #c8a45c;
  --accent-bright: #e8c86c;
  --inverse-bg: #c8a45c;
  --inverse-fg: #0c1a2e;
  --highlight: #e8c86c;
  --danger: #c75050;
  --link: #7aadcf;
  --safe-top: env(safe-area-inset-top, 0px);
}

/* ── Reset & Base ── */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-user-select: none; user-select: none; }
*:focus { outline: none; }
div:focus, span:focus { outline: none; }

html {
  background: var(--bg-surface);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  position: fixed;
  width: 100%;
  height: 100%;
}
body {
  background: var(--bg-surface);
  color: var(--fg);
  font-family: "DM Mono", monospace;
  font-size: 16px;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  overflow: hidden;
  overscroll-behavior: none;
  position: fixed;
  width: 100%;
  padding: 0;
  -webkit-text-size-adjust: 100%;
}

/* ── App container ── */
.m-app {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  background: var(--bg-surface);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

/* ── Screen sections — shown/hidden by JS ── */
.m-screen {
  display: none;
}
.m-screen.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  z-index: 1;
  background: var(--bg-surface);
}

/* ── Shared button ── */
.m-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg);
  padding: 14px 10px;
  text-align: center;
  font-family: "DM Mono", monospace;
  font-size: 14px;
  cursor: pointer;
  min-height: 44px;
  -webkit-tap-highlight-color: rgba(200, 164, 92, 0.2);
}
.m-btn:active { border-color: var(--accent); background: rgba(200, 164, 92, 0.1); }
.m-btn.accent {
  border-color: var(--border-accent);
  color: var(--accent);
}
.m-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--inverse-fg);
  font-weight: 500;
}
.m-btn.primary:active { background: var(--accent-bright); }


/* ================================================================
   1. Title Screen
   ================================================================ */
.m-title-scene {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  background: #1e5888;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
}
/* Sky gradient — matches desktop .title-sky */
.m-title-sky {
  position: absolute;
  top: 0; left: 0; right: 0; height: 38%;
  background: linear-gradient(180deg, #c8a050 0%, #e8c870 30%, #c8c8a0 50%, #8ab4c8 72%, #6a9cb8 100%);
  pointer-events: none;
  z-index: 0;
}
/* Horizon haze — matches desktop .title-horizon */
.m-title-horizon {
  position: absolute;
  top: calc(38% - 7px); left: 0; right: 0; height: 14px;
  background: linear-gradient(180deg, transparent 0%, rgba(255,245,220,0.25) 30%, rgba(255,250,230,0.45) 50%, rgba(200,220,235,0.20) 75%, transparent 100%);
  pointer-events: none;
  z-index: 3;
}
/* Ocean SVG layers — matches desktop .title-ocean */
.m-title-ocean {
  position: absolute;
  top: 38%; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 2;
}
.m-title-ocean svg {
  position: absolute;
  width: 200%; height: 530px;
  left: 0; top: 0;
  will-change: transform;
  opacity: 0.75;
}
.m-title-ocean.ol-a svg { animation: m-ocean-drift 18s linear infinite; }
.m-title-ocean.ol-b svg { animation: m-ocean-drift 25s linear infinite; animation-delay: -10s; }
.m-title-ocean.ol-a { animation: m-wave-bob-a 5s ease-in-out infinite; transform-origin: top; }
.m-title-ocean.ol-b { animation: m-wave-bob-b 6.5s ease-in-out infinite; animation-delay: -3s; transform-origin: top; }
@keyframes m-ocean-drift {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
@keyframes m-wave-bob-a {
  0%, 100% { transform: translateY(0) scaleY(1); }
  50% { transform: translateY(2.5px) scaleY(1.015); }
}
@keyframes m-wave-bob-b {
  0%, 100% { transform: translateY(0) scaleY(1.01); }
  50% { transform: translateY(-2px) scaleY(0.985); }
}
/* Ship — positioned at the horizon, matching desktop approach */
.m-title-ship {
  position: absolute;
  width: 200px; height: 171px;
  right: 2px; top: 17%;
  background-image: url('assets/ship1-spritesheet.png');
  background-repeat: no-repeat;
  background-position: 0 0;
  background-size: 1400px auto; /* 7 frames × 200px */
  image-rendering: pixelated;
  z-index: 5;
  animation: m-title-ship-bob 3s ease-in-out infinite;
}
.m-title-heading {
  position: absolute;
  top: 15%;
  left: 16px;
  z-index: 6;
  transform: scale(1.02);
  transform-origin: top left;
}
.m-title-name-block {
  display: inline-flex;
  align-items: flex-end;
}
.m-title-words {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.m-title-taipan {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 700;
  font-size: 34px;
  letter-spacing: 4px;
  color: #F8ECCE;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5), 0 0 20px rgba(248,236,206,0.18);
  line-height: 1;
}
.m-title-redux {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 400;
  font-size: 34px;
  letter-spacing: 6px;
  color: #7A5030;
  text-shadow: 0 1px 5px rgba(0,0,0,0.55);
  line-height: 1.1;
  margin-top: 3px;
}
.m-title-bang {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 700;
  font-size: 105px;
  line-height: 1;
  color: #F8ECCE;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5), 0 0 20px rgba(248,236,206,0.18);
  margin-left: 0;
  margin-bottom: -10px;
  align-self: flex-end;
  margin-top: -35px;
}
/* .m-title-ship-area replaced by absolutely-positioned .m-title-ship above */
@keyframes m-title-ship-bob {
  0%   { transform: translateY(0) rotate(0deg); }
  50%  { transform: translateY(4px) rotate(1.5deg); }
  100% { transform: translateY(0); }
}
.m-title-bottom {
  position: absolute;
  top: 48%;
  left: 0; right: 0;
  text-align: center;
  padding: 0 24px;
  z-index: 6;
}
.m-title-subtitle {
  color: rgba(248,236,206,0.95);
  font-style: italic;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 18px;
  margin-bottom: 10px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.m-title-credits {
  line-height: 1.4;
  color: rgba(255,255,255,0.7);
  font-size: 11px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
}
.m-title-credits a { color: rgba(255,255,255,0.8); }
.m-title-actions {
  margin-top: auto;
  padding: 16px 36px max(36px, env(safe-area-inset-bottom, 0px));
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 2;
}
.m-title-actions .m-btn.resume {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--inverse-fg);
  font-weight: 500;
  font-size: 15px;
}
.m-title-secondary {
  display: flex;
  gap: 12px;
}
.m-title-secondary .m-btn { flex: 1; font-size: 13px; }
.m-title-desktop-link {
  text-align: center;
  margin-top: 4px;
}
.m-title-desktop-link a {
  color: rgba(210,235,255,0.7);
  font-size: 13px;
  text-decoration: none;
}


/* ================================================================
   2. New Game Confirm
   ================================================================ */
.m-confirm-screen {
  padding: max(40px, var(--safe-top)) 28px 40px;
  background-color: var(--bg-surface);
  min-height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.m-confirm-screen .m-confirm-msg {
  font-size: 15px;
  color: var(--fg);
  margin-bottom: 32px;
  line-height: 1.6;
}
.m-confirm-buttons {
  display: flex;
  gap: 12px;
  width: 100%;
}
.m-confirm-buttons .m-btn { flex: 1; }


/* ================================================================
   3. Firm Name Screen
   ================================================================ */
.m-firm-screen {
  padding: max(40px, var(--safe-top)) 28px 40px;
  background-color: var(--bg-surface);
  background-image:
    radial-gradient(ellipse at 20% 80%, rgba(200, 164, 92, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(122, 173, 207, 0.03) 0%, transparent 50%);
  min-height: 400px;
  display: flex;
  flex-direction: column;
}
.m-firm-screen .m-firm-prompt {
  font-size: 14px;
  color: var(--fg);
  text-align: center;
  margin-bottom: 24px;
  line-height: 1.6;
}
.m-firm-input-area {
  border: 1px solid var(--border-accent);
  background: rgba(200, 164, 92, 0.04);
  border-radius: 6px;
  padding: 16px;
  text-align: center;
  margin-bottom: 24px;
}
.m-firm-input-display {
  font-size: 20px;
  color: var(--accent-bright);
  letter-spacing: 3px;
  min-height: 28px;
}
.m-firm-presets-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--fg-dim);
  text-align: center;
  margin-bottom: 10px;
}
.m-firm-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.m-firm-presets .m-btn { font-size: 12px; padding: 12px 8px; }
.m-firm-custom {
  margin-top: auto;
}
.m-firm-custom .m-btn {
  width: 100%;
  font-size: 13px;
}
.m-firm-custom-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
  z-index: 10;
}
.m-firm-custom-title {
  font-size: 15px;
  color: var(--fg);
  margin-bottom: 24px;
}
.m-firm-custom-field {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border-accent);
  border-radius: 6px;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 18px;
  color: var(--accent-bright);
  letter-spacing: 2px;
  text-align: center;
  outline: none;
  margin-bottom: 24px;
}
.m-firm-custom-field:focus {
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 1px var(--accent);
}
.m-firm-custom-buttons {
  display: flex;
  gap: 12px;
  width: 100%;
}
.m-firm-custom-buttons .m-btn { flex: 1; }


/* ================================================================
   4. Start Choice Screen
   ================================================================ */
.m-choice-screen {
  padding: max(40px, var(--safe-top)) 28px 40px;
  background-color: var(--bg-surface);
  background-image:
    radial-gradient(ellipse at 20% 80%, rgba(200, 164, 92, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(122, 173, 207, 0.03) 0%, transparent 50%);
  min-height: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.m-choice-prompt {
  font-size: 14px;
  color: var(--fg);
  text-align: center;
  margin-bottom: 32px;
}
.m-choice-options {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.m-choice-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(200, 164, 92, 0.2);
}
.m-choice-btn:active { border-color: var(--accent); background: rgba(200, 164, 92, 0.1); }
.m-choice-btn .m-choice-title {
  font-size: 15px;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 6px;
}
.m-choice-btn .m-choice-detail {
  font-size: 12px;
  color: var(--fg-dim);
  line-height: 1.4;
}
.m-choice-divider {
  text-align: center;
  color: var(--fg-dim);
  font-size: 12px;
  padding: 4px 0;
}


/* ================================================================
   5. Port Screen
   ================================================================ */

/* Port layout: top (data) is fixed size, bottom (message+actions) fills remainder */
.m-port-top {
  flex: 0 0 auto;
  background: var(--bg-surface);
  position: relative;
  z-index: 1;
}
.m-port-bottom {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 0;
  background: transparent;
}
.m-combat-bottom {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 0;
  background: transparent;
}

/* Firm name banner */
.m-firm-banner {
  text-align: center;
  padding: max(10px, var(--safe-top)) 12px 2px;
  background: var(--bg);
  font-family: "Cormorant Garamond", serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.5px;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(200, 164, 92, 0.2);
}

/* Location / date row */
.m-header {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 4px 12px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  font-size: 12px;
}
.m-header .m-location {
  background: var(--inverse-bg);
  color: var(--inverse-fg);
  padding: 3px 10px;
  font-weight: 500;
  font-size: 14px;
}
.m-header .m-date { color: var(--fg-dim); }

/* Status bar */
.m-status-bar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  background: rgba(18, 34, 64, 0.8);
}
.m-stat { text-align: center; }
.m-stat-label { color: var(--fg-dim); font-size: 12px; line-height: 1; }
.m-stat-value { color: var(--accent-bright); font-size: 17px; line-height: 1.2; }
.m-stat-value.danger { color: var(--danger); }

/* Cargo / warehouse / hold sections */
.m-cargo-section {
  padding: 12px 16px;
  margin: 6px 10px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
}
/* Warehouse — warm parchment card */
#m-warehouseSection {
  background: rgba(200, 164, 92, 0.08);
  border: 1px solid rgba(200, 164, 92, 0.20);
}
#m-warehouseSection .m-section-title {
  color: var(--accent);
}
/* Hold — deep navy card */
#m-holdSection {
  background: rgba(8, 18, 35, 0.8);
  border: 1px solid rgba(42, 74, 107, 0.4);
}
#m-holdSection .m-section-title {
  color: var(--link);
}
.m-section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--fg-dim);
  margin-bottom: 8px;
  width: 100%;
  max-width: 320px;
}
.m-cargo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 36px;
  font-size: 17px;
  width: 100%;
  max-width: 320px;
}
.m-cargo-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.m-cargo-name { color: var(--fg); }
.m-cargo-qty { color: var(--accent); text-align: right; }
.m-cargo-qty.dim { color: var(--fg-dim); }

/* Prices section */
.m-prices-section {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
}
.m-prices-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--fg-dim);
  margin-bottom: 8px;
  width: 100%;
  max-width: 320px;
}
.m-price-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 36px;
  font-size: 17px;
  width: 100%;
  max-width: 320px;
}
.m-price-row {
  display: flex;
  justify-content: space-between;
}
.m-price-name { color: var(--fg); }
.m-price-val { color: var(--highlight); }

/* Port message */
.m-message {
  padding: 12px 20px;
  font-size: 16px;
  color: var(--fg);
  flex: 1 0 auto;
  display: flex;
  align-items: center;
}
.m-message:empty {
  display: none;
}

/* Port action buttons — 2 columns */
.m-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px 16px 20px;
}

/* ── Action area background patterns (per-port) ── */
:root {
  --pat-opacity: 0.5;
}

/* Screens that show patterns get transparent background so .m-app::before shows through */
.m-screen.pat-transparent,
#m-portSection.active,
#m-combatSection.active {
  background: transparent;
}

/* Persistent pattern layer on app container — survives screen transitions */
.m-app::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: var(--pat-opacity);
  pointer-events: none;
  z-index: 0;
  background-size: auto;
  background-repeat: repeat;
}

/* Buttons and content must sit above the pattern layer */
.m-port-btn,
.m-combat-btn,
.m-dest-btn,
.m-message,
.m-seaworthiness-bar,
.m-combat-message,
.m-combat-actions,
.m-travel-screen,
.m-tap-continue {
  position: relative;
  z-index: 1;
}

/* Hong Kong — Double Happiness lattice */
.m-app.loc-hongkong::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'%3E%3Cg fill='none' stroke='%234a7a9b' stroke-width='0.8' opacity='0.7'%3E%3Crect x='5' y='5' width='50' height='50' /%3E%3Crect x='15' y='15' width='30' height='30' /%3E%3Cline x1='5' y1='5' x2='15' y2='15' /%3E%3Cline x1='55' y1='5' x2='45' y2='15' /%3E%3Cline x1='5' y1='55' x2='15' y2='45' /%3E%3Cline x1='55' y1='55' x2='45' y2='45' /%3E%3Crect x='22' y='22' width='16' height='16' transform='rotate(45 30 30)' /%3E%3C/g%3E%3C/svg%3E");
}

/* Shanghai — Thunder/Rain pattern (interlocking T) */
.m-app.loc-shanghai::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cg fill='none' stroke='%234a7a9b' stroke-width='1' opacity='0.75'%3E%3Cpath d='M0,12 L12,12 L12,0' /%3E%3Cpath d='M24,12 L24,24 L12,24 L12,12' /%3E%3Cpath d='M24,36 L36,36 L36,24' /%3E%3Cpath d='M48,36 L48,48 L36,48 L36,36' /%3E%3Cpath d='M0,36 L0,24 L12,24' /%3E%3Cpath d='M48,12 L48,0 L36,0' /%3E%3Cpath d='M24,0 L24,12 L36,12 L36,24' /%3E%3Cpath d='M0,48 L12,48 L12,36 L24,36 L24,48' /%3E%3C/g%3E%3C/svg%3E");
}

/* Nagasaki — Seigaiha wave arcs at 2x scale */
.m-app.loc-nagasaki::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='112' height='56' viewBox='0 0 112 56'%3E%3Cg fill='none' stroke='%234a7a9b' stroke-width='1' opacity='0.75'%3E%3Cpath d='M56,56 C56,30 30,0 0,0' /%3E%3Cpath d='M56,56 C56,30 82,0 112,0' /%3E%3Cpath d='M56,56 C56,38 38,12 16,8' /%3E%3Cpath d='M56,56 C56,38 74,12 96,8' /%3E%3Cpath d='M0,56 C0,30 -26,0 -56,0' /%3E%3Cpath d='M0,56 C0,30 26,0 56,0' /%3E%3Cpath d='M0,56 C0,38 -18,12 -40,8' /%3E%3Cpath d='M0,56 C0,38 18,12 40,8' /%3E%3Cpath d='M112,56 C112,30 86,0 56,0' /%3E%3Cpath d='M112,56 C112,30 138,0 168,0' /%3E%3Cpath d='M112,56 C112,38 94,12 72,8' /%3E%3Cpath d='M112,56 C112,38 130,12 152,8' /%3E%3C/g%3E%3C/svg%3E");
}

/* Saigon — Dragon Scale (overlapping arcs) */
.m-app.loc-saigon::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cg fill='none' stroke='%234a7a9b' stroke-width='0.8' opacity='0.75'%3E%3Cpath d='M0,24 C0,10.7 10.7,0 24,0 C37.3,0 48,10.7 48,24' /%3E%3Cpath d='M-24,48 C-24,34.7 -13.3,24 0,24 C13.3,24 24,34.7 24,48' /%3E%3Cpath d='M24,48 C24,34.7 34.7,24 48,24 C61.3,24 72,34.7 72,48' /%3E%3C/g%3E%3C/svg%3E");
}

/* Manila — Azulejo Tile (Spanish colonial ceramic) */
.m-app.loc-manila::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'%3E%3Cg fill='none' stroke='%234a7a9b' stroke-width='0.8' opacity='0.75'%3E%3Crect x='0' y='0' width='60' height='60' /%3E%3Crect x='10' y='10' width='40' height='40' /%3E%3Ccircle cx='30' cy='30' r='14' /%3E%3Cline x1='0' y1='0' x2='10' y2='10' /%3E%3Cline x1='60' y1='0' x2='50' y2='10' /%3E%3Cline x1='0' y1='60' x2='10' y2='50' /%3E%3Cline x1='60' y1='60' x2='50' y2='50' /%3E%3C/g%3E%3C/svg%3E");
}

/* Singapore — Batik Kawung (Malay/Javanese palm fruit) */
.m-app.loc-singapore::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cg fill='none' stroke='%234a7a9b' stroke-width='0.8' opacity='0.75'%3E%3Cellipse cx='24' cy='12' rx='8' ry='10' /%3E%3Cellipse cx='24' cy='36' rx='8' ry='10' /%3E%3Cellipse cx='12' cy='24' rx='10' ry='8' /%3E%3Cellipse cx='36' cy='24' rx='10' ry='8' /%3E%3Ccircle cx='24' cy='24' r='3' /%3E%3C/g%3E%3C/svg%3E");
}

/* Batavia — Delft Tile (Dutch blue-and-white ceramic) */
.m-app.loc-batavia::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%234a7a9b' stroke-width='0.8' opacity='0.75'%3E%3Crect x='0' y='0' width='56' height='56' /%3E%3Ccircle cx='28' cy='28' r='18' /%3E%3Cline x1='28' y1='10' x2='28' y2='46' /%3E%3Cline x1='10' y1='28' x2='46' y2='28' /%3E%3Ccircle cx='0' cy='0' r='8' /%3E%3Ccircle cx='56' cy='0' r='8' /%3E%3Ccircle cx='0' cy='56' r='8' /%3E%3Ccircle cx='56' cy='56' r='8' /%3E%3C/g%3E%3C/svg%3E");
}

/* Combat — Anchor at 0.4x scale, tiled from bottom to align with button grid */
.m-app.loc-combat::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='48' viewBox='0 0 100 120'%3E%3Cg fill='none' stroke='%234a7a9b' stroke-width='1.4' opacity='0.7'%3E%3Ccircle cx='50' cy='20' r='10' /%3E%3Cline x1='50' y1='30' x2='50' y2='100' /%3E%3Cline x1='25' y1='55' x2='75' y2='55' /%3E%3Cpath d='M18,78 C22,95 38,100 50,100 C62,100 78,95 82,78' /%3E%3C/g%3E%3C/svg%3E");
  background-position: left bottom 10px;
}

.m-port-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg);
  padding: 12px 4px;
  text-align: center;
  font-family: "DM Mono", monospace;
  font-size: 16px;
  cursor: pointer;
  min-height: 44px;
  -webkit-tap-highlight-color: rgba(200, 164, 92, 0.2);
}
.m-port-btn:has(.m-btn-label) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 4px;
}
.m-btn-label { display: block; }
.m-btn-sub { display: block; font-size: 12px; color: var(--fg-dim); line-height: 1.2; }
.m-port-btn:active { background: var(--border); }
.m-port-btn.disabled {
  background: var(--bg-surface);
  border-style: dashed;
  border-color: rgba(42, 74, 107, 0.4);
  color: rgba(102, 119, 136, 0.5);
  pointer-events: none;
}
.m-port-btn.sail {
  order: 99;
  grid-column: 2;
}


/* ================================================================
   6. Buy/Sell Screen
   ================================================================ */

/* Context header */
.m-ctx-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: max(8px, var(--safe-top)) 12px 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  font-size: 12px;
}
.m-ctx-header .m-location {
  background: var(--inverse-bg);
  color: var(--inverse-fg);
  padding: 2px 8px;
  font-weight: 500;
}
.m-ctx-header .m-info { color: var(--fg-dim); }
.m-ctx-header .m-info .m-val { color: var(--accent-bright); }

.m-buy-screen {
  padding: 8px 0;
  margin-top: auto;
}
.m-buy-prompt {
  padding: 8px 14px 10px;
  font-size: 15px;
  color: var(--fg);
}

/* Commodity row */
.m-commodity-row {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(42, 74, 107, 0.3);
}
.m-commodity-top {
  display: flex;
  align-items: baseline;
  margin-bottom: 8px;
  gap: 6px;
}
.m-commodity-name {
  font-size: 14px;
  color: var(--fg);
}
.m-commodity-price {
  color: var(--highlight);
  font-size: 13px;
}
.m-commodity-spacer { flex: 1; }
.m-commodity-top .m-hold-info {
  color: var(--fg-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Quick action buttons */
.m-quick-actions {
  display: flex;
  flex-direction: row-reverse;
  gap: 6px;
}
.m-qa-btn {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  height: 58px;
  text-align: center;
  cursor: pointer;
  padding: 0 4px;
  position: relative;
  -webkit-tap-highlight-color: rgba(200, 164, 92, 0.2);
}
.m-qa-btn:active { border-color: var(--accent); background: rgba(200, 164, 92, 0.1); }
.m-qa-btn .m-qa-label {
  position: absolute;
  top: 50%;
  left: 0; right: 0;
  transform: translateY(-50%);
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  font-family: "DM Mono", monospace;
  line-height: 1.2;
}
.m-qa-btn .m-qa-detail {
  position: absolute;
  top: 50%;
  left: 0; right: 0;
  margin-top: 10px;
  font-size: 11px;
  color: var(--fg-dim);
  font-family: "DM Mono", monospace;
  line-height: 1.2;
}
.m-qa-btn.disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* Done / cancel row */
.m-cancel-row {
  text-align: center;
  padding: 16px 24px 36px;
  margin-top: auto;
}
.m-cancel-btn {
  display: block;
  width: 100%;
  color: var(--fg);
  font-size: 16px;
  padding: 14px 24px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
  font-family: "DM Mono", monospace;
  min-height: 48px;
  -webkit-tap-highlight-color: rgba(200, 164, 92, 0.2);
}
.m-cancel-btn:active { border-color: var(--accent); background: rgba(200, 164, 92, 0.1); }


/* ================================================================
   7. Choose Panel (slider + presets + numpad)
   ================================================================ */
.m-choose-panel {
  background: var(--bg);
  padding: 14px 14px 24px;
  display: none;
}
.m-choose-panel.active {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.m-choose-header {
  text-align: center;
  margin-bottom: 12px;
}
.m-choose-header .m-what {
  font-size: 14px;
  color: var(--fg);
}
.m-choose-header .m-what .m-commodity { color: var(--accent); }
.m-choose-header .m-detail {
  font-size: 11px;
  color: var(--fg-dim);
  margin-top: 2px;
}

.m-choose-display {
  text-align: center;
  padding: 10px;
  margin-bottom: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-height: 76px;
  box-sizing: border-box;
}
.m-choose-display .m-number {
  font-size: 28px;
  color: var(--accent-bright);
  font-weight: 500;
}
.m-choose-display .m-cost {
  font-size: 11px;
  color: var(--fg-dim);
  margin-top: 2px;
}

/* Slider */
.m-choose-slider {
  padding: 0 4px;
  margin-bottom: 14px;
}
.m-choose-slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}
.m-choose-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
  cursor: pointer;
}
.m-slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--fg-dim);
  margin-top: 4px;
}

/* Preset row */
.m-preset-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.m-preset-btn {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg);
  padding: 8px 0;
  text-align: center;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  -webkit-tap-highlight-color: rgba(200, 164, 92, 0.2);
}
.m-preset-btn:active { background: rgba(200, 164, 92, 0.1); }
.m-preset-btn .m-preset-detail {
  display: block;
  font-size: 9px;
  color: var(--fg-dim);
  font-weight: 400;
  margin-top: 1px;
}

/* Numpad */
.m-numpad {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 5px;
  margin-bottom: 12px;
}
.m-num-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg);
  padding: 10px 0;
  text-align: center;
  font-family: "DM Mono", monospace;
  font-size: 20px;
  cursor: pointer;
  min-height: 44px;
  -webkit-tap-highlight-color: rgba(200, 164, 92, 0.2);
}
.m-num-btn:active { background: rgba(200, 164, 92, 0.1); }
.m-num-btn.backspace {
  font-size: 22px;
  color: var(--fg-dim);
}
.m-num-btn.op {
  color: var(--accent);
  font-size: 22px;
}
.m-num-btn.suffix {
  color: var(--accent);
  font-size: 18px;
}
.m-num-btn.clear {
  font-size: 13px;
  color: var(--danger);
}

/* Choose actions */
.m-choose-actions {
  display: flex;
  gap: 8px;
}
.m-choose-cancel {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg-dim);
  font-family: "DM Mono", monospace;
  font-size: 13px;
  text-align: center;
  cursor: pointer;
  min-height: 44px;
  -webkit-tap-highlight-color: rgba(200, 164, 92, 0.2);
}
.m-choose-confirm {
  flex: 2;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
  font-family: "DM Mono", monospace;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  min-height: 44px;
  -webkit-tap-highlight-color: rgba(200, 164, 92, 0.2);
}
.m-choose-confirm:active { background: rgba(200, 164, 92, 0.15); }


/* ================================================================
   8. Event Screen (Y/N prompts, messages)
   ================================================================ */
.m-screen-header {
  padding: max(10px, var(--safe-top)) 20px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  color: var(--accent-bright);
  display: none;
}

.m-event-screen {
  padding: 20px 28px 36px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: left;
}
.m-event-screen .m-report-title {
  display: none;
}
.m-event-msg {
  font-size: 16px;
  color: var(--fg);
  line-height: 1.6;
  margin-bottom: 20px;
}
.m-event-msg .m-name { color: var(--accent); font-weight: 500; }
.m-event-msg .m-cost { color: var(--highlight); font-weight: 500; }
.m-event-msg .m-warning { color: var(--danger); }

.m-yn-buttons {
  display: flex;
  gap: 8px;
}
.m-yn-btn {
  flex: 1;
  padding: 16px;
  border-radius: 6px;
  text-align: center;
  font-family: "DM Mono", monospace;
  font-size: 16px;
  cursor: pointer;
  min-height: 44px;
  -webkit-tap-highlight-color: rgba(200, 164, 92, 0.2);
}
.m-yn-btn.yes {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
}
.m-yn-btn.yes:active { background: rgba(200, 164, 92, 0.1); }
.m-yn-btn.no {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
}
.m-yn-btn.no:active { background: rgba(200, 164, 92, 0.1); }

/* Amount input (repair, repay, borrow) */
.m-amount-prompt {
  padding: 20px 20px 36px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.m-amount-prompt .m-report-title {
  font-size: 15px;
  color: var(--accent-bright);
  margin-bottom: 12px;
}
.m-amount-prompt .m-prompt-msg {
  font-size: 16px;
  color: var(--fg);
  line-height: 1.6;
  margin-bottom: 20px;
}
.m-amount-prompt .m-prompt-msg .m-cost { color: var(--highlight); }

.m-amount-display {
  text-align: center;
  padding: 10px;
  margin-bottom: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.m-amount-display .m-number {
  font-size: 24px;
  color: var(--accent-bright);
  font-weight: 500;
}

.m-amount-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.m-amount-preset {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border-accent);
  border-radius: 6px;
  color: var(--accent);
  padding: 8px 2px;
  text-align: center;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  cursor: pointer;
  min-height: 44px;
  -webkit-tap-highlight-color: rgba(200, 164, 92, 0.2);
}
.m-amount-preset:active { background: rgba(200, 164, 92, 0.1); }

.m-amount-actions {
  display: flex;
  gap: 8px;
}
.m-amount-cancel {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg-dim);
  font-family: "DM Mono", monospace;
  font-size: 13px;
  text-align: center;
  cursor: pointer;
  min-height: 44px;
}
.m-amount-confirm {
  flex: 2;
  padding: 12px;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--inverse-fg);
  font-family: "DM Mono", monospace;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  min-height: 44px;
}


/* ================================================================
   9. Travel Screen (destination picker + travel messages)
   ================================================================ */

/* Destination picker */
.m-dest-screen {
  padding: 20px 36px 36px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.m-dest-prompt {
  font-size: 15px;
  margin-bottom: 18px;
  color: var(--fg);
}
.m-dest-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 24px;
}
.m-dest-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 10px;
  text-align: center;
  font-family: "DM Mono", monospace;
  font-size: 14px;
  color: var(--fg);
  cursor: pointer;
  position: relative;
  min-height: 44px;
  -webkit-tap-highlight-color: rgba(200, 164, 92, 0.2);
}
.m-dest-btn:active { border-color: var(--accent); background: rgba(200, 164, 92, 0.1); }
.m-dest-btn.current {
  background: var(--bg-surface);
  border-style: dashed;
  border-color: rgba(42, 74, 107, 0.5);
  color: var(--fg-dim);
}
.m-dest-btn.current::after {
  content: '(here)';
  position: absolute;
  left: 0; right: 0;
  bottom: 3px;
  font-size: 9px;
  color: var(--fg-dim);
  text-align: center;
}
.m-dest-cancel {
  border-style: dashed;
}

/* Destination buttons inside port actions area — tighter fit */
.m-actions .m-dest-btn {
  padding: 10px 8px;
}

/* Travel messages (at sea, storm, etc.) */
.m-travel-screen {
  padding: 20px 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: left;
  padding: max(20px, var(--safe-top)) 28px 20px;
}
.m-travel-screen .m-report-title {
  display: none;
}
.m-travel-screen .m-travel-msg {
  font-size: 18px;
  color: var(--fg);
  line-height: 1.6;
}
.m-travel-screen .m-travel-msg .highlight {
  color: var(--accent-bright);
  font-weight: 500;
}
.m-travel-screen .m-travel-msg .danger {
  color: var(--danger);
  font-weight: 500;
}
.m-travel-screen .m-travel-submsg {
  font-size: 13px;
  color: var(--fg-dim);
  margin-top: 12px;
}

/* Tap-to-continue */
.m-tap-continue {
  text-align: center;
  padding: 20px 36px 36px;
}
.m-tap-btn {
  color: var(--fg);
  font-size: 14px;
  padding: 14px 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-family: "DM Mono", monospace;
  cursor: pointer;
  min-height: 44px;
  -webkit-tap-highlight-color: rgba(200, 164, 92, 0.2);
}
.m-tap-btn:active { border-color: var(--accent); background: rgba(200, 164, 92, 0.1); }


/* ================================================================
   10. Combat Screen
   ================================================================ */
.m-combat-scene {
  position: relative;
  z-index: 1;
  height: 449px;
  overflow: hidden;
  background: linear-gradient(180deg, #6aaccc 0%, #4a90b8 20%, #3878a8 50%, #1e5888 100%);
}

/* Sky gradient — matches desktop's bright sky above horizon */
.m-combat-sky {
  position: absolute;
  top: 0; left: 0; right: 0; height: 100px;
  background: linear-gradient(180deg, #c8a050 0%, #e8c870 30%, #c8c8a0 50%, #8ab4c8 72%, #6a9cb8 100%);
  pointer-events: none;
  z-index: 0;
}

/* Horizon haze */
.m-horizon-haze {
  position: absolute;
  top: 93px; left: 0; right: 0;
  height: 14px;
  z-index: 3;
  background: linear-gradient(180deg, transparent 0%, rgba(255,245,220,0.25) 30%, rgba(255,250,230,0.45) 50%, rgba(200,220,235,0.20) 75%, transparent 100%);
  pointer-events: none;
  z-index: 1;
}

/* Ocean SVG layers — same technique as desktop .ocean-layer */
.m-ocean-layer {
  position: absolute;
  top: 100px; left: 0; right: 0; bottom: 0;
  overflow: hidden;
  pointer-events: none;
  contain: strict;
  z-index: 2;
}
.m-ocean-layer svg {
  position: absolute;
  width: 200%;
  height: 100%;
  left: 0;
  top: 0;
  will-change: transform;
}
.m-ocean-layer.ol-a svg { animation: m-combat-ocean-drift 18s linear infinite; }
.m-ocean-layer.ol-b svg { animation: m-combat-ocean-drift 25s linear infinite; animation-delay: -10s; }
.m-ocean-layer.ol-a { animation: m-combat-wave-bob-a 5s ease-in-out infinite; transform-origin: top; }
.m-ocean-layer.ol-b { animation: m-combat-wave-bob-b 6.5s ease-in-out infinite; animation-delay: -3s; transform-origin: top; }
@keyframes m-combat-ocean-drift {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
@keyframes m-combat-wave-bob-a {
  0%, 100% { transform: translateY(0) scaleY(1); }
  50% { transform: translateY(2.5px) scaleY(1.015); }
}
@keyframes m-combat-wave-bob-b {
  0%, 100% { transform: translateY(0) scaleY(1.01); }
  50% { transform: translateY(-2px) scaleY(0.985); }
}

/* Combat topbar */
.m-combat-topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: max(8px, var(--safe-top)) 10px 8px;
  z-index: 10;
  background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, transparent 100%);
}
.m-combat-topbar .m-ship-count,
.m-combat-topbar .m-guns-box {
  line-height: 1.2;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 4px 8px 5px 12px;
  font-size: 12px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.m-combat-topbar .m-ship-count {
  color: #C03030;
}
.m-combat-topbar .m-guns-box {
  color: #2A3A4A;
}

/* Ship slots — positioned dynamically by JS, hold sprite controller movers */
.combat-ship {
  position: absolute;
  z-index: 3;
  pointer-events: none;
}
.combat-edge {
  opacity: 1;
}

/* Sprite controller: outer mover handles sail-in/flee translation (mobile) */
#m-combatScene .ship-mover {
  position: absolute;
  width: 83px; height: 71px;
  left: 0; top: 0;
}
/* Sprite controller: inner slot handles bob animation */
#m-combatScene .ship-mover .ship-slot {
  width: 83px; height: 71px;
  animation: m-ship-bob 3s infinite ease-in-out alternate;
}
#m-combatScene .ship-mover .ship-slot canvas {
  width: 83px; height: 71px;
  display: block;
}
@keyframes m-ship-bob {
  0% { transform: rotate(-3.5deg); }
  100% { transform: rotate(3.5deg); }
}
@keyframes ship-arrive {
  from { transform: translateX(var(--sail-offset)); }
  to { transform: translateX(0); }
}
@keyframes ship-flee {
  from { transform: translateX(0); }
  to { transform: translateX(var(--sail-offset)); }
}


/* Combat effects — flash overlays (mobile-scoped by ID prefix) */
#m-playerFlashGlow,
#m-playerFlashSpark,
#m-enemyFlashGlow {
  position: absolute;
  left: 0; top: 0; right: 0; bottom: 0;
  opacity: 0;
  pointer-events: none;
}
#m-playerFlashGlow {
  z-index: 500;
  background: radial-gradient(ellipse 90% 70% at 50% 55%,
    rgba(255, 255, 240, 0.6) 0%,
    rgba(255, 255, 240, 0.3) 30%,
    rgba(255, 255, 240, 0.08) 55%,
    transparent 80%);
}
#m-playerFlashSpark {
  z-index: 501;
  background: radial-gradient(ellipse 40% 30% at 50% 60%,
    rgba(255, 240, 200, 0.7) 0%,
    rgba(255, 240, 200, 0.3) 40%,
    transparent 70%);
}
#m-enemyFlashGlow {
  z-index: 500;
  background: radial-gradient(ellipse 85% 65% at 50% 50%,
    rgba(255, 255, 240, 0.7) 0%,
    rgba(255, 255, 240, 0.35) 35%,
    transparent 65%);
}

/* Smoke containers */
#m-playerSmoke {
  position: absolute;
  left: -40px; right: -40px; top: -30px; bottom: -15px;
  z-index: 450;
  pointer-events: none;
  opacity: 0;
}
#m-enemySmoke {
  position: absolute;
  left: -15px; right: -15px; top: -30px; bottom: 0;
  z-index: 450;
  pointer-events: none;
  opacity: 0;
}

/* Smoke particles — base styles (positions set dynamically by JS) */
#m-combatScene .smoke-particle {
  position: absolute;
  border-radius: 50%;
  background-color: rgba(240, 240, 235, 1);
}

/* Player smoke — knots (scaled down from desktop) */
#m-playerSmoke .smoke-particle:nth-child(1)  { width: 120px; height: 87px;  left: -2%;  top: 78%; filter: blur(10px); border-radius: 60% 40% 55% 45%; }
#m-playerSmoke .smoke-particle:nth-child(2)  { width: 107px; height: 80px;  left: 20%;  top: 82%; filter: blur(10px); border-radius: 45% 55% 40% 60%; }
#m-playerSmoke .smoke-particle:nth-child(3)  { width: 127px; height: 93px;  left: 42%;  top: 80%; filter: blur(10px); border-radius: 50% 60% 45% 55%; }
#m-playerSmoke .smoke-particle:nth-child(4)  { width: 113px; height: 83px;  left: 66%;  top: 84%; filter: blur(10px); border-radius: 55% 45% 60% 40%; }
#m-playerSmoke .smoke-particle:nth-child(5)  { width: 100px; height: 77px;  left: 84%;  top: 79%; filter: blur(10px); border-radius: 40% 60% 50% 50%; }
#m-playerSmoke .smoke-particle:nth-child(6)  { width: 133px; height: 97px;  left: 5%;   top: 66%; filter: blur(10px); border-radius: 55% 45% 50% 50%; }
#m-playerSmoke .smoke-particle:nth-child(7)  { width: 117px; height: 87px;  left: 32%;  top: 70%; filter: blur(10px); border-radius: 45% 55% 55% 45%; }
#m-playerSmoke .smoke-particle:nth-child(8)  { width: 123px; height: 90px;  left: 55%;  top: 64%; filter: blur(10px); border-radius: 60% 40% 45% 55%; }
#m-playerSmoke .smoke-particle:nth-child(9)  { width: 110px; height: 83px;  left: 76%;  top: 68%; filter: blur(10px); border-radius: 50% 50% 60% 40%; }
#m-playerSmoke .smoke-particle:nth-child(10) { width: 100px; height: 73px;  left: 8%;   top: 56%; filter: blur(11px); border-radius: 45% 55% 50% 50%; }
#m-playerSmoke .smoke-particle:nth-child(11) { width: 93px;  height: 70px;  left: 38%;  top: 54%; filter: blur(11px); border-radius: 55% 45% 45% 55%; }
#m-playerSmoke .smoke-particle:nth-child(12) { width: 103px; height: 77px;  left: 65%;  top: 58%; filter: blur(11px); border-radius: 50% 50% 55% 45%; }
#m-playerSmoke .smoke-particle:nth-child(13) { width: 160px; height: 120px; left: 25%;  top: 72%; filter: blur(11px); border-radius: 55% 45% 50% 50%; }
#m-playerSmoke .smoke-particle:nth-child(14) { width: 147px; height: 107px; left: 45%;  top: 74%; filter: blur(11px); border-radius: 45% 55% 55% 45%; }

/* Player smoke — connective fill (large, soft, low opacity) */
#m-playerSmoke .smoke-particle:nth-child(15) { width: 233px; height: 133px; left: -3%;  top: 74%; filter: blur(20px); border-radius: 50%; }
#m-playerSmoke .smoke-particle:nth-child(16) { width: 253px; height: 147px; left: 25%;  top: 72%; filter: blur(21px); border-radius: 50%; }
#m-playerSmoke .smoke-particle:nth-child(17) { width: 227px; height: 133px; left: 55%;  top: 74%; filter: blur(20px); border-radius: 50%; }
#m-playerSmoke .smoke-particle:nth-child(18) { width: 213px; height: 127px; left: 10%;  top: 60%; filter: blur(20px); border-radius: 50%; }
#m-playerSmoke .smoke-particle:nth-child(19) { width: 233px; height: 133px; left: 45%;  top: 58%; filter: blur(21px); border-radius: 50%; }
#m-playerSmoke .smoke-particle:nth-child(20) { width: 187px; height: 107px; left: 5%;   top: 50%; filter: blur(18px); border-radius: 50%; }
#m-playerSmoke .smoke-particle:nth-child(21) { width: 200px; height: 113px; left: 40%;  top: 52%; filter: blur(20px); border-radius: 50%; }
#m-playerSmoke .smoke-particle:nth-child(22) { width: 267px; height: 167px; left: 18%;  top: 64%; filter: blur(22px); border-radius: 50%; }

/* Enemy smoke — particle sizes (positions set dynamically by JS) */
#m-enemySmoke .smoke-particle:nth-child(1)  { width: 60px;  height: 47px;  filter: blur(7px); }
#m-enemySmoke .smoke-particle:nth-child(2)  { width: 73px;  height: 53px;  filter: blur(7px); }
#m-enemySmoke .smoke-particle:nth-child(3)  { width: 47px;  height: 37px;  filter: blur(7px); }
#m-enemySmoke .smoke-particle:nth-child(4)  { width: 67px;  height: 50px;  filter: blur(7px); }
#m-enemySmoke .smoke-particle:nth-child(5)  { width: 53px;  height: 40px;  filter: blur(7px); }
#m-enemySmoke .smoke-particle:nth-child(6)  { width: 80px;  height: 57px;  filter: blur(7px); }
#m-enemySmoke .smoke-particle:nth-child(7)  { width: 50px;  height: 40px;  filter: blur(7px); }
#m-enemySmoke .smoke-particle:nth-child(8)  { width: 63px;  height: 47px;  filter: blur(7px); }
#m-enemySmoke .smoke-particle:nth-child(9)  { width: 43px;  height: 33px;  filter: blur(7px); }
#m-enemySmoke .smoke-particle:nth-child(10) { width: 53px;  height: 43px;  filter: blur(7px); }
#m-enemySmoke .smoke-particle:nth-child(11) { width: 40px;  height: 33px;  filter: blur(7px); }
#m-enemySmoke .smoke-particle:nth-child(12) { width: 60px;  height: 43px;  filter: blur(7px); }

/* Throw cargo prompt (rendered inside combat message) */
.m-throw-prompt {
  margin-bottom: 8px;
  font-size: 13px;
}
.m-throw-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.m-throw-buttons .m-btn {
  font-size: 12px;
  padding: 10px 8px;
  flex: 1 1 auto;
  min-width: 80px;
}

/* Seaworthiness bar */
.m-seaworthiness-bar {
  padding: 6px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}
.m-sw-label { color: var(--fg-dim); white-space: nowrap; }
.m-sw-track {
  flex: 1;
  height: 8px;
  background: rgba(42, 74, 107, 0.5);
  border-radius: 4px;
  overflow: hidden;
}
.m-sw-fill {
  height: 100%;
  border-radius: 4px;
}
.m-sw-fill.good { background: #6cb86c; }
.m-sw-fill.warn { background: var(--accent); }
.m-sw-fill.danger { background: var(--danger); }
.m-sw-pct { color: var(--fg); min-width: 32px; text-align: right; }

/* Combat message */
.m-combat-message {
  padding: 10px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  height: 44px;
  overflow: hidden;
  display: flex;
  align-items: center;
  background: var(--bg);
}
.m-combat-message:has(.m-throw-prompt) {
  height: auto;
}

/* Combat action buttons (2x2) */
.m-combat-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 10px 12px;
  background: transparent;
}
.m-combat-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg);
  padding: 14px 4px;
  text-align: center;
  font-family: "DM Mono", monospace;
  font-size: 14px;
  cursor: pointer;
  min-height: 44px;
  -webkit-tap-highlight-color: rgba(200, 164, 92, 0.2);
}
.m-combat-btn:active { border-color: var(--accent); background: rgba(200, 164, 92, 0.1); }
.m-combat-btn.active-order {
  border-color: var(--accent);
  background: rgba(200, 164, 92, 0.12);
  color: var(--accent-bright);
  box-shadow: 0 0 8px rgba(200, 164, 92, 0.2);
  font-weight: 500;
}
.m-combat-btn.death { font-size: 12px; }
.m-combat-btn.disabled {
  background: var(--bg-surface);
  border-style: dashed;
  border-color: rgba(42, 74, 107, 0.3);
  color: rgba(102, 119, 136, 0.35);
  pointer-events: none;
}


/* ================================================================
   11. Game Over Screen
   ================================================================ */
.m-gameover-screen {
  padding: max(28px, var(--safe-top)) 24px 28px;
  background-color: var(--bg-surface);
  background-image:
    radial-gradient(ellipse at 20% 80%, rgba(200, 164, 92, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(122, 173, 207, 0.03) 0%, transparent 50%);
}
.m-gameover-title {
  font-family: "Cormorant Garamond", serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  margin-bottom: 20px;
}
.m-gameover-stats {
  margin-bottom: 16px;
}
.m-gameover-stat {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(42, 74, 107, 0.3);
  font-size: 13px;
}
.m-gameover-stat .m-label { color: var(--fg-dim); }
.m-gameover-stat .m-value { color: var(--fg); }
.m-gameover-stat .m-value.gold { color: var(--accent-bright); }

.m-gameover-score {
  text-align: center;
  padding: 14px;
  margin: 16px 0;
  background: var(--inverse-bg);
  color: var(--inverse-fg);
  border-radius: 6px;
}
.m-gameover-score .m-score-label { font-size: 12px; }
.m-gameover-score .m-score-value { font-size: 28px; font-weight: 500; }

.m-gameover-rating {
  margin-bottom: 16px;
}
.m-gameover-rating .m-rating-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--fg-dim);
  margin-bottom: 8px;
  text-align: center;
}
.m-rating-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 12px;
  font-size: 12px;
  border-bottom: 1px solid rgba(42, 74, 107, 0.2);
}
.m-rating-row .m-rank-name { color: var(--fg-dim); }
.m-rating-row .m-rank-range { color: var(--fg-dim); font-size: 11px; }
.m-rating-row.active {
  background: rgba(200, 164, 92, 0.1);
  border: 1px solid var(--border-accent);
  border-radius: 4px;
}
.m-rating-row.active .m-rank-name { color: var(--accent-bright); font-weight: 500; }
.m-rating-row.active .m-rank-range { color: var(--accent); }

.m-gameover-highscore {
  text-align: center;
  color: var(--accent-bright);
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
}
.m-gameover-highscore.show { display: block; }

.m-gameover-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 8px;
}


/* ================================================================
   12. High Scores Screen
   ================================================================ */
.m-highscores-screen {
  padding: max(28px, var(--safe-top)) 16px 28px;
  background-color: var(--bg-surface);
  background-image:
    radial-gradient(ellipse at 20% 80%, rgba(200, 164, 92, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(122, 173, 207, 0.03) 0%, transparent 50%);
}
.m-highscores-title {
  font-family: "Cormorant Garamond", serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--accent);
  text-align: center;
  margin-bottom: 16px;
}
.m-hs-table {
  width: 100%;
  font-size: 11px;
  border-collapse: collapse;
}
.m-hs-table th {
  color: var(--fg-dim);
  font-weight: 400;
  text-align: left;
  padding: 4px 4px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.m-hs-table th.r { text-align: right; }
.m-hs-table td {
  padding: 6px 4px;
  border-bottom: 1px solid rgba(42, 74, 107, 0.2);
}
.m-hs-table td.r { text-align: right; }
.m-hs-table td.firm { color: var(--accent); }
.m-hs-table td.score { color: var(--accent-bright); text-align: right; }
.m-hs-table td.dim { color: var(--fg-dim); }
.m-highscores-action {
  text-align: center;
  padding: 20px 36px 8px;
}
.m-highscores-action .m-btn { width: 100%; }
