:root {
  --canal-ink: #163d45;
  --canal-cream: #fff8df;
  --canal-brass: #e8b54b;
  --canal-red: #e86d55;
  --canal-blue: #4f91be;
}
html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #123f49;
}
body.canal-day {
  color: #183f46;
  background: linear-gradient(#79c9d1 0 46%, #6e9b64 46% 100%);
  touch-action: manipulation;
}
.canal-day .game-shell {
  height: 100dvh;
  min-height: 0;
  padding: max(7px, env(safe-area-inset-top))
    max(9px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom))
    max(9px, env(safe-area-inset-left));
  display: grid;
  grid-template-rows: 50px auto minmax(185px, 1fr) auto;
  gap: 6px;
  max-width: 760px;
  background: transparent;
}
.canal-day header {
  padding: 0;
  min-height: 50px;
}
.canal-day .brand {
  color: #fff;
}
.canal-day .brand small {
  color: #ffe69a;
}
.canal-day .round-button {
  width: 46px;
  height: 46px;
  min-height: 46px;
  background: #fff7de;
  color: #19454d;
  border-color: #fff;
}
.canal-day .mission-card {
  margin: 0;
  padding: 7px 12px;
  min-height: 72px;
  background: rgba(255, 248, 223, 0.97);
  border: 2px solid #d89b3b;
  color: #17414a;
}
.canal-day .mission-card > div {
  display: flex;
  justify-content: space-between;
}
.canal-day .mission-card p {
  margin: 2px 0;
  font-size: 14px;
  line-height: 1.2;
}
.canal-day .progress-track {
  height: 7px;
  margin: 5px 0 0;
}
.canal-day .progress-track i {
  background: linear-gradient(90deg, #e86d55, #e8b54b);
}
#stage {
  position: relative;
  min-height: 0;
  height: auto;
  border: 2px solid rgba(255, 248, 223, 0.85);
  border-radius: 22px;
  overflow: hidden;
  background: linear-gradient(#8bd2d7 0 58%, #7da26a 58%);
  isolation: isolate;
  box-shadow: 0 8px 18px #123b4650;
}
#stage canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100% !important;
  height: 100% !important;
  pointer-events: none;
}
.scene-caption {
  position: absolute;
  z-index: 3;
  top: 7px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 9px;
  border-radius: 999px;
  background: #174952d9;
  color: #fff5cc;
  white-space: nowrap;
  font-size: 9px;
  letter-spacing: 0.12em;
}
#targets {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  padding: 0 10px 10px;
}
.gate-target {
  pointer-events: auto;
  min-width: 94px;
  min-height: 52px;
  padding: 6px 10px;
  border: 2px solid #fff6d5;
  border-radius: 14px;
  background: linear-gradient(#f5c85d, #d89230);
  color: #173e45;
  box-shadow:
    0 5px 0 #8c5a24,
    0 7px 18px #163c4755;
  font:
    900 13px/1.05 Nunito,
    sans-serif;
  touch-action: manipulation;
}
.gate-target .wheel {
  display: block;
  font-size: 23px;
  line-height: 22px;
}
.gate-target:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #8c5a24;
}
.gate-target.hinted {
  outline: 4px solid #fff;
  animation: pulseGate 0.8s ease-in-out infinite alternate;
}
.gate-target.turned .wheel {
  animation: spinGate 0.38s ease;
}
.gate-target.solved {
  background: linear-gradient(#8ad787, #4ca76a);
}
@keyframes spinGate {
  to {
    transform: rotate(180deg);
  }
}
@keyframes pulseGate {
  to {
    filter: brightness(1.22) drop-shadow(0 0 7px #fff4b8);
  }
}
#loading {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  background: #174f59;
  color: #fff5d2;
  font-weight: 900;
}
.dock {
  margin: 0;
  padding: 7px 9px;
  background: rgba(255, 248, 223, 0.97);
  border: 2px solid #d89b3b;
  border-radius: 17px;
  color: #17414a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.water-key {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 8px;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.15;
  max-width: 58%;
}
.dock-actions {
  display: flex;
  gap: 7px;
}
.canal-day #hint,
.canal-day #restart {
  min-width: 74px;
  min-height: 46px;
  padding: 7px 9px;
}
.canal-day .intro-card {
  border-color: #e8b54b;
  background: #fff9e7;
}
.canal-day .primary {
  background: linear-gradient(135deg, #e86d55, #c94e43);
}
.canal-day .eyebrow {
  color: #2d7880;
}
.canal-day .dialog-art {
  filter: drop-shadow(0 5px 4px #24505b44);
}
body.stage-complete #stage {
  box-shadow:
    0 0 0 4px #ffe38b,
    0 0 30px #fff0a7;
}
.canal-day #announcement {
  z-index: 20;
}
.canal-day button:focus-visible,
.canal-day a:focus-visible {
  outline: 4px solid #fff;
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .gate-target,
  .gate-target .wheel {
    animation: none !important;
    transition: none !important;
  }
}
@media (max-width: 360px) {
  .canal-day .brand small {
    display: none;
  }
  .canal-day .mission-card {
    min-height: 64px;
  }
  .canal-day .mission-card p {
    font-size: 12px;
  }
  .gate-target {
    min-width: 82px;
    min-height: 48px;
    font-size: 11px;
  }
  .water-key {
    font-size: 9px;
  }
  .canal-day #hint,
  .canal-day #restart {
    min-width: 64px;
    padding: 5px;
    font-size: 11px;
  }
}
@media (max-height: 620px) and (orientation: portrait) {
  .canal-day .game-shell {
    grid-template-rows: 46px 66px minmax(170px, 1fr) 64px;
    gap: 4px;
  }
  .canal-day header {
    min-height: 46px;
  }
  .canal-day .round-button {
    width: 44px;
    height: 44px;
    min-height: 44px;
  }
  .canal-day .mission-card {
    min-height: 0;
    padding: 5px 10px;
  }
  .canal-day .mission-card p {
    font-size: 11px;
  }
  .dock {
    padding: 4px 7px;
  }
  .water-key span:nth-child(-n + 2) {
    display: none;
  }
}
@media (orientation: landscape) and (max-height: 500px) {
  .canal-day .game-shell {
    max-width: 900px;
    grid-template-columns: 180px minmax(0, 1fr) 180px;
    grid-template-rows: 48px minmax(240px, 1fr);
    gap: 6px;
  }
  .canal-day header {
    grid-column: 1/4;
  }
  .canal-day .mission-card {
    grid-column: 1;
    grid-row: 2;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: auto;
  }
  .canal-day .mission-card > div {
    display: block;
  }
  .canal-day .mission-card p {
    font-size: 13px;
    margin: 8px 0;
  }
  .canal-day #stage {
    grid-column: 2;
    grid-row: 2;
    margin: 0;
    width: auto;
  }
  .canal-day .dock {
    grid-column: 3;
    grid-row: 2;
    flex-direction: column;
    justify-content: center;
    width: auto;
  }
  .water-key {
    max-width: 100%;
    display: grid;
  }
  .dock-actions {
    flex-direction: column;
    width: 100%;
  }
  .canal-day #hint,
  .canal-day #restart {
    width: 100%;
  }
  .scene-caption {
    top: 5px;
  }
}
