:root {
  --bg-dark: #07080d;
  --board-bg: rgba(15, 18, 30, 0.85);
  --glass-border: rgba(255, 255, 255, 0.12);
  --neon-cyan: #00f2fe;
  --neon-pink: #ec4899;
  --neon-gold: #fbbf24;
  --neon-purple: #a855f7;
  --neon-green: #10b981;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", sans-serif;
  --font-mono: "SF Mono", "Fira Code", monospace;
}

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

body {
  background-color: var(--bg-dark);
  color: #fff;
  font-family: var(--font-sans);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  touch-action: none;
}

/* Ambient Pulsing Glow */
.cosmic-backdrop {
  position: fixed;
  inset: 0;
  background: 
    radial-gradient(circle at 50% 20%, rgba(236, 72, 153, 0.15), transparent 60%),
    radial-gradient(circle at 20% 80%, rgba(0, 242, 254, 0.12), transparent 55%),
    radial-gradient(circle at 80% 80%, rgba(168, 85, 247, 0.15), transparent 55%);
  pointer-events: none;
  z-index: 0;
}

header {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: rgba(7, 8, 13, 0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  box-shadow: 0 0 16px rgba(236, 72, 153, 0.4);
}

.brand-title {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 800;
  background: linear-gradient(135deg, #fff, #f472b6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.05em;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  color: #cbd5e1;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s;
}

.icon-btn:active {
  transform: scale(0.9);
  color: #fff;
}

/* Dopamine Meter & Score HUD */
.hud-banner {
  position: relative;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  gap: 10px;
}

.hud-pill {
  background: rgba(18, 22, 38, 0.85);
  border: 1px solid var(--glass-border);
  border-radius: 9999px;
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(12px);
}

/* Dopamine Rush Meter */
.rush-meter-container {
  position: relative;
  z-index: 20;
  padding: 0 18px 8px;
}

.rush-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

.rush-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink), var(--neon-gold));
  border-radius: 9999px;
  transition: width 0.25s ease;
  box-shadow: 0 0 12px rgba(236, 72, 153, 0.8);
}

/* Game Area */
main {
  position: relative;
  z-index: 10;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  max-width: 440px;
  margin: 0 auto;
  width: 100%;
}

/* 8x8 Jewel Board */
.grid-chassis {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 380px;
  background: var(--board-bg);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85), inset 0 2px 8px rgba(255, 255, 255, 0.1);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 4px;
  padding: 8px;
  overflow: hidden;
}

/* Gem Cells */
.gem-tile {
  position: relative;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.4);
}

.gem-tile:active {
  transform: scale(0.92);
}

.gem-tile.selected {
  transform: scale(1.12);
  filter: brightness(1.3) drop-shadow(0 0 12px #fff);
  z-index: 15;
  outline: 2px solid #fff;
}

.gem-tile.popping {
  animation: popExplosion 0.25s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popExplosion {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.8; filter: brightness(1.6); }
  100% { transform: scale(0); opacity: 0; }
}

/* Floating Juicy Feedback Text (e.g. "JUICY!", "EUPHORIC CASCADE!") */
.floating-banner {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: 1.6rem;
  text-shadow: 0 0 20px currentColor, 0 4px 8px #000;
  pointer-events: none;
  z-index: 50;
  white-space: nowrap;
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.4), opacity 0.35s;
  opacity: 0;
}

.floating-banner.show {
  transform: translate(-50%, -50%) scale(1.3);
  opacity: 1;
}

/* Dialogs */
dialog {
  margin: auto;
  background: rgba(13, 16, 26, 0.98);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  backdrop-filter: blur(30px);
  color: white;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.9);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
}

.primary-btn {
  width: 100%;
  padding: 13px;
  border-radius: 14px;
  border: none;
  font-weight: 800;
  font-size: 0.92rem;
  background: linear-gradient(135deg, var(--neon-pink), #c026d3);
  color: #fff;
  cursor: pointer;
  margin-top: 14px;
  box-shadow: 0 4px 20px rgba(236, 72, 153, 0.4);
}
