:root {
  color-scheme: dark;
  font-family: 'Avenir Next', 'Hiragino Sans', 'Yu Gothic', system-ui, sans-serif;
  background: #020817;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  min-height: 100%;
  background: radial-gradient(circle at 50% -20%, rgba(18, 112, 154, 0.22), transparent 42%), #020817;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button,
canvas { -webkit-tap-highlight-color: transparent; }

.game-wrapper {
  position: relative;
  display: grid;
  place-items: center;
  isolation: isolate;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  outline: none;
}

#gameCanvas:focus-visible { filter: drop-shadow(0 0 8px rgba(99, 234, 255, 0.55)); }

.game-actions {
  position: absolute;
  z-index: 4;
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.action-button {
  min-height: 42px;
  border: 1px solid rgba(126, 235, 255, 0.28);
  border-radius: 999px;
  color: #dbfbff;
  background: rgba(3, 21, 42, 0.78);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.1), 0 8px 24px rgba(0, 0, 0, 0.22);
  font: 700 12px 'Avenir Next', 'Hiragino Sans', sans-serif;
  letter-spacing: 0.08em;
  backdrop-filter: blur(12px);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.action-button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(126, 235, 255, 0.7);
  background: rgba(8, 48, 72, 0.9);
}

.action-button:focus-visible {
  outline: 2px solid #63eaff;
  outline-offset: 3px;
}

.action-button:disabled {
  color: rgba(184, 219, 226, 0.46);
  cursor: default;
}

.sonar-button {
  display: inline-flex;
  min-width: 122px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 16px;
}

.sonar-button.is-ready {
  color: #06131c;
  border-color: #8dffff;
  background: linear-gradient(135deg, #69f4ff, #8affc1);
  box-shadow: 0 0 24px rgba(80, 232, 255, 0.42);
  animation: sonar-ready 1.8s ease-in-out infinite;
}

.action-icon { font-size: 17px; }
.icon-button { width: 42px; padding: 0; font-size: 16px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes sonar-ready {
  0%, 100% { box-shadow: 0 0 18px rgba(80, 232, 255, 0.34); }
  50% { box-shadow: 0 0 34px rgba(80, 232, 255, 0.62); }
}

@media (orientation: portrait), (max-width: 720px) {
  .game-actions {
    top: max(14px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    gap: 5px;
  }

  .action-button { min-height: 36px; }
  .sonar-button { min-width: 98px; padding: 0 10px; font-size: 10px; }
  .icon-button { width: 36px; }
}

@media (hover: none) and (pointer: coarse) {
  #gameCanvas { cursor: default; }
}

@media (prefers-reduced-motion: reduce) {
  .action-button,
  .sonar-button.is-ready { animation: none; transition: none; }
}
