:root {
  --paper: #101c30;
  --wash: #22344c;
  --surface: #253955;
  --ink: #fff3d5;
  --label: #bacecd;
  --edge: #40576b;
  --primary: #f0bf68;
  --on-primary: #282537;
}
.scene {
  background: #12374d url(./bay.webp) center/cover;
}
.chart-grid {
  position: absolute;
  inset: 0;
  opacity: 0.22;
  background-image: radial-gradient(circle, #b1ede6 1px, transparent 1.8px);
  background-size: 8.3% 7.7%;
  background-position: 4.3% 4%;
}
.light-chart,
.mirrors,
.harbor {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.light-chart polyline {
  fill: none;
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.halo {
  stroke: #ffbb38;
  stroke-width: 14px;
  opacity: 0.27;
  filter: blur(4px);
}
.ray {
  stroke: #ffd968;
  stroke-width: 4px;
}
.spark {
  stroke: #fff9d3;
  stroke-width: 2px;
  stroke-dasharray: 3 18;
  animation: light-run 2s linear infinite;
}
.trace {
  stroke: #fff;
  stroke-width: 5px;
  stroke-dasharray: 4 7;
}
@keyframes light-run {
  to {
    stroke-dashoffset: -84;
  }
}
.reflector {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  width: 8.7%;
  aspect-ratio: 1;
  min-width: 44px;
  max-width: 75px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    #225571 0 52%,
    #122f46 55% 64%,
    #8aa6a8 66% 69%,
    #385575 71%
  );
  border: 0;
  padding: 0;
  box-shadow:
    0 5px 0 #102f41,
    0 7px 9px #09222d99;
}
.reflector.lit {
  background: radial-gradient(
    circle,
    #356e80 0 52%,
    #213e49 54% 63%,
    #ffe4a0 64% 68%,
    #ac794c 69%
  );
}
.glass {
  position: absolute;
  left: 7%;
  top: 43%;
  width: 86%;
  height: 15%;
  border: 2px solid #c2fef6;
  border-radius: 12px;
  background: linear-gradient(#e1ffff, #65b5c6 55%, #2e839b);
  box-shadow: 0 2px 1px #062a41;
  transform: rotate(var(--angle));
  transition: transform 0.24s cubic-bezier(0.22, 0.75, 0.24, 1.18);
}
.pivot {
  position: absolute;
  width: 11%;
  aspect-ratio: 1;
  top: 44.5%;
  left: 44.5%;
  border-radius: 50%;
  background: #d9af70;
  border: 1px solid #ffdfa2;
}

.moon {
  position: absolute;
  width: 9%;
  height: 16%;
  min-width: 41px;
  transform: translate(-50%, -50%);
  background: url(./moon.webp) center/contain no-repeat;
  filter: drop-shadow(0 0 6px #ffce6e88);
}
.lighthouse {
  position: absolute;
  width: 10%;
  min-width: 43px;
  height: 29%;
  transform: translate(-50%, -20%);
  background: url(./lighthouse.webp) top center/contain no-repeat;
  filter: drop-shadow(1px 3px 2px #0c233a99);
}
.lighthouse::before {
  content: "";
  position: absolute;
  width: 25%;
  aspect-ratio: 1;
  top: 12%;
  left: 37.5%;
  background: radial-gradient(circle, #fffac4, #ffc24c88 48%, transparent 73%);
  opacity: 0;
  transition: opacity 0.5s;
}
.home .lighthouse::before {
  opacity: 1;
  box-shadow: 0 0 12px 7px #ffce6a66;
  border-radius: 50%;
}
.harbor button.buoy {
  border: none;
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
}
.buoy {
  position: absolute;
  width: 5%;
  height: 9%;
  transform: translate(-50%, -47%);
  background: url(./buoy.webp) center/contain no-repeat;
  filter: saturate(0.45) brightness(0.78);
}
.buoy.lit {
  filter: drop-shadow(0 0 6px #ffe387) saturate(1.2) brightness(1.25);
}
.boat {
  position: absolute;
  width: 11%;
  height: 16%;
  bottom: 4%;
  left: 4%;
  background: url(./sailboat.webp) center bottom/contain no-repeat;
  transition: left 3.2s ease-in-out;
}
.home .boat {
  left: 81%;
}
.chart-sheet {
  position: absolute;
  z-index: 2;
  inset: 4%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 3%;
  border: 2px solid #bd9a61;
  border-radius: 9px;
  color: #344c50;
  background: radial-gradient(ellipse at 48% 44%, #fff4cb, #dfc99b);
  box-shadow:
    0 3px 0 #7b695a,
    0 14px 35px #08172299;
}
.chart-sheet[hidden] {
  display: none;
}
.chart-sheet h3 {
  font-family: Georgia, serif;
  font-size: clamp(18px, 3vw, 31px);
  margin: 0;
}
.chart-sheet > p {
  margin: 0;
  font-size: 14px;
}
.chart-stops {
  position: relative;
  width: 96%;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template: repeat(2, 1fr) / repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.chart-stops button {
  display: flex;
  flex-direction: column;
  gap: 2px;
  justify-content: center;
  align-items: center;
  padding: 7px 3px;
  background: #fff4d94d;
  border: 1px dashed #849077;
  border-radius: 10px;
  min-height: 52px;
  line-height: 1.1;
}
.chart-stops button:disabled {
  opacity: 0.65;
}
.chart-stops button.current {
  border: 2px solid #8e5941;
}
.chart-stops img {
  height: clamp(30px, 5vw, 65px);
  width: auto;
}
.chart-stops span {
  color: #3b4d4a;
  font-size: clamp(11px, 1.6vw, 15px);
  font-weight: 750;
}
.chart-stops small {
  font-size: 12px;
  color: #664c34;
}
.chart-sheet .close-chart {
  border: 1px solid #8f7856;
  border-radius: 8px;
  background: #fff4d8;
  font-weight: 800;
  padding: 7px 12px;
  min-height: 44px;
  flex: 0 0 auto;
  color: #3b4d4a;
}
@media (max-width: 600px) {
  .chart-sheet {
    inset: 2%;
    gap: 6px;
    padding: 2%;
  }
  .chart-stops {
    grid-template: repeat(4, minmax(44px, 1fr)) / repeat(2, minmax(0, 1fr));
    gap: 4px;
  }
  .chart-stops button {
    min-height: 40px;
    display: grid;
    grid-template-columns: 26px 1fr;
    align-content: center;
    text-align: left;
    padding: 3px;
    gap: 0 3px;
  }
  .chart-stops img {
    width: 25px;
    height: 35px;
    object-fit: contain;
    grid-row: 1/3;
  }
  .chart-stops small {
    font-size: 10px;
  }
}
.buoy {
  width: 7%;
  height: 12.4%;
  min-width: 31px;
  min-height: 37px;
  filter: saturate(0.88) brightness(0.98) drop-shadow(0 1px 2px #122b3a);
}
.buoy::after {
  content: "";
  position: absolute;
  left: 20%;
  right: 20%;
  bottom: -3%;
  height: 10%;
  border: 1px solid #eace88;
  border-radius: 50%;
  opacity: 0.75;
}

.chart-stops button:not(:disabled) {
  background:
    linear-gradient(0deg, #fff0ce 47%, transparent 51%),
    var(--shore) center/cover;
}

.harbor .boat {
  border: 0;
  padding: 0;
  pointer-events: auto;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  touch-action: manipulation;
}
.boat:focus-visible {
  outline: 3px solid #ffdc8d;
  border-radius: 8px;
}

.harbor :is(.moon, .lighthouse) {
  pointer-events: auto;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}
.reflector.calling::after {
  content: "";
  position: absolute;
  inset: -8%;
  border-radius: 50%;
  border: 3px dashed #fff3b0;
  box-shadow: 0 0 10px #ffc24e;
}

@media (orientation: landscape) and (max-height: 500px) {
  .chart-sheet {
    inset: 2%;
    padding: 2%;
    gap: 4px;
  }
  .chart-sheet h3 {
    font-size: 19px;
  }
  .chart-sheet > p {
    font-size: 12px;
  }
  .chart-stops button {
    padding: 3px;
    min-height: 48px;
  }
  .chart-stops img {
    max-height: 25px;
  }
  .chart-stops small {
    font-size: 10px;
  }
  .chart-stops span {
    font-size: 11px;
  }
}
