@font-face {
  font-family: 'Shippori';
  src: url('./ui/type/shippori-mincho.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
:root {
  --navy: #152d38;
  --ink: #232d2e;
  --paper: #e9dfc6;
  --brass: #ad8650;
  --gold: #e1c395;
  --wine: #743932;
  --serif: 'Shippori', 'Hiragino Mincho ProN', 'Yu Mincho', 'Noto Serif JP', serif;
  --roman: 'Iowan Old Style', Baskerville, 'Palatino Linotype', Georgia, serif;
  --sans: 'Hiragino Kaku Gothic ProN', 'Yu Gothic', Meiryo, system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(125deg,#203c46b3,#11293344 64%,#0c202be6), url('./ui/portolan.svg') center top / 1200px 720px repeat, #112b36;
  color: var(--paper);
  font: 400 16px/1.55 var(--sans);
}
main { width: min(1488px,100%); margin: 0 auto; padding: 0 clamp(18px,3.7vw,58px) 40px; }
.colophon { display: flex; align-items: baseline; justify-content: flex-end; flex-wrap: wrap; gap: 6px 18px; margin-top: 18px; border-top: 1px solid #a78c5e65; padding-top: 8px; color: #d9c6a0; font: 500 13px/1.5 var(--serif); }
.colophon b { margin-left: .35em; font: italic 600 17px var(--roman); }
.colophon a { display: inline-flex; align-items: center; min-height: 36px; color: #ecdac0; text-underline-offset: .22em; }
.voyage-expanded .colophon { display: none; }
button, select, input { font: inherit; }
button, select, summary { cursor: pointer; }
button { color: inherit; }
button:disabled { cursor: wait; opacity: .58; }
:where(button,select,a,input,summary):focus-visible { outline: 3px solid #e2a448; outline-offset: 3px; }
button { -webkit-tap-highlight-color: transparent; }
.mast { position: relative; display: flex; align-items: center; min-height: 146px; isolation: isolate; gap: 18px; }
.mast::before {
  content: ''; flex: 0 0 clamp(62px,6.2vw,95px); aspect-ratio: 1;
  background: url('./ui/compass-rose.svg') center / contain no-repeat;
}
.mast::after { content: ''; position: absolute; inset: auto 0 0; height: 4px; border-block: 1px solid #b29b6b85; }
.mast-copy { position: relative; z-index: 1; padding-bottom: 4px; }
.imprint { margin: 0; font: 600 12px/1.25 var(--roman); text-transform: uppercase; letter-spacing: .23em; color: var(--gold); }
.mast h1 { margin: 4px 0; font: 600 clamp(34px,3.15vw,54px)/1.16 var(--serif); letter-spacing: .075em; color: #f5ead1; }
.place { display: flex; align-items: center; gap: 9px; margin: 0; font: italic 16px/1.25 var(--roman); color: #dcc29b; letter-spacing: .055em; }
.place::before { content: ''; width: 30px; height: 1px; background: #ad946a; }
.mast-plate { position: absolute; z-index: -1; right: clamp(128px,14%,215px); inset-block: 0 3px; width: 29%; overflow: hidden; }
.mast-plate img { width: 100%; height: 100%; object-fit: contain; opacity: .9; }
.guide-button, .full-button, .orbit-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 5px 14px; font: 600 14px/1.25 var(--serif);
  border: 1px solid #a18c67; background: #152c35; color: #f1e2c4; border-radius: 1px;
  transition: background-color 140ms, color 140ms;
}
.guide-button { margin-left: auto; box-shadow: inset 0 0 0 3px #152c35,inset 0 0 0 4px #aa906b5c; }
.guide-button svg,.full-button svg { width: 18px; height: 18px; }
.guide-button:hover,.full-button:hover,.orbit-button:hover { background: #32484d; color: white; }
.route-index { display: flex; align-items: stretch; border-bottom: 1px solid #b29b6b70; }
.index-caption,.view-label { display: inline-flex; align-items: center; white-space: nowrap; margin-right: 18px; font: 600 13px/1.3 var(--serif); letter-spacing: .1em; color: var(--gold); }
#stages { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)) minmax(92px,.92fr); flex: 1; min-width: 0; }
#stages button {
  position: relative; display: flex; justify-content: center; align-items: center; gap: 8px; padding: 6px 4px;
  min-height: 53px; min-width: 0; border: 0; border-inline-start: 1px solid #b29b6b47;
  background: transparent; font: 600 clamp(13px,1vw,15px)/1.25 var(--serif); color: #f2e4c9;
}
#stages button:last-child { border-inline-end: 1px solid #b29b6b47; }
#stages b { font: 600 16px/1 var(--roman); color: #dbbc86; }
#stages button:hover { background: #b7a07519; }
#stages button[aria-pressed=true] { background: #e7d9b8; color: #392e26; box-shadow: inset 0 -4px var(--wine); }
#stages button[aria-pressed=true] b { color: var(--wine); }
#stages button[data-clear=true]::after { content: '✓'; font: 600 12px var(--sans); }
.explore-settings { display: flex; align-items: center; gap: 14px; padding: 8px 0; border-bottom: 1px solid #b29b6b70; font: 600 14px var(--serif); }
.explore-settings select { min-height: 44px; max-width: 100%; padding: 4px 10px; color: var(--ink); color-scheme: light; background: var(--paper); border: 1px solid var(--brass); }
.layout { display: grid; grid-template-columns: minmax(0,2.45fr) minmax(285px,.95fr); align-items: start; gap: clamp(14px,1.65vw,26px); margin-top: 22px; }
.scene-board { min-width: 0; border: 1px solid #aa9165; box-shadow: 0 5px 18px #08161e80; background: #13272e; }
.chart-caption { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 14px; border-bottom: 1px solid #a18b65; background: #1d343b; }
.chart-name { display: flex; align-items: center; gap: 12px; min-width: 0; }
#seaStage { color: #debd87; font: 600 14px/1.4 var(--serif); white-space: nowrap; border-right: 1px solid #a18762; padding-right: 12px; }
.chart-name h2 { color: #f0e4c9; font: 600 clamp(17px,1.45vw,23px)/1.32 var(--serif); margin: 0; letter-spacing: .045em; }
.clock { display: flex; align-items: baseline; gap: 7px; margin-left: auto; color: #d3c1a4; font: 500 12px var(--sans); white-space: nowrap; }
.clock time { color: #f0e4cb; font: 500 18px var(--roman); font-variant-numeric: tabular-nums; }
.full-button { padding-inline: 8px; min-width: 44px; border: 0; background: transparent; }
.view-frame { position: relative; isolation: isolate; }
.scene { width: 100%; height: clamp(345px, min(43vw,54svh),690px); overflow: hidden; background: #17373c; }
.scene canvas { display: block; width: 100%; height: 100%; }
.scene[data-view=follow] { touch-action: pan-y pinch-zoom; cursor: grab; user-select: none; }
.scene[data-view=follow]:active { cursor: grabbing; }
#minimap { pointer-events: none; position: absolute; top: 12px; right: 12px; width: clamp(90px,13%,145px); height: auto; border: 1px solid #c2a477; box-shadow: 0 0 0 2px #253535,0 2px 8px #0716208c; }
.orbit-controls { display: flex; gap: 4px; position: absolute; bottom: 8px; right: 8px; pointer-events: none; }
.orbit-button { pointer-events: auto; padding: 3px 8px; font-size: 12px; background: #13282dd4; }
.view-controls { display: flex; align-items: center; padding: 3px 12px; border-top: 1px solid #8c785b; }
.view-label { margin-right: 12px; }
.camera-controls { display: flex; flex-wrap: wrap; }
.camera-controls button { position: relative; min-height: 44px; padding: 3px 13px; border: 0; background: transparent; color: #d7cfba; font: 600 14px var(--serif); }
.camera-controls button:hover { background: #b9a07118; }
.camera-controls button[aria-pressed=true] { color: #ffe3ad; }
.camera-controls button[aria-pressed=true]::after { content: ''; height: 2px; position: absolute; bottom: 3px; inset-inline: 14px; background: #c3a174; }
.voyage-record { border-top: 1px solid #99825d; background: linear-gradient(100deg,#ecdfbe,#e5d6b6); color: var(--ink); }
.ticket,.log { display: flex; align-items: center; gap: 18px; padding: 14px clamp(12px,1.5vw,24px); }
.ticket::before { content: ''; flex: 0 0 44px; aspect-ratio: 1; background: url('./ui/compass-rose.svg') center / contain; filter: sepia(.65) brightness(.50); }
.entry-copy { min-width: 0; }
.entry-copy small,.log-title { color: var(--wine); font: 600 12px/1.35 var(--serif); letter-spacing: .09em; }
.entry-copy h3 { margin: 2px 0 3px; font: 600 clamp(17px,1.4vw,22px)/1.4 var(--serif); }
.entry-copy p,.log p { margin: 0; font: 500 13px/1.6 var(--sans); color: #464035; }
.primary { position: relative; min-height: 44px; padding: 8px 18px; border: 1px solid #522b23; outline-offset: 3px; box-shadow: inset 0 0 0 3px #793e35,inset 0 0 0 4px #be9574; background: var(--wine); color: #fff3d7; font: 600 16px/1.4 var(--serif); white-space: nowrap; }
.primary::after { content: ''; display: inline-block; margin: 0 0 2px 12px; width: 6px; height: 6px; border: solid currentColor; border-width: 1px 1px 0 0; transform: rotate(45deg); }
.primary:hover { background: #8d493e; }
.primary:active,.guide-button:active { box-shadow: inset 0 2px 6px #2518108c; }
.ticket .primary { margin-left: auto; }
#overlay:not([hidden]) + .log { display: none; }
.log { min-height: 62px; }
.log-title { flex-shrink: 0; border-right: 1px solid #a28b67; padding-right: 14px; }
dialog { color-scheme: light; width: min(530px,calc(100% - 28px)); max-height: calc(100dvh - 32px); padding: clamp(20px,4vw,36px); color: var(--ink); border: 1px solid #6f624c; background: var(--paper); box-shadow: inset 0 0 0 5px var(--paper),inset 0 0 0 6px #b2a17f,0 16px 70px #102026; }
dialog::backdrop { background: #0a1e28bb; }
#termsDialog { width: min(700px, calc(100% - 24px)); padding: 8px; }
#termsDialog iframe { display: block; width: 100%; height: min(64dvh, 620px); border: 0; }
#termsDialog form { display: flex; justify-content: flex-end; padding: 8px; }
dialog .imprint { color: var(--wine); }
dialog h2 { font: 600 30px/1.4 var(--serif); margin: 5px 0 14px; border-bottom: 3px double #a69473; }
dialog dl { margin: 0 0 20px; }
dialog dt { margin: 12px 0 3px; font: 600 17px/1.4 var(--serif); color: var(--wine); }
dialog dd { margin: 0; font: 400 14px/1.7 var(--sans); }
@media (max-width: 1120px) {
  .index-caption { margin-right: 10px; }
  #stages button { gap: 5px; }
  .mast { min-height: 126px; }
}
@media (max-width: 940px) {
  main { padding-inline: 14px; }
  .index-caption { display: none; }
  #stages button { flex-direction: column; gap: 3px; }
  .layout { grid-template-columns: minmax(0,1.8fr) minmax(265px,1fr); gap: 12px; }
  .ticket { gap: 12px; }
  .ticket::before { display: none; }
}
@media (max-width: 760px) {
  main { padding: 0 max(10px,env(safe-area-inset-right)) max(20px,env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left)); }
  .mast { min-height: 92px; gap: 7px; }
  .mast::before { flex-basis: 45px; }
  .mast h1 { font-size: clamp(24px,5.1vw,34px); letter-spacing: .035em; margin: 3px 0; }
  .mast .imprint { font-size: 9px; }
  .place { font-size: 13px; }
  .place::before { width: 16px; }
  .mast-plate { right: 85px; width: 23%; }
  .guide-button { gap: 5px; padding: 5px 9px; font-size: 12px; }
  #stages { grid-template-columns: repeat(5,minmax(0,1fr)) minmax(66px,1.15fr); }
  #stages button { height: 46px; min-height: 44px; }
  #stages button:not(.explore-tab) span { display: none; }
  #stages .explore-tab { flex-direction: row; }
  #stages button[data-clear=true]::after { position: absolute; top: 4px; right: 4px; }
  .explore-settings { gap: 5px; flex-wrap: wrap; }
  .explore-settings select { flex: 1; }
  .layout { grid-template-columns: minmax(0,1fr); margin-top: 10px; }
  .chart-caption { min-height: 43px; gap: 5px; padding: 0 8px; }
  .chart-name { gap: 7px; }
  #seaStage { font-size: 12px; padding-right: 7px; }
  .clock { gap: 3px; }
  .full-button { padding: 4px; gap: 3px; }
  .full-button span { font-size: 12px; }
  .scene { height: clamp(210px,35svh,345px); }
  #minimap { width: clamp(60px,18%,94px); right: 7px; top: 7px; }
  .view-controls { padding: 0 6px; }
  .view-label { margin-right: 4px; font-size: 12px; }
  .camera-controls { flex: 1; flex-wrap: nowrap; }
  .camera-controls button { flex: 1; font-size: 13px; padding-inline: 3px; }
  .camera-controls button[aria-pressed=true]::after { inset-inline: 5px; }
  .ticket,.log { padding: 9px 10px; gap: 8px; }
  .ticket .primary { padding: 6px 11px; font-size: 14px; }
  .entry-copy h3 { font-size: 16px; margin-block: 1px; }
  .ticket small { font-size: 11px; }
  .entry-copy p,.log p { font-size: 12px; }
  .log { min-height: 46px; }
}
@media (max-width: 520px) {
  .mast { min-height: 87px; }
  .mast-plate { width: 19%; right: 48px; }
  .guide-button { width: 44px; flex: 0 0 44px; gap: 0; overflow: hidden; font-size: 0; }
  .guide-button svg { width: 20px; height: 20px; flex-shrink: 0; }
}
@media (max-width: 360px) {
  .mast::before { flex-basis: 32px; }
  .mast-plate { width: 17%; right: 43px; }
  #stages .explore-tab b,.clock > span { display: none; }
  #stages .explore-tab { font-size: 12px; }
  .chart-name h2 { font-size: 16px; }
  .entry-copy p { line-height: 1.45; }
  .primary::after { margin-left: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { scroll-behavior: auto !important; transition-duration: 0s !important; animation-duration: 0s !important; }
}
@media (min-width: 761px) and (max-height: 820px) {
  .mast { min-height: 108px; }
  .layout { margin-top: 14px; }
  .scene { height: clamp(280px,min(43vw,54svh,calc(100svh - 340px)),520px); }
}
@media (max-width: 520px) {
  #stages .explore-tab b { display: none; }
  #stages .explore-tab span { white-space: nowrap; }
}

#keySettings p { margin: 8px 0 14px; font: 14px/1.5 var(--sans); }
#keySettings table { width: 100%; border-collapse: collapse; }
#keySettings :is(td, th) { padding: 5px 3px; text-align: left; border-bottom: 1px solid #b9aa8c; }
#keySettings thead th { color: var(--wine); font: 600 14px/1.5 var(--serif); }
#keySettings tbody th { font: 500 14px/1.4 var(--sans); }
#keySettings select { width: 100%; min-width: 48px; min-height: 42px; color: var(--ink); background: #faf2df; border: 1px solid #988468; border-radius: 2px; font: 600 16px/1.3 var(--sans); }
#keySettings select[aria-invalid=true] { outline: 2px solid var(--wine); }
#keySettings [role=status] { color: var(--wine); }
#keySettings [role=status]:empty { margin: 0; }
#keySettings button:not(.primary), .binding-link { min-height: 44px; padding: 5px 10px; background: transparent; border: 0; color: var(--wine); font: 600 14px/1.4 var(--serif); text-decoration: underline; cursor: pointer; }
#keySettings .binding-actions { display: flex; justify-content: flex-end; gap: 8px; }
#keySettings .primary:disabled { opacity: .55; }
