/* ============================================================
   Windward — style.css
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy-deep: #06121f;
  --navy: #0b2236;
  --navy-light: #133250;
  --parchment: #f0e6cf;
  --parchment-dark: #d8c9a3;
  --ink: #2b2317;
  --gold: #e8b94a;
  --gold-dark: #b8892c;
  --good: #6fd087;
  --bad: #e87a6a;
  --dim: #8fa3b8;
}

html, body { height: 100%; }
body {
  background: var(--navy-deep);
  color: #dde8f2;
  font-family: Georgia, "Times New Roman", serif;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;   /* stop iOS from inflating text */
  text-size-adjust: 100%;
  touch-action: manipulation;        /* kill double-tap zoom + 300ms delay */
  overscroll-behavior: none;         /* no pull-to-refresh / rubber-banding */
}

button { font-family: inherit; cursor: pointer; }

.btn {
  background: var(--navy-light);
  color: #dde8f2;
  border: 1px solid #2a5278;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 14px;
  margin: 3px 2px;
  transition: background .12s, transform .05s;
}
.btn:hover:not(:disabled) { background: #1b466e; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-gold {
  background: linear-gradient(#f3c75e, #cf9c33);
  color: #3a2a08; border-color: #8a6a1e; font-weight: bold;
}
.btn-gold:hover:not(:disabled) { background: linear-gradient(#ffd76e, #dfa93d); }
.btn-small { padding: 3px 9px; font-size: 12px; }

.dim { color: var(--dim); font-size: .92em; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.big { font-size: 1.25em; }

/* ---------- title screen ---------- */
#title-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 30% 20%, #14406688 0%, transparent 50%),
    radial-gradient(ellipse at 75% 80%, #0d2f4d88 0%, transparent 55%),
    var(--navy-deep);
}
.title-box {
  max-width: 560px; text-align: center; padding: 48px 40px;
  background: rgba(8, 24, 40, .85);
  border: 1px solid #2a5278; border-radius: 14px;
  box-shadow: 0 0 80px #04101daa;
}
.lang-row { display: flex; justify-content: center; gap: 6px; margin-bottom: 14px; }
.lang-btn {
  padding: 4px 16px; font-size: 13px; border-radius: 14px;
  background: #0a1c2e; color: var(--dim); border: 1px solid #2a5278;
}
.lang-btn.active { background: var(--gold-dark); color: #fff; border-color: var(--gold); font-weight: bold; }
.title-box h1 {
  font-size: 56px; letter-spacing: 12px; color: var(--gold);
  text-shadow: 0 2px 0 #5e470f, 0 6px 24px #000;
}
.subtitle { font-size: 19px; font-style: italic; color: #aac4dc; margin: 6px 0 22px; }
.title-flavor { color: #c9d8e6; line-height: 1.5; margin-bottom: 26px; }
.title-form { display: flex; flex-direction: column; gap: 9px; max-width: 320px; margin: 0 auto; }
.title-form label { font-size: 13px; color: var(--dim); text-align: left; }
.title-form input {
  padding: 9px 12px; font-size: 16px; font-family: inherit;
  background: #0a1c2e; color: #fff; border: 1px solid #2a5278; border-radius: 6px;
}
.title-form .btn { font-size: 17px; padding: 11px; }
.title-credits { margin-top: 26px; font-size: 11px; color: #51677c; }

/* ---------- game layout ---------- */
#game-screen { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

#hud {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  background: linear-gradient(#15314c, #0d2438);
  border-bottom: 2px solid #2a5278;
  padding: 5px 10px;
  padding-top: max(5px, env(safe-area-inset-top));
  font-size: 14px;
}
.hud-group {
  padding: 3px 9px; border-radius: 5px; background: #0a1c2eaa; white-space: nowrap;
}
.hud-group.warn { background: #5e1f16; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { background: #84301f; } }
#hud-wind { margin-left: auto; }
#wind-arrow { display: inline-block; transition: transform .5s; color: var(--gold); font-size: 16px; margin-right: 5px; }
#btn-menu { margin-left: 4px; }

#main-area { position: relative; flex: 1; min-height: 0; }
#sea-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }

#minimap {
  position: absolute; top: 10px; right: 10px;
  width: 250px; border: 2px solid #2a5278; border-radius: 6px;
  background: #04101d; cursor: pointer;
  image-rendering: pixelated;
  opacity: .92;
}

#ship-banner {
  position: absolute; top: 10px; left: 12px;
  background: #0a1c2ecc; padding: 5px 12px; border-radius: 6px;
  border: 1px solid #2a527866; font-size: 14px;
}

#sail-controls {
  position: absolute; bottom: 14px; right: 14px;
  display: flex; flex-direction: column; gap: 3px; opacity: .85;
}
.pad-row { display: flex; gap: 3px; }
#sail-controls button {
  width: 40px; height: 40px; font-size: 17px;
  background: #0e2a44cc; color: #cfe0ef; border: 1px solid #2a5278; border-radius: 7px;
}
#sail-controls button:hover { background: #1b466e; }

#log-panel {
  height: 116px; background: #081826;
  border-top: 2px solid #2a5278; padding: 4px 10px;
  padding-bottom: max(4px, env(safe-area-inset-bottom));
}
#log { height: 100%; overflow-y: auto; font-size: 13px; line-height: 1.45; }
.log-line { color: #b9cadb; }
.log-line.good { color: var(--good); }
.log-line.bad { color: var(--bad); }
.log-date { color: #51677c; font-size: 11px; margin-right: 6px; }

/* ---------- modals ---------- */
#modal-veil, #port-veil {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(3, 10, 18, .72);
  display: flex; align-items: center; justify-content: center;
}
#modal-veil { z-index: 60; }

#modal-box {
  width: min(620px, 92vw); max-height: 86vh; max-height: 86dvh; overflow-y: auto;
  background: linear-gradient(var(--parchment), var(--parchment-dark));
  color: var(--ink);
  border: 3px solid #8a6a1e; border-radius: 10px;
  padding: 26px 30px 18px;
  box-shadow: 0 12px 60px #000c;
}
#modal-box h2 { color: #5e3d10; margin-bottom: 12px; font-size: 24px; }
#modal-box h3 { color: #5e3d10; }
#modal-content p { margin: 9px 0; line-height: 1.5; }
#modal-content .dim { color: #7a6a4a; }
#modal-content .good { color: #2e7d44; font-weight: bold; }
#modal-content .bad { color: #a43e2c; font-weight: bold; }
#modal-buttons { margin-top: 16px; text-align: right; }
#modal-buttons .btn {
  background: #4a3a1c; color: var(--parchment); border-color: #2e2410;
}
#modal-buttons .btn:hover:not(:disabled) { background: #5e4a24; }
#modal-buttons .btn-gold { background: linear-gradient(#f3c75e, #cf9c33); color: #3a2a08; }

.objective {
  margin: 14px 0 4px; padding: 9px 12px;
  background: #00000014; border-left: 4px solid var(--gold-dark);
  border-radius: 4px; font-style: italic;
}

/* ---------- combat ---------- */
.combat-grid { display: flex; gap: 12px; align-items: stretch; }
.combatant { flex: 1; background: #00000010; border-radius: 8px; padding: 10px 12px; }
.combatant h3 { font-size: 16px; margin-bottom: 2px; }
.combat-vs { display: flex; align-items: center; font-size: 26px; color: #8a6a1e; }
.bar {
  position: relative; height: 17px; background: #00000028;
  border-radius: 4px; overflow: hidden; margin: 3px 0 7px;
}
.bar-fill { height: 100%; background: #2e7d44; transition: width .25s; }
.bar-fill.foe { background: #a43e2c; }
.bar-fill.crew { background: #2c6ea4; }
.bar-fill.crew.foe { background: #8a5a2c; }
.bar span {
  position: absolute; inset: 0; text-align: center; font-size: 11px;
  color: #fff; text-shadow: 0 1px 2px #000; line-height: 17px;
}
.combat-log {
  margin-top: 12px; padding: 8px 12px; min-height: 84px;
  background: #00000010; border-radius: 6px; font-size: 14px;
}
.combat-log p { margin: 4px 0; }

/* ---------- port screen ---------- */
#port-box {
  width: min(960px, 96vw); height: min(640px, 92vh); height: min(640px, 92dvh);
  display: flex; flex-direction: column;
  background: linear-gradient(var(--parchment), var(--parchment-dark));
  color: var(--ink);
  border: 3px solid #8a6a1e; border-radius: 12px;
  box-shadow: 0 12px 60px #000c;
  overflow: hidden;
}
#port-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 16px 22px 10px;
}
#port-header h2 { color: #5e3d10; font-size: 26px; }
#port-desc { color: #7a6a4a; font-style: italic; font-size: 13px; max-width: 560px; }
#port-quickstats { font-size: 14px; white-space: nowrap; padding-top: 6px; }

#port-tabs { display: flex; gap: 2px; padding: 0 22px; border-bottom: 2px solid #8a6a1e55; }
.tab-btn {
  padding: 8px 18px; font-size: 15px; border: none; border-radius: 8px 8px 0 0;
  background: #00000012; color: #5a4a2a;
}
.tab-btn.active { background: #8a6a1e; color: var(--parchment); font-weight: bold; }
.tab-btn:hover:not(.active) { background: #00000022; }

#port-body { flex: 1; overflow-y: auto; padding: 14px 22px; }
.panel-cols { display: flex; gap: 18px; align-items: flex-start; }
.panel { flex: 1; min-width: 0; }
.panel h3 { color: #5e3d10; margin-bottom: 7px; }
.panel p { margin: 6px 0; line-height: 1.45; }
.panel .dim { color: #7a6a4a; }
.panel .btn { background: #4a3a1c; color: var(--parchment); border-color: #2e2410; display: block; width: 100%; text-align: left; }
.panel .btn:hover:not(:disabled) { background: #5e4a24; }
.panel .btn.btn-gold { background: linear-gradient(#f3c75e, #cf9c33); color: #3a2a08; }
.panel table .btn { display: inline-block; width: auto; }

.shop-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 8px; }
.shop-table td { padding: 4px 6px; border-bottom: 1px solid #8a6a1e22; }
.shop-table .thead td { font-weight: bold; color: #5e3d10; border-bottom: 2px solid #8a6a1e66; }
.shop-table .btn-small { background: #4a3a1c; color: var(--parchment); border-color: #2e2410; }
.shop-table .good { color: #2e7d44; font-weight: bold; }
.shop-table .bad { color: #a43e2c; }
.shop-table .dim { color: #7a6a4a; }

.tag-cheap, .tag-want {
  font-size: 10px; padding: 1px 6px; border-radius: 8px; vertical-align: middle;
}
.tag-cheap { background: #2e7d4422; color: #2e7d44; border: 1px solid #2e7d4455; }
.tag-want { background: #a43e2c22; color: #a43e2c; border: 1px solid #a43e2c55; }

.ship-card, .quest-card {
  background: #00000010; border: 1px solid #8a6a1e33; border-radius: 8px;
  padding: 9px 12px; margin-bottom: 9px;
}
.ship-card h4 { color: #5e3d10; }
.ship-card .btn, .quest-card .btn { width: auto; display: inline-block; }
.active-quest { border-left: 4px solid var(--gold-dark); }

.rumor-box { margin-top: 10px; font-style: italic; color: #4a3a20; }
.rumor-box p { padding: 8px 10px; background: #00000010; border-radius: 6px; }

#port-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 22px; border-top: 2px solid #8a6a1e55;
}
#port-hint { font-size: 13px; font-style: italic; color: #7a6a4a; max-width: 70%; }
#port-footer .btn-gold { font-size: 17px; padding: 10px 26px; }

/* scrollbars */
::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a527888; border-radius: 5px; }

/* small screens */
@media (max-width: 760px) {
  .panel-cols { flex-direction: column; }
  #minimap { width: 150px; }
  .title-box h1 { font-size: 38px; letter-spacing: 6px; }
}

/* phones — keep everything within a narrow viewport */
@media (max-width: 540px) {
  /* HUD: compact chips so they fit in a couple of rows instead of overflowing */
  #hud { gap: 3px 4px; padding: 4px 6px; font-size: 11.5px; }
  #hud { padding-top: max(4px, env(safe-area-inset-top)); }
  .hud-group { padding: 2px 6px; border-radius: 4px; }
  #hud-wind { margin-left: 0; }          /* flow inline instead of jumping to its own row */
  #wind-arrow { font-size: 13px; margin-right: 3px; }

  /* in-canvas overlays smaller so they don't cover the view */
  #minimap { width: 116px; top: 8px; right: 8px; }
  #ship-banner { font-size: 12px; padding: 4px 9px; top: 8px; left: 8px; }
  #sail-controls button { width: 44px; height: 44px; font-size: 18px; }

  /* title screen: shrink so the wide heading + padding fit */
  .title-box { padding: 30px 20px; border-radius: 10px; }
  .title-box h1 { font-size: 30px; letter-spacing: 4px; }
  .subtitle { font-size: 16px; margin: 5px 0 16px; }
  .title-flavor { font-size: 14px; margin-bottom: 18px; }

  /* modal / port overlays use the full width */
  #modal-box { padding: 20px 18px 14px; }
  #modal-box h2 { font-size: 20px; }
  #port-box { width: 96vw; height: min(640px, 92dvh); }
  #port-header { flex-direction: column; gap: 6px; padding: 12px 14px 8px; }
  #port-header h2 { font-size: 21px; }
  #port-quickstats { padding-top: 0; white-space: normal; }

  /* tabs wrap rather than overflow off-screen */
  #port-tabs { flex-wrap: wrap; padding: 0 12px; gap: 2px 1px; }
  .tab-btn { padding: 7px 12px; font-size: 14px; }
  #port-body { padding: 12px 14px; }
  #port-footer { padding: 10px 14px; }
  #port-hint { max-width: 55%; font-size: 12px; }
  #port-footer .btn-gold { font-size: 15px; padding: 9px 16px; }

  /* combat panels stack vertically */
  .combat-grid { flex-direction: column; gap: 8px; }
  .combat-vs { justify-content: center; }

  .shop-table { font-size: 13px; }
  .shop-table td { padding: 4px; }
}
