:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #1a1a1d;
  color: #fbfff9;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  min-width: 320px;
}

/* Maps container sits behind the Three.js canvas in Lake Tahoe mode */
#mapsContainer {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
}

#mapsContainer gmp-map-3d {
  width: 100%;
  height: 100%;
}

#scene {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #8b9db0 0%, #d4a48b 65%, #efc6a6 100%);
  touch-action: none;
}

/* In photoreal mode the Three.js canvas goes transparent so the Map shows through */
#scene.photoreal-mode {
  background: transparent;
}

.hud {
  position: fixed;
  z-index: 5;
  color: #fbfff9;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.hud-button,
.sail-toggle button,
.controls-legacy button {
  pointer-events: auto;
}

/* ====== Compass panel (top-left) ====== */
.compass-panel {
  top: 18px;
  left: 18px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: 220px;
}

.compass-card {
  position: relative;
  background: rgba(10, 12, 16, 0.78);
  border-radius: 14px;
  padding: 14px 16px 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.compass-speed {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 6px;
}

.compass-speed strong {
  font-size: 32px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
  line-height: 1;
}

.compass-speed span {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.68);
  font-weight: 500;
}

.compass-rose {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  margin: 2px 0 10px;
}

.compass-dial {
  width: 100%;
  height: 100%;
  display: block;
}

.compass-bg {
  fill: #1e2025;
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 1;
}

.compass-ring {
  fill: none;
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 1;
}

.compass-ticks line {
  stroke: rgba(255, 255, 255, 0.42);
  stroke-width: 1.2;
}

.compass-ticks line.major {
  stroke: rgba(255, 255, 255, 0.72);
  stroke-width: 1.8;
}

.compass-card-letter {
  fill: rgba(255, 255, 255, 0.92);
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
}

/* Heading needle - rotates around center */
.compass-needle {
  position: absolute;
  inset: 0;
  transform: rotate(calc(var(--heading, 0) * 1deg));
  transition: transform 120ms linear;
  pointer-events: none;
}

.needle-north,
.needle-south {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  transform: translate(-50%, -100%);
}

.needle-north {
  border-bottom: 36px solid #ff4949;
}

.needle-south {
  border-bottom: 26px solid #d9dbe0;
  transform: translate(-50%, 0) rotate(180deg);
  transform-origin: top center;
}

/* Wind arrow - rotates around compass center, relative wind direction */
.compass-wind {
  position: absolute;
  inset: 0;
  transform: rotate(calc(var(--wind, 0) * 1deg));
  transition: transform 200ms linear;
  pointer-events: none;
}

.wind-tick {
  position: absolute;
  left: 50%;
  top: 6%;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 14px solid #5aa8ff;
  transform: translate(-50%, 0);
  filter: drop-shadow(0 0 3px rgba(90, 168, 255, 0.6));
}

.compass-readouts {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  font-weight: 600;
}

.compass-readouts .lbl {
  font-weight: 700;
  letter-spacing: 0.2px;
}

.compass-readouts .lbl-heading { color: #ff7e7e; }
.compass-readouts .lbl-wind    { color: #5aa8ff; }

.compass-readouts b {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.compass-mode {
  margin-top: 6px;
  font-size: 10px;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.54);
}

/* ====== Buttons ====== */
.hud-button {
  border: 0;
  border-radius: 10px;
  min-height: 44px;
  padding: 0 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  color: #fbfff9;
  background: rgba(10, 12, 16, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.28);
  transition: transform 0.08s ease, filter 0.15s ease;
}

.hud-button:hover {
  filter: brightness(1.12);
}

.hud-button:active {
  transform: translateY(1px);
}

.btn-race {
  background: linear-gradient(180deg, #39b57a 0%, #2a8b5e 100%);
  color: #fbfff9;
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-bay {
  font-size: 13px;
  min-height: 38px;
  background: rgba(20, 32, 34, 0.8);
}

.race-timer {
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  background: rgba(10, 12, 16, 0.78);
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.race-timer span {
  font-size: 11px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
}

.race-timer strong {
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  font-weight: 700;
}

/* ====== Tutorial panel (top-right) ====== */
.tutorial {
  top: 18px;
  right: 18px;
  width: min(330px, calc(100vw - 280px));
  padding: 14px 16px;
  background: rgba(10, 12, 16, 0.62);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
  pointer-events: none;
}

.tutorial p {
  margin: 0;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.9);
}

/* ====== Sail toggle button (bottom center) ====== */
.sail-toggle {
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  pointer-events: none;
}

.sail-toggle button {
  min-width: 100px;
  min-height: 70px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: #1a1a1d;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.32);
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  font-size: 15px;
  letter-spacing: 0.8px;
  cursor: pointer;
}

.sail-toggle button .toggle-top,
.sail-toggle button .toggle-bottom {
  display: block;
}

.sail-toggle button.sail-down {
  background: rgba(26, 38, 34, 0.82);
  color: #e9fff3;
}

/* ====== Sliders ====== */
.rudder-control,
.sail-control {
  pointer-events: none;
}

.rudder-control {
  left: 24px;
  bottom: 24px;
}

.sail-control {
  right: 24px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.sheet-button {
  pointer-events: auto;
  min-width: 92px;
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(10, 12, 16, 0.72);
  color: rgba(255, 255, 255, 0.94);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
}

.sheet-button:hover {
  filter: brightness(1.12);
}

.sheet-button:active {
  transform: translateY(1px);
}

.slider-shell {
  position: relative;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  backdrop-filter: blur(6px);
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
  user-select: none;
}

.slider-shell.horizontal {
  width: 260px;
  height: 44px;
  padding: 0 6px;
  display: flex;
  align-items: center;
}

.slider-shell.vertical {
  width: 44px;
  height: 260px;
  padding: 6px 0;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
}

.slider-track {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
}

.slider-shell.horizontal .slider-track {
  height: 3px;
  width: 100%;
  border-radius: 2px;
}

.slider-shell.vertical .slider-track {
  width: 3px;
  height: 100%;
  border-radius: 2px;
}

.slider-thumb {
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.55);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.slider-shell.horizontal .slider-thumb {
  left: calc(50% + (var(--value, 0) * 108px));
}

.slider-shell.vertical .slider-thumb {
  top: calc(50% - (var(--value, 0) * 108px));
}

.slider-shell:active .slider-thumb {
  background: rgba(255, 255, 255, 0.38);
}

.thumb-mark {
  display: block;
  width: 3px;
  height: 16px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.85);
}

.slider-shell.horizontal .thumb-mark {
  width: 16px;
  height: 3px;
}

.slider-label {
  margin-top: 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.4px;
  color: rgba(255, 255, 255, 0.88);
}

.slider-subtext {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 2px;
  text-align: center;
}

.slider-subtext span {
  font-size: 10px;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.56);
}

.slider-subtext strong {
  font-size: 12px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.94);
}

/* ====== Hidden legacy controls ====== */
.controls-legacy {
  display: none;
}

.map-credits {
  position: fixed;
  right: 8px;
  bottom: 7px;
  z-index: 6;
  max-width: min(480px, calc(100vw - 16px));
  padding: 4px 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.78);
  color: #111;
  font-size: 10px;
  line-height: 1.3;
  pointer-events: none;
}

/* ====== Responsive adjustments ====== */
@media (max-width: 760px) {
  .compass-panel {
    top: 10px;
    left: 10px;
    width: 180px;
    gap: 6px;
  }

  .compass-card {
    padding: 10px 12px 8px;
  }

  .compass-speed strong { font-size: 26px; }

  .tutorial {
    left: 10px;
    right: 10px;
    top: auto;
    bottom: 230px;
    width: auto;
  }

  .rudder-control {
    left: 10px;
    bottom: 12px;
  }

  .sail-control {
    right: 10px;
    bottom: 12px;
  }

  .sheet-button {
    min-width: 80px;
    min-height: 30px;
    font-size: 11px;
  }

  .slider-shell.horizontal {
    width: 180px;
    height: 38px;
  }

  .slider-shell.vertical {
    height: 180px;
    width: 38px;
  }

  .slider-shell.horizontal .slider-thumb {
    left: calc(50% + (var(--value, 0) * 74px));
  }

  .slider-shell.vertical .slider-thumb {
    top: calc(50% - (var(--value, 0) * 74px));
  }

  .sail-toggle {
    bottom: 14px;
  }

  .sail-toggle button {
    min-width: 84px;
    min-height: 60px;
    font-size: 13px;
  }
}
