:root {
  color-scheme: dark;
  --bg: #07131d;
  --panel: rgba(9, 20, 34, 0.82);
  --panel-border: rgba(125, 236, 255, 0.22);
  --text: #f4fbff;
  --muted: #9fc4d4;
  --accent: #7cf5c9;
  --hot: #ffcb6b;
  --danger: #ff6a83;
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(0, 190, 255, 0.18), transparent 34%),
    linear-gradient(180deg, #08131b 0%, #102331 55%, #0b1520 100%);
  color: var(--text);
}

.shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 20px;
  display: grid;
  gap: 18px;
}

.hud-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

.title-card {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 22px;
}

h1, h2, p {
  margin: 0;
}

.eyebrow,
.label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.74rem;
  color: var(--muted);
}

.subtitle {
  margin-top: 8px;
  color: #d9eff8;
}

.control-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: end;
  color: var(--muted);
}

.game-wrap {
  position: relative;
  width: 100%;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, #63dbff 0%, #6cc9fa 36%, #efd79f 36%, #efcf8b 52%, #8f5a36 52%, #7b4c2d 100%);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.35);
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.overlay-panel {
  width: min(520px, 100%);
  background: rgba(6, 16, 27, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.36);
}

.overlay-kicker {
  color: var(--hot);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  margin-bottom: 10px;
}

.overlay h2 {
  font-size: clamp(1.7rem, 2.8vw, 2.4rem);
  margin-bottom: 10px;
}

.overlay p + button,
button {
  margin-top: 18px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 700;
  color: #072420;
  background: linear-gradient(135deg, var(--accent), #99ffe4);
  cursor: pointer;
  box-shadow: 0 12px 25px rgba(124, 245, 201, 0.25);
}

.mobile-overlay {
  position: absolute;
  inset: 0;
  padding: 16px;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
  pointer-events: none;
}

.mobile-actions {
  align-self: flex-start;
  margin-left: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

.mobile-hint {
  display: none;
  max-width: 12rem;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(6, 16, 27, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #eaf9ff;
  font-size: 0.78rem;
  line-height: 1.25;
  text-align: right;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
}

.mobile-action-button {
  pointer-events: auto;
  min-height: 46px;
  padding: 10px 16px;
  margin-top: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.mobile-action-button.secondary {
  background: rgba(7, 23, 29, 0.82);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
}

.joystick {
  pointer-events: auto;
  position: relative;
  width: 132px;
  height: 132px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: radial-gradient(circle at center, rgba(124, 245, 201, 0.18), rgba(7, 19, 29, 0.3) 62%, rgba(7, 19, 29, 0.64));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), 0 12px 28px rgba(0, 0, 0, 0.28);
  touch-action: none;
}

.joystick::after {
  content: '';
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, 0.14);
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin-left: -26px;
  margin-top: -26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #99ffe4);
  box-shadow: 0 10px 22px rgba(124, 245, 201, 0.28);
}

.hud-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.hud-grid .hud-card {
  padding: 16px 18px;
}

.hud-grid .wide {
  grid-column: span 1;
}

.value {
  margin-top: 7px;
  font-size: 1.8rem;
  font-weight: 800;
}

.value.small {
  font-size: 1rem;
  line-height: 1.4;
  font-weight: 600;
  color: #eaf9ff;
}

@media (max-width: 860px) {
  .title-card {
    flex-direction: column;
    align-items: start;
  }

  .control-list {
    justify-content: start;
  }

  .hud-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hud-grid .wide {
    grid-column: span 2;
  }
}

@media (max-width: 560px) {
  .shell {
    padding: 12px;
  }

  .title-card {
    padding: 16px 18px;
  }

  .game-wrap {
    margin-left: -2px;
    margin-right: -2px;
  }

  .hud-grid {
    grid-template-columns: 1fr;
  }

  .hud-grid .wide {
    grid-column: span 1;
  }

  .value {
    font-size: 1.4rem;
  }
}

@media (hover: none) and (pointer: coarse) {
  .mobile-overlay {
    display: flex;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }

  .mobile-actions {
    gap: 8px;
  }

  .mobile-hint {
    display: block;
  }

  .mobile-action-button {
    min-height: 42px;
    padding: 9px 14px;
    font-size: 0.95rem;
  }

  .joystick {
    width: 116px;
    height: 116px;
  }

  .joystick-knob {
    width: 46px;
    height: 46px;
    margin-left: -23px;
    margin-top: -23px;
  }
}

.game-wrap:fullscreen,
.game-wrap:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  background: #050d14;
  display: grid;
  place-items: center;
}

.game-wrap:fullscreen canvas,
.game-wrap:-webkit-full-screen canvas {
  width: min(100vw, calc(100vh * 1.6));
  height: auto;
  max-height: 100vh;
  border-radius: 0;
}

.game-wrap:fullscreen .mobile-overlay,
.game-wrap:-webkit-full-screen .mobile-overlay {
  display: flex;
}
