:root {
  color-scheme: light;
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  background: #b9e7ff;
  color: #173149;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  touch-action: none;
}

button {
  font: inherit;
}

#game-shell {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #b9e7ff;
}

#game-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  cursor: crosshair;
}

.hud {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  z-index: 5;
  width: min(360px, calc(100vw - 24px));
  padding: 10px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 30px rgba(17, 55, 92, 0.16);
  backdrop-filter: blur(10px);
}

.mission-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 15px;
  line-height: 1.25;
}

.mission-strip strong {
  flex: 1 1 104px;
  min-width: 0;
}

.mission-strip span {
  flex: 1 1 180px;
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.meter-row {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 22px;
  font-size: 14px;
  font-weight: 700;
}

.meter {
  position: relative;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #d8e2ea;
}

.meter i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1aa7ec, #77dcff);
  transition: width 120ms linear;
}

.timer i {
  background: linear-gradient(90deg, #54c66b, #f6d365);
}

.crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 4;
  width: 32px;
  height: 32px;
  translate: -50% -50%;
  pointer-events: none;
}

.crosshair::before,
.crosshair::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 2px rgba(20, 43, 68, 0.34);
}

.crosshair::before {
  left: 15px;
  top: 5px;
  width: 2px;
  height: 22px;
}

.crosshair::after {
  left: 5px;
  top: 15px;
  width: 22px;
  height: 2px;
}

.crosshair.hit::before,
.crosshair.hit::after {
  background: #58e48a;
}

.panel {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 10;
  width: min(430px, calc(100vw - 32px));
  padding: 24px;
  translate: -50% -50%;
  border: 2px solid rgba(255, 255, 255, 0.84);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 20px 70px rgba(24, 56, 84, 0.24);
  text-align: center;
  backdrop-filter: blur(14px);
}

.panel.hidden {
  display: none;
}

.panel h1,
.panel h2 {
  margin: 0 0 10px;
  font-size: clamp(26px, 5vw, 42px);
  line-height: 1.08;
  letter-spacing: 0;
}

.panel p {
  margin: 0 0 18px;
  font-size: 16px;
  line-height: 1.5;
  color: #36546d;
}

.panel .control-copy {
  margin-top: -4px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(126, 215, 255, 0.24);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.55;
}

.panel button,
.mobile-actions button {
  min-width: 104px;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: #f15f4d;
  color: white;
  font-weight: 800;
  box-shadow: 0 8px 0 #bf3d30;
}

.panel button:active,
.mobile-actions button:active {
  translate: 0 4px;
  box-shadow: 0 4px 0 #bf3d30;
}

.mobile-stick,
.mobile-actions {
  display: none;
}

.mobile-stick {
  position: fixed;
  left: max(20px, env(safe-area-inset-left));
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 6;
  width: 118px;
  height: 118px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: rgba(37, 66, 98, 0.2);
  backdrop-filter: blur(8px);
  touch-action: none;
}

#stick-thumb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  translate: -50% -50%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 6px 16px rgba(20, 43, 68, 0.22);
}

.mobile-actions {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 6;
  grid-template-columns: 72px;
  gap: 12px;
}

.mobile-actions button {
  min-width: 72px;
  width: 72px;
  height: 72px;
  border-radius: 999px;
}

#rescue-btn {
  display: none;
  background: #23a35a;
  box-shadow: 0 8px 0 #17783f;
}

#rescue-btn:active {
  box-shadow: 0 4px 0 #17783f;
}

@media (pointer: coarse), (max-width: 780px) {
  .hud {
    width: min(330px, calc(100vw - 24px));
    padding: 9px;
  }

  .mission-strip {
    font-size: 13px;
  }

  .meter-row {
    grid-template-columns: 34px 1fr;
    font-size: 12px;
  }

  .mobile-stick {
    display: block;
  }

  .mobile-actions {
    display: grid;
  }

  .panel {
    top: 43%;
    padding: 20px;
  }
}

@media (max-width: 520px) {
  .hud {
    right: max(12px, env(safe-area-inset-right));
  }

  .mission-strip {
    display: block;
  }

  .mission-strip span {
    display: block;
    margin-top: 3px;
    text-align: left;
  }

  .mobile-stick {
    width: 104px;
    height: 104px;
  }

  .mobile-actions {
    grid-template-columns: 64px;
  }

  .mobile-actions button {
    width: 64px;
    height: 64px;
    min-width: 64px;
    min-height: 64px;
    font-size: 13px;
  }
}
