:root {
  --bg: #0c1430;
  --bg-soft: #1a2659;
  --panel: rgba(9, 14, 34, 0.92);
  --text: #ecf2ff;
  --accent: #63d4ff;
  --accent-2: #ffdd57;
  --danger: #ff5c7a;
  --ok: #58d68d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: radial-gradient(circle at 20% 20%, #21327a, var(--bg));
  color: var(--text);
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 75% 12%, rgba(255, 255, 255, 0.15), transparent 35%);
}

.app {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 12px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.game-title {
  margin: 0;
  font-size: clamp(1.4rem, 2.2vw, 2rem);
  letter-spacing: 1px;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.icon-btn,
.primary-btn,
.touch-btn {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease, background 0.2s ease;
}

.icon-btn {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #2f4694, #21326b);
  color: var(--text);
  font-size: 1.15rem;
}

.icon-btn:active,
.primary-btn:active,
.touch-btn:active {
  transform: scale(0.97);
}

.icon-btn:hover,
.primary-btn:hover,
.touch-btn:hover {
  transform: translateY(-2px) scale(1.02);
  filter: brightness(1.08);
}

.game-shell {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.36);
}

#gameCanvas {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  display: block;
  background: linear-gradient(180deg, #5ea9ff 0%, #7ad2ff 40%, #8ce49a 100%);
}

.hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  background: linear-gradient(180deg, rgba(11, 17, 41, 0.82), transparent);
  pointer-events: none;
}

.hud-item,
.hud-health {
  background: rgba(8, 14, 38, 0.75);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 0.95rem;
}

.hud-health {
  min-width: 180px;
}

.health-bar {
  width: 100%;
  height: 10px;
  margin-top: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  overflow: hidden;
}

.health-fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--danger), var(--accent-2), var(--ok));
  transition: width 0.25s ease;
}

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.25s ease;
}

.overlay.visible {
  display: flex;
}

.panel {
  width: min(92%, 420px);
  padding: 24px 20px;
  border-radius: 16px;
  background: var(--panel);
  text-align: center;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}

.panel h2 {
  font-size: clamp(1.5rem, 2.8vw, 2rem);
}

.panel h2 {
  margin: 0 0 10px;
}

.panel p {
  margin: 0 0 14px;
}

.hint {
  color: #cbdbff;
  font-size: 0.92rem;
}

.primary-btn {
  min-width: 150px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  color: #10203f;
  background: linear-gradient(135deg, var(--accent-2), #ffc939);
}

.settings-menu {
  margin-top: 12px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(10, 16, 38, 0.8);
  display: none;
}

.settings-menu.open {
  display: block;
  animation: fadeIn 0.2s ease;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.setting-row input[type="range"] {
  width: min(260px, 60vw);
}

.touch-controls {
  display: none;
  margin-top: 12px;
  gap: 10px;
  justify-content: center;
}

.touch-btn {
  width: 74px;
  height: 54px;
  background: linear-gradient(135deg, #2f4694, #1f2e61);
  color: var(--text);
  font-size: 1.25rem;
}

@media (max-width: 900px), (pointer: coarse) {
  .touch-controls {
    display: flex;
  }

  .top-actions {
    gap: 8px;
  }
}

@media (max-width: 650px) {
  .hud {
    gap: 8px;
    padding: 8px;
  }

  .hud-item,
  .hud-health {
    font-size: 0.84rem;
    padding: 5px 8px;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
