/* ==========================================================================
   CHAOS DROP - UI layer. No external assets, no webfonts, no CDN.
   ========================================================================== */

:root {
  --bg-color: #08090d;
  --accent-cyan: #00f3ff;
  --accent-magenta: #ff0055;
  --accent-gold: #ffbe0b;
  --accent-violet: #7c5cff;
  --text-pure: #ffffff;
  --panel-bg: rgba(18, 20, 29, 0.85);
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body,
html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-color);
  font-family: var(--font-family);
  color: var(--text-pure);
  overscroll-behavior: none;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

#game-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: radial-gradient(circle at center, #111422 0%, #050608 100%);
  touch-action: none;
}

.hidden {
  display: none !important;
}

/* ---------------------------------------------------------------- HUD ---- */

.hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: calc(16px + var(--safe-top)) 20px 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10;
}

.hud-progress {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
}

.hud-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-magenta));
  transition: width 0.2s linear;
}

.hud-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 8px;
}

.hud-label {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  opacity: 0.6;
  display: block;
}

.hud-value {
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.score-box {
  justify-self: start;
}

.challenge-box {
  justify-self: center;
  text-align: center;
}

.target-val {
  color: var(--accent-gold);
  font-size: 1.15rem;
}

.hud-right {
  justify-self: end;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.combo-pill {
  padding: 4px 12px;
  background: var(--accent-magenta);
  font-size: 1rem;
  font-weight: 900;
  border-radius: 999px;
  box-shadow: 0 0 12px rgba(255, 0, 85, 0.4);
  transition: transform 0.12s ease;
  display: inline-block;
}

.hud-actions {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.icon-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-pure);
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  touch-action: manipulation;
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn[aria-pressed="true"] {
  background: rgba(255, 0, 85, 0.25);
  border-color: var(--accent-magenta);
  color: var(--accent-magenta);
}

.event-banner {
  align-self: center;
  padding: 6px 18px;
  background: var(--accent-cyan);
  color: #000;
  font-weight: 900;
  letter-spacing: 0.15em;
  font-size: 0.85rem;
  border-radius: 4px;
  text-transform: uppercase;
  animation: pulse 0.8s infinite alternate;
}

.event-banner.warning {
  background: var(--accent-magenta);
  color: #fff;
}

@keyframes pulse {
  from { transform: scale(0.96); opacity: 0.85; }
  to { transform: scale(1.04); opacity: 1; }
}

/* ------------------------------------------------------------ Overlays --- */

.screen-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 8, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  overflow-y: auto;
  padding: calc(24px + var(--safe-top)) 24px calc(24px + var(--safe-bottom));
  z-index: 20;
}

.screen-inner {
  margin: auto;
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.glitch-title {
  font-size: 2.6rem;
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 1;
  background: linear-gradient(180deg, #fff 0%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tagline {
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  opacity: 0.8;
  margin-top: 8px;
  line-height: 1.5;
}

.profile-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  margin-bottom: 1.25rem;
  text-align: left;
}

.profile-input-wrap label {
  font-size: 0.7rem;
  font-weight: 700;
  opacity: 0.6;
  letter-spacing: 0.08em;
}

.profile-input-wrap input {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 12px;
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.08em;
  outline: none;
  text-transform: uppercase;
  width: 100%;
}

.profile-input-wrap input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(0, 243, 255, 0.15);
}

.btn-group,
.action-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 16px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.2s ease;
}

.btn:active {
  transform: scale(0.96);
}

.btn:focus-visible,
.icon-btn:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}

.primary-btn {
  background: var(--accent-cyan);
  color: #000;
  box-shadow: 0 4px 20px rgba(0, 243, 255, 0.3);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.ghost-btn {
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.8rem;
  padding: 10px;
}

.rage-btn {
  background: var(--accent-magenta);
  color: #fff;
  box-shadow: 0 4px 20px rgba(255, 0, 85, 0.4);
}

.menu-stats {
  display: flex;
  gap: 24px;
  margin-top: 1.75rem;
  font-size: 0.85rem;
  opacity: 0.8;
  font-variant-numeric: tabular-nums;
}

.menu-legend {
  list-style: none;
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  opacity: 0.55;
  font-weight: 700;
}

.menu-legend li {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-cyan { background: var(--accent-cyan); }
.dot-magenta { background: var(--accent-magenta); }
.dot-gold { background: var(--accent-gold); }

.rival-card {
  background: rgba(255, 190, 11, 0.15);
  border: 1px solid var(--accent-gold);
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 1.25rem;
  text-align: center;
  width: 100%;
}

.rival-title {
  font-size: 0.6rem;
  font-weight: 800;
  color: var(--accent-gold);
  letter-spacing: 0.12em;
  display: block;
}

#challenge-desc {
  font-size: 0.9rem;
  font-weight: 800;
  margin-top: 4px;
}

/* ---------------------------------------------------------- Game over ---- */

.gameover-content .meme-text {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--accent-gold);
  letter-spacing: 0.1em;
  margin-bottom: 6px;
  line-height: 1.4;
}

.gameover-title {
  font-size: 1.9rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
}

.final-score-cluster {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  margin-bottom: 1.5rem;
}

.score-display .lbl {
  font-size: 0.7rem;
  opacity: 0.6;
  font-weight: 700;
  display: block;
  letter-spacing: 0.1em;
}

.score-display .val {
  font-size: 2.9rem;
  font-weight: 900;
  color: var(--accent-cyan);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  display: block;
  word-break: break-all;
}

.stat-pills {
  display: flex;
  justify-content: space-around;
  gap: 8px;
  margin-top: 12px;
  font-size: 0.72rem;
  opacity: 0.85;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.challenge-result {
  margin-top: 14px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(0, 243, 255, 0.12);
  border: 1px solid var(--accent-cyan);
  color: var(--accent-cyan);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.pause-content .tagline {
  margin-bottom: 1.75rem;
}

/* -------------------------------------------------------------- Toast ---- */

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(28px + var(--safe-bottom));
  transform: translateX(-50%);
  background: rgba(18, 20, 29, 0.96);
  border: 1px solid rgba(0, 243, 255, 0.4);
  color: var(--text-pure);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 10px 18px;
  border-radius: 999px;
  z-index: 30;
  max-width: 86%;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
}

/* ------------------------------------------------------ Touch controls --- */

.touch-controls {
  position: absolute;
  inset: 0;
  display: flex;
  pointer-events: none;
  z-index: 5;
}

.touch-zone {
  flex: 1;
  height: 100%;
  border: none;
  background: transparent;
  outline: none;
  pointer-events: auto;
  touch-action: none;
  padding: 0;
}

.touch-controls.disabled .touch-zone {
  pointer-events: none;
}

.noscript {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  font-size: 0.9rem;
}

/* ---------------------------------------------------------- Responsive --- */

@media (min-width: 720px) {
  .glitch-title { font-size: 3rem; }
  .screen-inner { max-width: 340px; }
  .btn-group,
  .action-grid { max-width: 320px; }
  .action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .action-grid #btn-rage-restart,
  .action-grid #btn-menu {
    grid-column: span 2;
  }
}

@media (prefers-reduced-motion: reduce) {
  .event-banner { animation: none; }
  .btn { transition: none; }
  .combo-pill { transition: none; }
}
