/* Sailing - styles.  No external font, no external image, no CDN: everything ships in the bundle. */
:root {
  --sea: #0a1d2b;
  --panel: rgba(8, 22, 33, 0.86);
  --edge: rgba(150, 195, 220, 0.26);
  --ink: #e8f1f6;
  --dim: #9fb9c8;
  --hi: #66d0f0;
  --warm: #f2b23a;
  --good: #7ee08a;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--sea); color: var(--ink);
  font-family: var(--font); overflow: hidden; }
#stage { position: fixed; inset: 0; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#plan { position: absolute; right: 12px; bottom: 12px; width: 260px; height: 300px;
  border: 1px solid var(--edge); border-radius: 8px; background: #0a1d2b;
  box-shadow: 0 6px 24px rgba(0,0,0,0.45); }
#plan[hidden] { display: none !important; }

#hud { position: absolute; left: 12px; top: 12px; background: var(--panel); border: 1px solid var(--edge);
  border-radius: 10px; padding: 10px 14px 12px; min-width: 246px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#hud h1 { margin: 0 0 8px; font-size: 17px; letter-spacing: 0.04em; font-weight: 650; }
#hud .grid { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 12px; }
#hud .lbl { color: var(--dim); }
#hud .val { font-family: var(--mono); text-align: right; }
#hud .val.big { font-size: 16px; color: var(--hi); font-weight: 650; }

#msg-bar { position: absolute; left: 50%; transform: translateX(-50%); top: 14px;
  max-width: min(620px, 62vw); text-align: center; pointer-events: none; }
#hud-msg { display: inline-block; background: var(--panel); border: 1px solid var(--edge);
  border-radius: 999px; padding: 5px 14px; font-size: 12.5px; color: var(--ink); }
#hud-msg:empty { display: none; }

#controls { position: absolute; left: 12px; bottom: 12px; width: 300px; background: var(--panel);
  border: 1px solid var(--edge); border-radius: 10px; padding: 10px 12px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#controls .row { display: block; margin: 6px 0; font-size: 12px; }
#controls .row label { display: block; color: var(--dim); margin-bottom: 3px; }
#controls .row label b { color: var(--ink); font-family: var(--mono); }
#controls .row label em { color: var(--warm); font-style: normal; float: right; }
#controls .row.btns { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
input[type=range] { width: 100%; accent-color: var(--hi); }
button, select, input[type=number] { font-family: var(--font); font-size: 12px; color: var(--ink);
  background: rgba(255,255,255,0.07); border: 1px solid var(--edge); border-radius: 7px;
  padding: 5px 9px; cursor: pointer; }
button:hover, select:hover { background: rgba(255,255,255,0.14); }
button.primary { background: rgba(102, 208, 240, 0.20); border-color: rgba(102,208,240,0.55); }
button.on { background: rgba(126, 224, 138, 0.22); border-color: rgba(126,224,138,0.6); }
kbd { font-family: var(--mono); font-size: 10px; background: rgba(255,255,255,0.10);
  border: 1px solid var(--edge); border-radius: 4px; padding: 0 4px; margin: 0 1px; }

#setup { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(560px, 92vw); max-height: 88vh; overflow: auto; background: var(--panel);
  border: 1px solid var(--edge); border-radius: 14px; padding: 20px 22px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 18px 60px rgba(0,0,0,0.5); }
#setup[hidden] { display: none !important; }
#setup h2 { margin: 0 0 8px; font-size: 20px; }
#setup .intro { color: var(--dim); font-size: 13px; line-height: 1.5; margin: 0 0 14px; }
#setup .row { display: flex; gap: 10px; align-items: center; margin: 8px 0; font-size: 13px; }
#setup .row label { width: 82px; color: var(--dim); }
#setup .row select, #setup .row input { flex: 1; }
#setup .row.btns { margin-top: 16px; }
#setup .spec { font-size: 11.5px; color: var(--dim); line-height: 1.45; margin: 2px 0 12px;
  font-family: var(--mono); }
.best { color: var(--good); font-size: 12px; margin: 12px 0 0; }

/* The accuracy caveat.  It is STATIC MARKUP in index.html, not injected by a script, so it is in
   the page source and it survives a JS failure - the deviations it names are large and visible on
   screen (65 degrees of heel), and a player has no other way to tell a documented model limit from
   a bug. */
.limits { margin: 14px 0 4px; padding: 10px 12px; border: 1px solid rgba(242, 178, 58, 0.45);
  border-radius: 9px; background: rgba(242, 178, 58, 0.07); }
.limits > summary { cursor: pointer; font-size: 12.5px; color: var(--warm); font-weight: 600;
  list-style: none; }
