:root {
  --ink: #12305a;
  --card: rgba(255, 255, 255, 0.86);
  --accent: #ff7a45;
  --shadow: 0 6px 18px rgba(10, 30, 70, 0.18);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #2f8cff;
  color: var(--ink);
  font-family: "M PLUS Rounded 1c", system-ui, sans-serif;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.title {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 16px;
  text-align: center;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 40%, rgba(18, 48, 90, 0.35));
  transition: opacity 0.6s;
}
.title.leaving { opacity: 0; pointer-events: none; }
.title h1 {
  margin: 0;
  font-size: clamp(48px, 13vw, 112px);
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.08em;
  text-shadow: 0 4px 0 var(--ink), 0 10px 30px rgba(10, 30, 70, 0.35);
}
.title p { margin: 0; color: #fff; font-size: clamp(15px, 4vw, 20px); text-shadow: 0 2px 6px rgba(10, 30, 70, 0.5); }
.title .hint { font-size: 13px; opacity: 0.9; }

.primary {
  margin-top: 12px;
  padding: 14px 34px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 5px 0 #c4501f, var(--shadow);
  cursor: pointer;
}
.primary:active { transform: translateY(3px); box-shadow: 0 2px 0 #c4501f, var(--shadow); }

.hud {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
}
.card { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 8px 14px; }
.gauges { display: flex; align-items: center; gap: 14px; }
.speed { font-size: 30px; font-weight: 800; line-height: 1; min-width: 3.4em; }
.speed small, .dist small, .compass small, .clock small { font-size: 12px; margin-left: 3px; opacity: 0.7; }
.compass { display: flex; align-items: center; gap: 6px; }
.compass svg { width: 38px; height: 38px; }
.compass circle { fill: #fff; stroke: var(--ink); stroke-width: 2; }
.compass .n { fill: var(--accent); }
.compass .s { fill: #9fb3cf; }
.compass b { display: block; font-size: 16px; white-space: nowrap; }
.gauges small, .clock small { white-space: nowrap; }

@media (max-width: 420px) {
  .card { padding: 8px 10px; }
  .gauges { gap: 10px; }
  .speed { font-size: 26px; min-width: 3em; }
  .compass svg { width: 32px; height: 32px; }
  .clock span { font-size: 19px; }
}
.dist span { font-size: 18px; font-weight: 800; }
.clock { text-align: right; }
.side { display: grid; gap: 6px; justify-items: end; }

.secondary {
  padding: 10px 22px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.zukan-btn {
  pointer-events: auto;
  border: 0;
  font: inherit;
  font-weight: 800;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
}

.zukan {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(10, 30, 70, 0.45);
}
.zukan-panel {
  width: min(720px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  border-radius: 20px;
  background: #fffaf0;
  box-shadow: var(--shadow);
  padding: 16px;
}
.zukan-panel header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.zukan-panel h2 { margin: 0; font-size: 20px; }
.zukan-panel h2 span { font-size: 15px; margin-left: 6px; opacity: 0.75; }
.zukan-panel header button {
  border: 0;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  background: var(--ink);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}
.zukan-grid {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.entry {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 12px 8px;
  border-radius: 14px;
  background: #e8eef6;
  text-align: center;
}
.entry .icon { font-size: 34px; line-height: 1.2; filter: grayscale(1); opacity: 0.45; }
.entry b { font-size: 15px; }
.entry small { font-size: 11px; opacity: 0.75; line-height: 1.4; }
.entry.found { background: #dff3ff; }
.entry.found .icon { filter: none; opacity: 1; }
.zukan-goal { margin: 14px 0 0; text-align: center; font-size: 13px; opacity: 0.8; }
.zukan-panel footer { margin-top: 12px; text-align: center; }
.zukan-reset {
  border: 1px solid #c9d3e0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  padding: 6px 16px;
  cursor: pointer;
}

.boat-select { display: flex; gap: 6px; padding: 4px; border-radius: 999px; background: rgba(255, 255, 255, 0.85); }
.boat-select button {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  padding: 8px 14px;
  cursor: pointer;
}
.boat-select button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.fleet { padding: 4px 12px; font-size: 14px; }
.fleet b { font-size: 18px; margin-left: 2px; }
.fleet-title { font-weight: 800; }
.privacy-link {
  position: fixed;
  bottom: max(12px, env(safe-area-inset-bottom));
  right: 14px;
  color: #fff;
  font-size: 12px;
  opacity: 0.85;
  text-shadow: 0 1px 4px rgba(10, 30, 70, 0.6);
}
.clock span { display: block; font-size: 22px; font-weight: 800; }

.toast {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -10px);
  padding: 10px 22px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-weight: 800;
  font-size: 18px;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 0.4s, transform 0.4s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.keys {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--card);
  font-size: 13px;
  white-space: nowrap;
}

.touch {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}
.lever, .wheel { position: relative; pointer-events: auto; background: var(--card); box-shadow: var(--shadow); }
.lever { width: 64px; height: 170px; border-radius: 32px; }
.lever span { position: absolute; left: 0; right: 0; text-align: center; font-size: 11px; opacity: 0.6; }
.lever span:first-of-type { top: 6px; }
.lever span:last-of-type { bottom: 6px; }
.wheel { width: 170px; height: 76px; border-radius: 38px; }
.knob {
  position: absolute;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 3px 0 #c4501f;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 26px;
}
.lever .knob { left: 6px; }
.wheel .knob { top: 12px; }
