:root {
  --ink: #10262c;
  --ink-deep: #091a20;
  --panel: #10272d;
  --panel-soft: #173139;
  --paper: #e9e2d3;
  --muted: #9daeb0;
  --gold: #d3b47a;
  --gold-light: #f0d69e;
  --line: rgba(222, 214, 192, .14);
  --port: #d68b72;
  --starboard: #a4bea0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--paper);
  background: var(--ink-deep);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; min-height: 100%; }
body { overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 3px; }
button { -webkit-tap-highlight-color: transparent; }

.app { width: 100vw; height: 100vh; height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) 356px; }
.viewport { position: relative; min-width: 0; overflow: hidden; background: linear-gradient(#b8ccca, #d7d7c6 55%, #638a89); isolation: isolate; }
.scene { position: absolute; inset: 0; }
.scene canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.scene canvas:active { cursor: grabbing; }
.scene-shade { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(7,25,30,.18), transparent 20%, transparent 69%, rgba(6,21,25,.34)), radial-gradient(ellipse at center, transparent 50%, rgba(6,25,29,.14)); z-index: 1; }

.topbar { position: absolute; z-index: 12; left: 0; right: 0; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 20px 23px; pointer-events: none; }
.identity { text-shadow: 0 1px 12px rgba(5,24,28,.35); }
.eyebrow { display: block; color: var(--gold-light); font-size: 10px; font-weight: 750; letter-spacing: .18em; }
.identity .eyebrow { color: #17343a; }
.identity h1 { margin: 3px 0 0; color: #102a31; font: 500 25px/1.1 Georgia, serif; letter-spacing: -.02em; }
.view-tools { display: flex; gap: 8px; align-items: center; pointer-events: auto; }
.deck-switch { display: flex; padding: 3px; border: 1px solid rgba(234,228,211,.2); border-radius: 5px; background: rgba(10,34,40,.87); box-shadow: 0 6px 22px rgba(7,24,27,.12); backdrop-filter: blur(10px); }
.deck-switch button, .icon-button { border: 0; border-radius: 3px; background: transparent; color: #b6c4c2; padding: 8px 10px; font-size: 10px; font-weight: 650; cursor: pointer; white-space: nowrap; }
.deck-switch button:hover, .deck-switch button.active { background: #365059; color: #fff6e6; }
.deck-switch button.active { box-shadow: inset 0 0 0 1px rgba(222,198,149,.2); }
.icon-button { border: 1px solid rgba(234,228,211,.2); background: rgba(10,34,40,.87); padding: 10px 12px; }
.icon-button:hover { color: white; background: #29454e; }

.order-card { position: absolute; z-index: 8; left: 23px; top: 96px; width: 255px; padding: 18px 19px 15px; border: 1px solid rgba(222,209,177,.25); border-radius: 5px; background: linear-gradient(135deg, rgba(11,38,44,.94), rgba(13,42,47,.83)); box-shadow: 0 14px 40px rgba(7,25,29,.18); backdrop-filter: blur(12px); }
.order-kicker { color: #b9c6c3; font-size: 9px; font-weight: 700; letter-spacing: .16em; display: flex; align-items: center; gap: 7px; }
.signal-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 3px rgba(211,180,122,.12); }
.order-text { font: 400 31px/1.08 Georgia, serif; color: #fff3dc; margin: 12px 0 5px; letter-spacing: -.025em; }
.order-card p { margin: 0; min-height: 28px; color: #aabbb9; font-size: 11px; line-height: 1.45; }
.angle-row { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); margin-top: 13px; padding-top: 12px; }
.angle-row div { display: flex; flex-direction: column; gap: 3px; }
.angle-row div + div { border-left: 1px solid var(--line); padding-left: 16px; }
.angle-row span { font-size: 8px; letter-spacing: .16em; color: #8fa4a4; }
.angle-row strong { font: 400 18px/1.2 Georgia, serif; color: #e8dcc4; }
.rudder-scale { display: flex; align-items: center; gap: 8px; margin-top: 13px; color: #829b9b; font-size: 7px; font-weight: 700; letter-spacing: .12em; }
.scale-track { position: relative; height: 2px; background: linear-gradient(90deg, var(--port), #71888a 50%, var(--starboard)); flex: 1; }
.scale-mid { position: absolute; left: 50%; top: -3px; width: 1px; height: 8px; background: #d9dfd7; opacity: .5; }
.scale-track b { position: absolute; width: 7px; height: 7px; border: 1px solid #fff0d3; background: #17373e; border-radius: 50%; left: 50%; top: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 0 3px rgba(255,240,211,.09); }

.compass-card { position: absolute; z-index: 7; right: 23px; top: 86px; display: flex; align-items: center; gap: 10px; color: #15353b; }
.compass { width: 59px; height: 59px; border: 1px solid rgba(17,49,55,.35); border-radius: 50%; position: relative; background: rgba(225,229,213,.26); box-shadow: inset 0 0 0 4px rgba(222,227,212,.13); }
.compass > span { position: absolute; font-size: 7px; font-weight: 800; }
.compass .north { top: 3px; left: 50%; transform: translateX(-50%); }
.compass .south { bottom: 3px; left: 50%; transform: translateX(-50%); }
.compass .east { right: 4px; top: 50%; transform: translateY(-50%); }
.compass .west { left: 4px; top: 50%; transform: translateY(-50%); }
.compass > i { position: absolute; inset: 12px; border: 1px dotted rgba(19,51,57,.25); border-radius: 50%; }
.compass-ship { position: absolute; z-index: 2; inset: 0; display: grid; place-items: center; color: #153d44; font-size: 22px; line-height: 1; transform: rotate(0deg); transition: transform .08s linear; text-shadow: 0 1px 4px rgba(240,236,208,.6); }
.compass-card > div:last-child { display: flex; flex-direction: column; }
.compass-card strong { font: 400 23px/1 Georgia, serif; }
.compass-card > div > span { margin-top: 5px; font-size: 8px; font-weight: 750; letter-spacing: .1em; }

.part-labels { position: absolute; inset: 0; z-index: 6; pointer-events: none; overflow: hidden; }
.part-label { position: absolute; display: flex; align-items: center; gap: 7px; border: 0; padding: 4px 8px 4px 4px; border-radius: 20px; background: rgba(10,34,39,.82); box-shadow: 0 2px 12px rgba(4,18,20,.18); color: #eee5d1; pointer-events: auto; cursor: pointer; white-space: nowrap; transform: translate(-10px, -50%); backdrop-filter: blur(6px); transition: background .15s, opacity .15s; }
.part-label::before { content: ""; position: absolute; right: 100%; top: 50%; width: 16px; height: 1px; background: rgba(239,225,193,.6); }
.part-label span { display: grid; place-items: center; width: 23px; height: 23px; border-radius: 50%; background: #d0b17a; color: #10292f; font-size: 8px; font-weight: 800; }
.part-label b { font-size: 9px; font-weight: 650; letter-spacing: .015em; }
.part-label:hover, .part-label.active { background: #294b51; }
.part-label.active span { background: #ffe0a6; }
.part-label.hidden { opacity: 0; pointer-events: none; }

.interaction-hint { position: absolute; z-index: 7; left: 23px; bottom: 22px; display: flex; flex-direction: column; gap: 6px; color: rgba(239,238,219,.83); font-size: 9px; text-shadow: 0 1px 6px #17353b; pointer-events: none; }
.interaction-hint span:first-child { color: #fff3da; font-weight: 650; }
.mouse-icon { display: inline-block; vertical-align: -3px; width: 11px; height: 15px; border: 1px solid currentColor; border-radius: 6px; margin-right: 5px; position: relative; }
.mouse-icon::after { content: ""; position: absolute; width: 1px; height: 4px; background: currentColor; left: 4px; top: 2px; }

.helm-console { position: absolute; z-index: 10; width: min(480px, calc(100% - 46px)); bottom: 20px; left: 50%; transform: translateX(-50%); border: 1px solid rgba(226,210,175,.24); border-radius: 6px; background: rgba(9,32,38,.94); padding: 12px 15px 10px; box-shadow: 0 14px 40px rgba(4,20,24,.25); backdrop-filter: blur(12px); }
.console-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; }
.console-heading > span { font-size: 8px; font-weight: 750; letter-spacing: .16em; color: #9fb1b0; }
.console-heading output { font: 400 17px/1 Georgia, serif; color: var(--gold-light); font-variant-numeric: tabular-nums; }
.helm-control-row { display: flex; align-items: center; gap: 12px; }
.helm-step { flex: 0 0 33px; height: 33px; border: 1px solid #53666a; border-radius: 50%; background: #173940; color: #f5e7c9; font: 300 22px/1 Georgia, serif; cursor: pointer; }
.helm-step:hover { background: #31535a; border-color: var(--gold); }
.helm-step:active { transform: scale(.96); }
.slider-wrap { flex: 1; min-width: 0; }
input[type="range"] { width: 100%; height: 16px; margin: 0; appearance: none; -webkit-appearance: none; background: transparent; cursor: ew-resize; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: linear-gradient(90deg, #aa7766, #62787a 50%, #91aa8e); }
input[type="range"]::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%; background: #e1c58e; border: 3px solid #1c3a40; margin-top: -6px; box-shadow: 0 0 0 1px #e1c58e; }
input[type="range"]::-moz-range-track { height: 3px; background: #718789; }
input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border-radius: 50%; background: #e1c58e; border: 2px solid #1c3a40; }
.slider-labels { display: flex; align-items: center; justify-content: space-between; margin-top: 3px; color: #718d8e; font-size: 7px; font-weight: 750; letter-spacing: .08em; }
.slider-labels button { border: 0; background: none; color: #d7c9ab; padding: 2px 5px; font-size: 7px; letter-spacing: .1em; cursor: pointer; }
.slider-labels button:hover { color: white; }
.key-hint { text-align: center; margin-top: 8px; padding-top: 7px; border-top: 1px solid var(--line); color: #789293; font-size: 8px; }
.key-hint i { font-style: normal; margin: 0 5px; opacity: .5; }
kbd { display: inline-block; min-width: 15px; padding: 1px 3px; margin: 0 1px; border: 1px solid #4c6467; border-radius: 2px; color: #b9c6c2; font: inherit; }

.load-message { position: absolute; z-index: 30; inset: 0; display: grid; place-items: center; background: #b9cbc5; color: #18383d; font: 20px Georgia, serif; transition: opacity .35s; }
.load-message.loaded { opacity: 0; pointer-events: none; }
.load-message.error { padding: 40px; text-align: center; font: 15px/1.6 ui-sans-serif, system-ui; color: #f6e8d0; background: #173139; }

.guide { position: relative; z-index: 20; background: var(--panel); border-left: 1px solid rgba(226,211,179,.13); overflow-y: auto; scrollbar-width: thin; scrollbar-color: #3d5558 transparent; }
.guide-inner { padding: 28px 27px 24px; }
.guide-header h2 { margin: 10px 0 9px; color: #f0e5d0; font: 400 39px/.96 Georgia, serif; letter-spacing: -.035em; }
.guide-header p { margin: 0; max-width: 265px; color: #9dafae; font: 12px/1.55 Georgia, serif; }
.rule-note { margin: 23px 0 20px; padding: 13px 14px; border-left: 2px solid var(--gold); background: rgba(217,188,132,.065); }
.rule-note > span { color: var(--gold); font-size: 8px; font-weight: 800; letter-spacing: .15em; }
.rule-note p { color: #b9c3bb; margin: 6px 0 0; font-size: 10px; line-height: 1.55; }
.rule-note strong { color: #eee1c7; font-weight: 650; }
.chain-list { border-top: 1px solid var(--line); }
.chain-item { width: 100%; display: grid; grid-template-columns: 29px 1fr; gap: 9px; text-align: left; padding: 13px 4px; border: 0; border-bottom: 1px solid var(--line); background: transparent; cursor: pointer; transition: background .15s; }
.chain-item:hover, .chain-item.active { background: rgba(215,190,139,.055); }
.chain-item.active { box-shadow: inset 2px 0 var(--gold); }
.chain-number { color: #6f898a; font: 10px/1.4 Georgia, serif; padding-top: 1px; }
.chain-item strong { display: block; color: #e4dcc9; font: 400 15px/1.25 Georgia, serif; }
.chain-item small { display: block; color: #8fa4a3; font-size: 9px; line-height: 1.48; margin-top: 5px; }
.chain-item.active small, .chain-item:hover small { color: #b6c2bb; }
.rope-monitor { margin-top: 20px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 4px; background: #0d2228; }
.monitor-title { display: flex; align-items: center; justify-content: space-between; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
.monitor-title > span { color: #9db0ac; font-size: 8px; font-weight: 750; letter-spacing: .13em; }
.monitor-title small { color: #647f80; font-size: 8px; }
.rope-value { display: flex; justify-content: space-between; align-items: center; margin-top: 9px; }
.rope-value > span { color: #9db0ac; font-size: 8px; font-weight: 700; letter-spacing: .1em; }
.rope-value i { display: inline-block; width: 14px; height: 2px; vertical-align: 3px; margin-right: 6px; }
.rope-value.port i { background: var(--port); }
.rope-value.starboard i { background: var(--starboard); }
.rope-value strong { color: #ddd5c2; font: 13px Georgia, serif; font-variant-numeric: tabular-nums; }
.ship-specs { display: grid; grid-template-columns: 1fr 1fr 1.25fr; gap: 8px; margin-top: 20px; }
.ship-specs div { min-width: 0; }
.ship-specs span { display: block; min-height: 20px; color: #688385; font-size: 6px; font-weight: 750; line-height: 1.4; letter-spacing: .09em; }
.ship-specs strong { display: block; color: #c9c6b7; font: 13px Georgia, serif; margin-top: 4px; }
.simulation-note { margin: 17px 0 12px; color: #698486; font-size: 8px; line-height: 1.55; }
.reset-simulation { width: 100%; border: 1px solid #385258; border-radius: 3px; padding: 9px; background: transparent; color: #92a9a7; font-size: 8px; text-transform: uppercase; letter-spacing: .09em; cursor: pointer; }
.reset-simulation:hover { background: #1a363d; color: #d9dece; }

@media (max-height: 790px) and (min-width: 801px) {
  .guide-inner { padding-top: 22px; }
  .guide-header h2 { font-size: 33px; }
  .rule-note { margin: 17px 0 14px; }
  .chain-item { padding-top: 10px; padding-bottom: 10px; }
  .chain-item small { font-size: 8px; }
  .rope-monitor { margin-top: 15px; }
  .ship-specs { margin-top: 15px; }
  .interaction-hint { bottom: 126px; }
}

@media (max-width: 1120px) {
  .app { grid-template-columns: minmax(0, 1fr) 322px; }
  .guide-inner { padding-left: 22px; padding-right: 22px; }
  .view-tools { gap: 5px; }
  .deck-switch button { padding-left: 7px; padding-right: 7px; }
  .icon-button { display: none; }
  .order-card { width: 228px; }
  .order-text { font-size: 27px; }
  .interaction-hint { display: none; }
}

@media (max-width: 800px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; display: block; }
  .viewport { height: 76vh; height: 76dvh; min-height: 570px; }
  .guide { overflow: visible; border-left: 0; border-top: 1px solid var(--line); }
  .guide-inner { max-width: 620px; margin: auto; padding: 28px; }
  .guide-header h2 br { display: none; }
  .chain-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
  .topbar { padding: 16px; }
  .identity h1 { font-size: 22px; }
  .identity .eyebrow { font-size: 8px; }
  .order-card { left: 16px; top: 80px; transform: scale(.9); transform-origin: left top; }
  .compass-card { right: 16px; top: 78px; }
  .helm-console { bottom: 15px; }
  .part-label b { display: none; }
  .part-label { padding-right: 4px; }
  .part-label::before { display: none; }
}

@media (max-width: 520px) {
  .viewport { min-height: 600px; }
  .topbar { display: block; padding: 14px; }
  .identity h1 { font-size: 18px; }
  .view-tools { position: absolute; left: 14px; top: 49px; }
  .deck-switch button { font-size: 8px; padding: 7px 8px; }
  .order-card { top: 96px; transform: scale(.84); }
  .compass-card { top: 98px; transform: scale(.85); transform-origin: right top; }
  .helm-console { width: calc(100% - 28px); padding-left: 11px; padding-right: 11px; }
  .helm-control-row { gap: 8px; }
  .slider-labels { font-size: 6px; }
  .chain-list { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
