/* ── Cosmic Chaos — Mobile-First Stylesheet ──── */

:root {
  --bg: #080a14;
  --panel: #10132a;
  --accent: #7b2ff7;
  --accent-hover: #9b5cff;
  --accent-secondary: #00e5ff;
  --muted: #8b8fa8;
  --font-display: "Bangers", cursive;
  --font-body: "Outfit", sans-serif;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: #e8e9f0;
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ── Backdrop gradients ──────────────────────── */
.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.backdrop--one {
  background: radial-gradient(ellipse at 20% 30%, rgba(123, 47, 247, 0.12) 0%, transparent 60%);
}

.backdrop--two {
  background: radial-gradient(ellipse at 80% 70%, rgba(0, 229, 255, 0.08) 0%, transparent 55%);
}

/* ── Shell ───────────────────────────────────── */
.shell {
  position: relative;
  z-index: 1;
  max-width: 1140px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Hero ────────────────────────────────────── */
.hero {
  text-align: center;
  margin-bottom: 1.5rem;
}

.eyebrow {
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  color: var(--accent-secondary);
  margin-bottom: 0.5rem;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.5rem);
  color: var(--accent);
  letter-spacing: 0.04em;
  line-height: 1.1;
}

.subtitle {
  max-width: 600px;
  margin: 0.5rem auto 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ── Game Frame ──────────────────────────────── */
.game-frame {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

/* ── Arena ────────────────────────────────────── */
.arena-wrap {
  position: relative;
  background: rgba(16, 19, 42, 0.6);
  border: 1px solid rgba(123, 47, 247, 0.2);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 0 60px rgba(123, 47, 247, 0.08);
  backdrop-filter: blur(6px);
}

.arena-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px 10px;
  font-size: 0.85rem;
}

#message-banner {
  color: var(--muted);
  font-weight: 600;
}

.streak {
  color: var(--accent-secondary);
  font-weight: 700;
}

.streak strong {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin-left: 4px;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 960 / 600;
  border-radius: 14px;
  border: 1px solid rgba(123, 47, 247, 0.15);
  background: #050718;
}

.arena-bottom {
  padding: 10px 4px 0;
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
}

/* ── Arena overlay (pause) ───────────────────── */
.arena-overlay {
  position: absolute;
  inset: 66px 18px 58px;
  z-index: 10;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: rgba(8, 10, 20, 0.82);
  border-radius: 14px;
  backdrop-filter: blur(10px);
}

.arena-overlay.show {
  display: flex;
}

.arena-overlay__title {
  font-family: var(--font-display);
  font-size: 2.5rem;
  color: var(--accent);
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.arena-overlay__text {
  font-size: 0.95rem;
  color: var(--muted);
}

/* ── Touch Controls ──────────────────────────── */
.touch-controls {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.touch-joystick {
  position: absolute;
  left: 5vw;
  bottom: max(20px, env(safe-area-inset-bottom, 0px) + 12px);
  pointer-events: auto;
}

.touch-joystick--aim {
  left: auto;
  right: 5vw;
}

.touch-joystick__base {
  width: min(130px, 30vw);
  height: min(130px, 30vw);
  border-radius: 50%;
  background: rgba(123, 47, 247, 0.15);
  border: 2px solid rgba(123, 47, 247, 0.35);
  display: flex;
  justify-content: center;
  align-items: center;
}

.touch-joystick__base--aim {
  background: rgba(0, 229, 255, 0.12);
  border-color: rgba(0, 229, 255, 0.3);
}

.touch-joystick__thumb {
  width: min(52px, 12vw);
  height: min(52px, 12vw);
  border-radius: 50%;
  background: rgba(123, 47, 247, 0.5);
  border: 2px solid rgba(123, 47, 247, 0.7);
  transition: none;
}

.touch-joystick__thumb--aim {
  background: rgba(0, 229, 255, 0.4);
  border-color: rgba(0, 229, 255, 0.6);
}

.touch-joystick__label {
  text-align: center;
  margin-top: 6px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
}

.touch-buttons {
  position: absolute;
  top: max(14px, env(safe-area-inset-top, 0px) + 8px);
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: auto;
}

.touch-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: white;
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 0.08em;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.touch-btn--special {
  background: rgba(123, 47, 247, 0.25);
  border-color: rgba(123, 47, 247, 0.5);
}

.touch-btn--pause {
  width: 40px;
  height: 40px;
  font-size: 0.7rem;
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 767px) {
  .shell {
    width: 100%;
    padding: 0;
  }

  .hero {
    display: none;
  }

  .game-frame {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .arena-wrap {
    padding: 0;
    border-radius: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  .arena-topbar,
  .arena-bottom {
    display: none;
  }

  .arena-overlay {
    inset: 0;
    border-radius: 0;
  }

  canvas {
    width: 100vw !important;
    height: calc(100vh - 140px) !important;
    height: calc(100dvh - 140px) !important;
    border-radius: 0;
    border: 0;
    aspect-ratio: auto;
  }
}

/* Landscape phones — width > 767px but small height */
@media (orientation: landscape) and (max-height: 700px) {
  .shell { width: 100%; padding: 0; }
  .hero { display: none; }
  .game-frame { grid-template-columns: 1fr; gap: 0; }
  .arena-wrap {
    padding: 0; border-radius: 0; border: 0;
    background: transparent; box-shadow: none; backdrop-filter: none;
  }
  .arena-topbar, .arena-bottom { display: none; }
  .arena-overlay { inset: 0; border-radius: 0; }
  canvas {
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    border-radius: 0;
    border: 0;
    aspect-ratio: auto;
  }
}

@media (min-width: 768px) and (max-width: 1080px) {
  .arena-overlay {
    inset: 66px 18px 58px;
    border-radius: 22px;
  }
}

/* ── Show touch controls on touch devices ────── */
@media (pointer: coarse) {
  .touch-controls {
    display: block;
  }
}

@media (max-width: 767px) {
  .touch-joystick {
    left: 3vw;
    bottom: max(12px, env(safe-area-inset-bottom, 0px) + 8px);
  }

  .touch-joystick--aim {
    left: auto;
    right: 3vw;
    bottom: max(12px, env(safe-area-inset-bottom, 0px) + 8px);
  }

  .touch-joystick__base {
    width: min(120px, 28vw);
    height: min(120px, 28vw);
  }

  .touch-joystick__thumb {
    width: min(48px, 11vw);
    height: min(48px, 11vw);
  }

  .touch-buttons {
    position: absolute;
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    bottom: max(12px, env(safe-area-inset-bottom, 0px) + 8px);
    top: auto;
    flex-direction: row;
    gap: 10px;
  }

  .touch-btn--special {
    width: 58px;
    height: 58px;
    font-size: 0.6rem;
  }

  .touch-btn--pause {
    width: 38px;
    height: 38px;
    font-size: 0.7rem;
  }

  .touch-joystick__label {
    font-size: 0.55rem;
  }
}

/* ── Iframe embed — MUST be last to override all media queries ── */
.in-iframe .hero,
.in-iframe .arena-topbar,
.in-iframe .arena-bottom { display: none !important; }
.in-iframe .shell { width: 100% !important; padding: 0 !important; }
.in-iframe .game-frame { gap: 0 !important; }
.in-iframe .arena-wrap {
  padding: 0 !important; border-radius: 0 !important; border: 0 !important;
  background: transparent !important; box-shadow: none !important; backdrop-filter: none !important;
}
.in-iframe .arena-overlay { inset: 0 !important; border-radius: 0 !important; }
.in-iframe canvas {
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  border-radius: 0 !important;
  border: 0 !important;
  aspect-ratio: auto !important;
}
