@import url("https://fonts.googleapis.com/css2?family=Orbitron:wght@600;700;800&family=Rajdhani:wght@500;600;700&display=swap");

:root {
  --bg-deep: #08111d;
  --bg-mid: #102438;
  --bg-glow: rgba(66, 214, 255, 0.14);
  --panel-bg: rgba(7, 17, 29, 0.78);
  --panel-border: rgba(141, 226, 255, 0.22);
  --panel-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --text-main: #f4fbff;
  --text-soft: rgba(244, 251, 255, 0.74);
  --accent: #42d6ff;
  --accent-hot: #ffb443;
  --accent-green: #93ff97;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 20% 20%, rgba(66, 214, 255, 0.18), transparent 28%),
    radial-gradient(circle at 78% 16%, rgba(255, 180, 67, 0.18), transparent 24%),
    linear-gradient(180deg, #0c1b2d 0%, #08111d 50%, #050b12 100%);
  color: var(--text-main);
  font-family: "Rajdhani", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

body {
  position: fixed;
  inset: 0;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
}

#app::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 25%),
    radial-gradient(circle at 50% 110%, rgba(66, 214, 255, 0.18), transparent 40%);
  pointer-events: none;
  z-index: 1;
}

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

#uiLayer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.hud {
  position: absolute;
  top: clamp(14px, 2.2vh, 26px);
  left: clamp(14px, 2.6vw, 26px);
  display: grid;
  grid-template-columns: repeat(2, minmax(108px, 140px));
  gap: 10px;
  max-width: min(320px, calc(100vw - 28px));
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.stat-card {
  padding: 12px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(8, 17, 29, 0.9), rgba(10, 24, 39, 0.76));
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(14px);
}

.stat-label {
  display: block;
  margin-bottom: 4px;
  color: var(--text-soft);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-card strong {
  font-family: "Orbitron", sans-serif;
  font-size: clamp(1rem, 2.6vw, 1.2rem);
  letter-spacing: 0.04em;
}

.utility-bar {
  position: absolute;
  top: clamp(14px, 2.2vh, 26px);
  right: clamp(14px, 2.6vw, 26px);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#app[data-screen="menu"] .hud,
#app[data-screen="menu"] .utility-bar,
#app[data-screen="gameover"] .hud,
#app[data-screen="gameover"] .utility-bar {
  opacity: 0;
  transform: translateY(-10px);
  visibility: hidden;
  pointer-events: none;
}

.sound-toggle {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(7, 17, 29, 0.7);
  color: var(--text-main);
  backdrop-filter: blur(14px);
  pointer-events: auto;
  cursor: pointer;
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.sound-toggle:hover,
.sound-toggle:focus-visible,
.action-button:hover,
.action-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(66, 214, 255, 0.62);
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.screen.visible {
  display: flex;
}

.panel {
  width: min(100%, 500px);
  padding: clamp(24px, 5vw, 38px);
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(66, 214, 255, 0.1), transparent 18%),
    linear-gradient(180deg, rgba(8, 17, 29, 0.95), rgba(5, 11, 18, 0.9));
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(18px);
  text-align: center;
  pointer-events: auto;
}

.panel h1,
.panel h2 {
  margin: 0;
  font-family: "Orbitron", sans-serif;
  font-size: clamp(2rem, 7vw, 3.3rem);
  line-height: 1.05;
}

.status-message {
  min-height: 1.2em;
  margin: 10px auto 0;
  max-width: 44ch;
  color: #ffcf78;
  font-size: 0.98rem;
  letter-spacing: 0.02em;
}

.status-message:empty {
  display: none;
}

.panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 22px;
  flex-wrap: wrap;
}

.policy-row {
  margin-top: 14px;
}

.policy-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.04);
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.policy-link:hover,
.policy-link:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(66, 214, 255, 0.62);
  background: rgba(66, 214, 255, 0.08);
}

.support-stack {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-top: 10px;
}

.compact-panel {
  width: min(100%, 460px);
}

.sound-toggle-small {
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.support-link {
  color: var(--text-soft);
  text-decoration: none;
  font-size: 0.88rem;
  letter-spacing: 0.02em;
}

.support-link:hover,
.support-link:focus-visible {
  color: var(--accent);
}

.best-run {
  color: var(--text-soft);
  font-size: 1.05rem;
}

.best-run strong {
  color: var(--accent-green);
  font-family: "Orbitron", sans-serif;
  margin-left: 6px;
}

.results {
  margin: 24px 0 16px;
  display: grid;
  gap: 12px;
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.result-row strong {
  font-family: "Orbitron", sans-serif;
  color: var(--accent-hot);
}

.action-button {
  pointer-events: auto;
  cursor: pointer;
  border: 1px solid rgba(66, 214, 255, 0.48);
  border-radius: 999px;
  padding: 13px 22px;
  background: linear-gradient(135deg, rgba(66, 214, 255, 0.96), rgba(42, 145, 255, 0.92));
  color: #031018;
  font: inherit;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 16px 30px rgba(42, 145, 255, 0.28);
  transition: transform 0.2s ease, filter 0.2s ease, border-color 0.2s ease;
}

.action-button:active,
.sound-toggle:active {
  transform: scale(0.98);
}

@media (max-width: 820px) {
  .hud {
    grid-template-columns: repeat(2, minmax(92px, 1fr));
    gap: 8px;
  }

  .utility-bar {
    top: auto;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: auto;
  }
}

@media (max-width: 560px) {
  .hud {
    max-width: calc(100vw - 24px);
  }

  .stat-card {
    padding: 10px 12px;
  }

  .panel-footer {
    flex-direction: column;
  }
}
