:root { --bg: rgba(11, 23, 34, .86); --bg2: rgba(20, 36, 52, .92); --fg: #eaf2f8; --mut: #8fa6b8; --line: rgba(255,255,255,.12);
  --danger: #ff3b30; --caution: #ffb020; --safe: #34c759; --own: #00e5ff; --acc: #4fc3f7; --side: 340px; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b1722; color: var(--fg);
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
#map { position: absolute; inset: 0; }
button { font: inherit; color: inherit; background: rgba(255,255,255,.08); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; cursor: pointer; }
button.icon { width: 40px; height: 40px; padding: 0; font-size: 18px; }
button.primary { background: var(--acc); color: #002233; font-weight: 700; border: none; }
button.mini { padding: 3px 8px; font-size: 12px; }
.hidden { display: none !important; }
.card { background: var(--bg); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(8px); box-shadow: 0 6px 24px rgba(0,0,0,.35); }

/* top bar */
#topbar { position: absolute; top: 0; left: 0; right: 0; height: 56px; display: flex; align-items: center; gap: 10px; padding: 0 10px;
  background: linear-gradient(180deg, rgba(8,18,28,.95), rgba(8,18,28,.75)); border-bottom: 1px solid var(--line); z-index: 5; }
.brand { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.brand .logo { font-size: 24px; }
.brand b { display: block; font-size: 15px; letter-spacing: .02em; }
.brand small, .clock small { display: block; font-size: 10px; color: var(--mut); }
#scenario { max-width: 270px; background: var(--bg2); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; padding: 8px; font: inherit; font-size: 13px; }
.clock b { font-variant-numeric: tabular-nums; font-size: 15px; }
.replay { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 120px; }
#seek { flex: 1; accent-color: var(--acc); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: none; border-radius: 0; padding: 7px 9px; font-size: 13px; background: transparent; }
.seg button.on { background: var(--acc); color: #002233; font-weight: 700; }
.conn { width: 12px; height: 12px; border-radius: 50%; background: #666; box-shadow: 0 0 0 3px rgba(255,255,255,.08); }
.conn.open { background: var(--safe); } .conn.connecting { background: var(--caution); } .conn.closed, .conn.error { background: var(--danger); }

/* alarm */
.alarm { position: absolute; top: 64px; left: 12px; right: calc(var(--side) + 22px); z-index: 6; padding: 10px 14px; border-radius: 12px;
  background: rgba(150, 18, 12, .92); border: 2px solid var(--danger); font-size: 15px; display: flex; gap: 12px; align-items: center; animation: pulse 1.2s infinite; }
.alarm b { font-size: 17px; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,59,48,.6); } 50% { box-shadow: 0 0 0 10px rgba(255,59,48,0); } }

/* side list */
#side { position: absolute; top: 64px; right: 10px; bottom: 10px; width: var(--side); z-index: 4; display: flex; flex-direction: column; gap: 8px; }
.side-head { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 12px; background: var(--bg); border-radius: 12px; border: 1px solid var(--line); }
.side-head span { color: var(--mut); font-size: 12px; }
#targets { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; scrollbar-width: thin; }
.tcard { background: var(--bg); border: 1px solid var(--line); border-left: 6px solid var(--safe); border-radius: 12px; padding: 10px 12px; cursor: pointer; }
.tcard.danger { border-left-color: var(--danger); background: rgba(70, 14, 12, .9); }
.tcard.caution { border-left-color: var(--caution); background: rgba(60, 44, 8, .88); }
.tcard.sel { outline: 2px solid #fff; }
.tcard .l1 { display: flex; align-items: center; gap: 8px; }
.tcard .ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 17px; }
.tcard .nm { font-weight: 700; font-size: 15px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcard .typ { font-size: 11px; color: var(--mut); }
.tcard .dir { font-size: 16px; font-weight: 700; margin: 6px 0 2px; }
.tcard .nums { display: flex; gap: 14px; font-variant-numeric: tabular-nums; }
.tcard .nums div small { display: block; font-size: 10px; color: var(--mut); }
.tcard .nums b { font-size: 18px; } .tcard .nums i { font-size: 11px; font-style: normal; color: var(--mut); margin-left: 2px; }
.trow { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--bg); border-radius: 10px; border: 1px solid var(--line); font-size: 13px; cursor: pointer; }
.trow .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow .r { color: var(--mut); font-variant-numeric: tabular-nums; font-size: 12px; }
.sub { font-size: 11px; color: var(--mut); padding: 2px 6px; }
.detail { background: var(--bg2); border: 1px solid var(--acc); border-radius: 12px; padding: 10px 12px; font-size: 12.5px; max-height: 42%; overflow-y: auto; }
.detail h3 { margin: 0 0 6px; font-size: 16px; display: flex; justify-content: space-between; }
.detail table { width: 100%; border-collapse: collapse; } .detail td { padding: 2px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.detail td:first-child { color: var(--mut); width: 40%; }
.est { color: var(--caution); font-size: 11px; margin-left: 4px; }

/* instruments */
#instruments { position: absolute; left: 10px; bottom: 10px; width: 330px; padding: 10px 12px; z-index: 4; }
.inst-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 10px; }
.inst-grid small { display: block; font-size: 10px; color: var(--mut); }
.inst-grid b { font-size: 22px; font-variant-numeric: tabular-nums; } .inst-grid i { font-style: normal; color: var(--mut); font-size: 11px; margin-left: 2px; }
.attitude { display: grid; grid-template-columns: 1fr 1fr 70px; gap: 6px; margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; align-items: center; }
.attitude svg { width: 100%; height: 66px; }
.attitude .sea { stroke: #3a8dde; stroke-width: 1.5; stroke-dasharray: 3 3; }
.attitude .hullp { fill: #00b8d4; } .attitude .house { fill: #e0f7fa; } .attitude .mast { stroke: #e0f7fa; stroke-width: 2; }
.attitude text { fill: #eaf2f8; font-size: 11px; text-anchor: middle; }
.heave small { display: block; font-size: 10px; color: var(--mut); } .heave b { font-size: 18px; } .heave i { font-style: normal; font-size: 11px; color: var(--mut); }
.tide { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; font-size: 12px; display: flex; gap: 10px; align-items: center; }
.tide b { font-size: 18px; } .tide svg { flex: 1; height: 34px; } .tide .na { color: var(--mut); }

/* trial maneuver */
#trial { position: absolute; left: 352px; right: calc(var(--side) + 22px); bottom: 10px; padding: 8px 12px; z-index: 4; max-width: 560px; }
.trial-head { display: flex; gap: 10px; align-items: baseline; } .trial-head small { color: var(--mut); font-size: 11px; }
.trial-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.trial-row input { flex: 1; accent-color: #b388ff; height: 28px; }
.trial-row b { min-width: 52px; text-align: right; font-size: 18px; color: #d1b3ff; }
#sweep { width: 100%; height: 46px; display: block; margin-top: 2px; }
.trial-text { font-size: 12.5px; margin-top: 3px; min-height: 18px; }
.trial-text .up { color: var(--safe); font-weight: 700; } .trial-text .down { color: var(--danger); font-weight: 700; }


/* settings drawer */
.drawer { position: absolute; top: 56px; right: 0; bottom: 0; width: 420px; max-width: 100%; z-index: 10; background: rgba(10,20,30,.98); border-left: 1px solid var(--line); padding: 14px 16px; overflow-y: auto; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.drawer label { display: block; font-size: 12px; color: var(--mut); margin: 8px 0; }
.drawer input, .drawer select { display: block; width: 100%; margin-top: 4px; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: #13263a; color: var(--fg); font: inherit; font-size: 14px; }
.drawer .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.drawer .chk { display: flex; gap: 8px; align-items: center; color: var(--fg); font-size: 13px; }
.drawer .chk input { width: auto; margin: 0; }
.hint { color: var(--mut); font-size: 11px; display: block; }
.credits { font-size: 11.5px; line-height: 1.5; } .credits div { border-bottom: 1px solid var(--line); padding: 5px 0; } .credits a { color: var(--acc); }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; font-size: 12px; }
.legend span i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }

/* map labels */
.labels { position: absolute; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
.labels .leaders { position: absolute; inset: 0; width: 100%; height: 100%; }
.labels .leaders line { stroke: rgba(255,255,255,.7); stroke-width: 1; }
.tlabel { position: absolute; left: 0; top: 0; pointer-events: none; will-change: transform; background: rgba(8,18,28,.88); border: 1px solid var(--line); border-left: 4px solid var(--safe);
  padding: 2px 7px; border-radius: 8px; font-size: 12px; white-space: nowrap; color: #fff; }
.tlabel.danger { border-left-color: var(--danger); } .tlabel.caution { border-left-color: var(--caution); } .tlabel.own { border-left-color: var(--own); }
.tlabel small { color: var(--mut); margin-left: 4px; }
.maplibregl-ctrl-attrib { font-size: 10px; } .maplibregl-ctrl-bottom-right { bottom: 0; right: calc(var(--side) + 14px); }
.maplibregl-ctrl-bottom-left { display: none; }
.banner-info { position: absolute; top: 64px; left: 12px; z-index: 4; font-size: 12px; padding: 6px 10px; max-width: 520px; color: #d5e2ec; }
.banner-info b { color: var(--caution); }

/* PC / narrow screens */
@media (min-width: 1400px) { :root { --side: 380px; } #trial { left: 352px; } }
@media (max-width: 1000px) { .brand small, .clock small { display: none; } #scenario { max-width: 170px; } .views { display: none; } #trial { left: 10px; bottom: 250px; right: calc(var(--side) + 22px); } }

/* live AIS mode */
body.live .replay { display: none; }
.livebadge { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: 10px; background: rgba(255,255,255,.07); border: 1px solid var(--line); font-size: 12px; line-height: 1.25; }
.livebadge .dot { width: 10px; height: 10px; border-radius: 50%; background: #8a97a3; flex: none; }
.livebadge.on .dot { background: #ff3b30; box-shadow: 0 0 0 0 rgba(255,59,48,.6); animation: livepulse 1.6s infinite; }
.livebadge b { font-size: 13px; } .livebadge small { display: block; color: var(--mut); font-size: 11px; }
.livebadge.stale small, .livebadge.err small { color: var(--caution); }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 rgba(255,59,48,.6); } 100% { box-shadow: 0 0 0 10px rgba(255,59,48,0); } }
.livenotice { position: absolute; top: 64px; left: 12px; right: calc(var(--side) + 22px); z-index: 5; padding: 10px 14px; border-radius: 12px;
  background: rgba(16, 32, 46, .92); border: 1px solid var(--line); font-size: 14px; line-height: 1.5; }
.livenotice.warn { background: rgba(60, 44, 8, .92); border-color: var(--caution); }
.livenotice b { font-size: 15px; }
button.ownbtn { width: 100%; margin-top: 10px; padding: 12px; font-size: 16px; font-weight: 700; border-radius: 12px; background: #00b8d4; color: #00222a; border: none; }
button.ownbtn.sec { background: rgba(255,255,255,.1); color: #fff; border: 1px solid var(--line); font-size: 14px; padding: 9px; }
.tlabel.own small.age { color: var(--caution); }

.alarm .sit { background: rgba(255,255,255,.15); padding: 2px 8px; border-radius: 8px; font-size: 13px; }

.trailbtn { padding: 6px 10px; border-radius: 10px; font-size: 12.5px; background: rgba(255,255,255,.07); border: 1px solid var(--line); color: var(--mut); white-space: nowrap; }
.trailbtn.on { color: #fff; }
.badge { display: inline-block; margin-top: 6px; padding: 3px 8px; border-radius: 8px; font-size: 12px; font-weight: 700; }
.badge.giveway { background: var(--danger); color: #fff; } .badge.standon { background: #2d6cdf; color: #fff; } .badge.both { background: #8e44ad; color: #fff; }