.limits > summary::-webkit-details-marker { display: none; }
.limits > summary::before { content: "\25B8"; display: inline-block; width: 1em; color: var(--warm); }
.limits[open] > summary::before { content: "\25BE"; }
.limits h3 { margin: 0 0 8px; font-size: 13.5px; color: var(--warm); }
.limits ul { margin: 10px 0 6px; padding-left: 20px; }
.limits li { font-size: 12.5px; line-height: 1.55; color: var(--ink); margin-bottom: 6px; }
.limits p { font-size: 12.5px; line-height: 1.55; margin: 8px 0 0; }
.limits .note { color: var(--dim); font-size: 11.5px; }
#limits { margin-top: 16px; }
#help-limits { margin: 0 0 6px; }

.modal { position: absolute; inset: 0; background: rgba(4, 12, 19, 0.66);
  display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal[hidden] { display: none !important; }
/* `open` is added by the script alongside el.hidden = false.  Both are needed: [hidden] alone is
   beaten by ANY class rule that sets display, and an invisible modal that still eats every click
   is the classic symptom of getting this wrong. */
.modal.open { animation: fade 140ms ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal .panel { background: var(--panel); border: 1px solid var(--edge); border-radius: 14px;
  padding: 20px 22px; width: min(520px, 94vw); max-height: 90vh; overflow: auto;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 18px 60px rgba(0,0,0,0.55); }
.modal .panel.wide { width: min(760px, 96vw); }
.modal h2 { margin: 0 0 12px; font-size: 19px; }
.modal h2 small { color: var(--dim); font-weight: 400; font-size: 13px; margin-left: 8px; }
.modal h3 { margin: 18px 0 6px; font-size: 14px; color: var(--hi); }
.modal p, .modal li { font-size: 13px; line-height: 1.6; color: var(--ink); }
.modal ul { padding-left: 20px; }
.modal .note { color: var(--dim); font-size: 12px; }
.modal code { font-family: var(--mono); font-size: 11.5px; background: rgba(255,255,255,0.08);
  padding: 1px 4px; border-radius: 4px; }
.modal table { width: 100%; border-collapse: collapse; font-size: 13px; }
.modal th, .modal td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--edge); }
.modal th { color: var(--dim); font-weight: 500; }
.modal tr.me td { color: var(--hi); font-weight: 600; }
.modal .row.btns { display: flex; gap: 8px; margin-top: 16px; }
#polar-canvas { width: 100%; height: auto; max-width: 620px; display: block;
  border: 1px solid var(--edge); border-radius: 8px; background: #08151f; }

#nogl { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; padding: 24px; background: var(--sea); z-index: 20; }
#nogl[hidden] { display: none !important; }
#nogl h2 { font-size: 20px; margin: 0 0 8px; }
#nogl p { color: var(--dim); font-size: 13px; max-width: 42em; }

@media (max-width: 760px) {
  #hud { min-width: 0; padding: 8px 10px 10px; font-size: 11px; }
  #hud h1 { font-size: 15px; }
  #controls { width: calc(100vw - 24px); }
  #plan { width: 150px; height: 175px; right: 8px; bottom: 220px; }
  #msg-bar { top: auto; bottom: 200px; max-width: 90vw; }
}
/* Phones: keep the HUD inside the side gutters, and on short portrait screens shrink it and the
   plan so neither covers the other or the helm panel. */
@media (max-width: 760px) {
  #hud { max-width: calc(100vw - 24px); }
}
@media (max-width: 760px) and (max-height: 700px) and (orientation: portrait) {
  #hud { padding: 6px 9px 7px; }
  #hud h1 { font-size: 13px; margin-bottom: 3px; }
  #hud .grid { gap: 0 8px; font-size: 10.5px; }
  #hud .val.big { font-size: 13px; }
  #plan { width: 120px; height: 140px; bottom: 212px; }
}
/* Phones held sideways (the manifest asks for landscape): a two-column HUD that is half as tall,
   so the helm panel below it no longer covers Leg / Clock / Place. */
@media (max-height: 500px) and (orientation: landscape) {
  #hud { padding: 6px 10px 7px; min-width: 0; max-width: calc(100vw - 230px); }
  #hud h1 { display: none; }
  #hud .grid { grid-template-columns: auto auto auto auto; gap: 0 10px; font-size: 11px; }
  #hud .val.big { font-size: 13px; }
  #controls { padding: 6px 10px; width: 290px; }
  #controls .row { margin: 3px 0; }
  #plan { width: 190px; height: 220px; right: 8px; bottom: 8px; }
  #msg-bar { top: auto; bottom: 12px; left: auto; right: 210px; transform: none; max-width: 40vw; }
}
@media (max-width: 340px) and (orientation: portrait) {
  #plan { bottom: 236px; }
}
