/* ===================================================
   BUBBLE SHOOTER — style.css
   =================================================== */
/* Fonts handled via index.html <link> */

/* ─── CSS Variables ─────────────────────────────── */
:root {
  --bg:          #0A1137;
  --bg2:         #1B1820;
  --bg3:         #1B1820;
  --accent:      #A61127;
  --accent2:     #ACA6BB;
  --text:        #F5F7F3;
  --text-muted:  #ACA6BB;
  --surface:     rgba(245,247,243,0.06);
  --glass:       rgba(245,247,243,0.08);
  --border:      rgba(172,166,187,0.2);
  --shadow:      0 8px 40px rgba(0,0,0,0.6);
  --radius:      16px;
  --font-base:   1rem;
  --font-scale:  1;

  /* Bubble colours (harmonized with new palette) */
  --c-R: #A61127;
  --c-G: #74c69d;
  --c-B: #4dabf7;
  --c-Y: #ffd43b;
  --c-O: #ff922b;
  --c-V: #cc5de8;
  --c-P: #f06595;
  --c-W: #ffffff;
  --c-I: #a5d8ff;
  --c-X: #868e96;
  --c-M: #1B1820;
  --c-Z: #74c69d;
}

/* ─── Reset & Base ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: 'Nunito', sans-serif;
  font-size: calc(16px * var(--font-scale));
  background: var(--bg);
  color: var(--text);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

canvas {
  display: block;
  position: fixed;
  top: 0; left: 0;
  touch-action: none;
}

/* ─── Utility ───────────────────────────────────── */
.hidden { display: none !important; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-col { flex-direction: column; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }

/* ─── Overlay Screens ───────────────────────────── */
.screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  z-index: 100;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease;
  background: rgba(10, 17, 55, 0.4);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes scaleUp {
  0%   { transform: scale(0.6); opacity: 0; }
  60%  { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes victoryGlowPulse {
  0%, 100% { box-shadow: var(--shadow), 0 0 20px rgba(255, 212, 59, 0.4); }
  50% { box-shadow: var(--shadow), 0 0 40px rgba(255, 212, 59, 0.7); }
}

@keyframes defeatRattle {
  0% { transform: translate(1px, 1px) rotate(0deg); }
  10% { transform: translate(-1px, -2px) rotate(-1deg); }
  20% { transform: translate(-3px, 0px) rotate(1deg); }
  30% { transform: translate(3px, 2px) rotate(0deg); }
  40% { transform: translate(1px, -1px) rotate(1deg); }
  50% { transform: translate(-1px, 2px) rotate(-1deg); }
  60% { transform: translate(-3px, 1px) rotate(0deg); }
  70% { transform: translate(3px, 1px) rotate(-1deg); }
  80% { transform: translate(-1px, -1px) rotate(1deg); }
  90% { transform: translate(1px, 2px) rotate(0deg); }
  100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.victory-animate {
  animation: scaleUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both, victoryGlowPulse 2s infinite ease-in-out;
}

.defeat-animate {
  animation: fadeIn 0.4s ease both, defeatRattle 0.3s;
}

.panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.05);
  padding: 32px 40px;
  width: min(480px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}

#screen-victory .panel {
  width: 100%;
  height: 100%;
  max-height: 100%;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#screen-victory .panel > * {
  width: min(480px, 94vw);
}

.panel h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 3.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  margin-bottom: 6px;
}

.panel h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2.2rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 4px;
}

.panel .subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 24px;
}
.impressum-link {
  display: block;
  margin-top: 14px;
  font-size: 0.72rem;
  color: #666;
  text-align: left;
  text-decoration: none;
}
.impressum-link:hover { color: #999; }

/* ─── Buttons ───────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 28px;
  border-radius: 999px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  border: none;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  letter-spacing: 0.02em;
}
.btn:active { transform: scale(0.95); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 24px rgba(166,17,39,0.3);
  width: 100%;
}
.btn-primary:hover { box-shadow: 0 6px 30px rgba(166,17,39,0.5); transform: translateY(-1px); }

.btn-secondary {
  background: var(--glass);
  border: 1px solid var(--border);
  color: var(--text);
  width: 100%;
}
.btn-secondary:hover { background: rgba(255,255,255,0.12); }

.btn-sm {
  padding: 8px 18px;
  font-size: 0.82rem;
}

.btn-icon {
  width: 40px; height: 40px; padding: 0;
  border-radius: 50%;
  font-size: 1.1rem;
  background: var(--glass);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: var(--surface); transform: scale(1.1); }

/* ─── Main Menu ─────────────────────────────────── */
#screen-menu .logo-wrap {
  margin-bottom: 8px;
}
#screen-menu .logo {
  font-family: 'Cormorant Garamond', serif;
  font-size: 4rem;
  font-weight: 700;
  background: linear-gradient(135deg, #ff4444, #ffd43b, #3ddc84, #4dabf7, #cc5de8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  background-size: 300% 300%;
  animation: gradientShift 4s ease infinite;
  text-align: center;
  line-height: 1;
}
#screen-menu .tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 28px;
}

@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ─── Level Select ──────────────────────────────── */
.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin: 16px 0;
}

.level-btn {
  aspect-ratio: 1;
  border-radius: 12px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.2s, border-color 0.2s;
  background: var(--bg3);
  position: relative;
  overflow: hidden;
}
.level-btn.locked {
  opacity: 0.35;
  cursor: not-allowed;
}
.level-btn:not(.locked):hover {
  transform: scale(1.1);
  border-color: var(--accent);
}
.level-btn .stars {
  font-size: 0.55rem;
  letter-spacing: -1px;
  margin-top: 2px;
  color: #ffd43b;
}

/* ─── HUD ───────────────────────────────────────── */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  pointer-events: none;
}

#hud .hud-box {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px 10px;
  text-align: center;
  min-width: 52px;
  pointer-events: all;
}
#hud .hud-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
#hud .hud-value {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
}
#hud .hud-btn {
  pointer-events: all;
}

#hud-center {
  display: flex; gap: 8px; pointer-events: none;
}
#score-val, #shots-val, #level-label {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
}

/* ─── Next Bubble Preview ───────────────────────── */
#next-bubbles {
  position: fixed;
  bottom: calc(140px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 8px; align-items: center;
  z-index: 50;
  pointer-events: auto;
}
.next-bubble-preview {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  transition: transform 0.2s;
}
.next-bubble-preview:first-child { width: 38px; height: 38px; }

.keyboard-hint {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--accent);
  color: white;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  pointer-events: none;
  z-index: 2;
}

/* ─── Colorblind Shapes in Preview ─── */
.bubble-shape {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: rgba(255, 255, 255, 0.7);
  pointer-events: none;
}

.shape-circle { border-radius: 50%; }
.shape-square { }
.shape-triangle { 
  background: none;
  width: 0; height: 0; 
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 12px solid rgba(255, 255, 255, 0.7);
}
.shape-diamond { transform: translate(-50%, -50%) rotate(45deg); width: 10px; height: 10px; }
.shape-cross {
  background: none;
  width: 14px; height: 14px;
}
.shape-cross::before, .shape-cross::after {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.7);
}
.shape-cross::before { width: 4px; height: 14px; left: 5px; }
.shape-cross::after { width: 14px; height: 4px; top: 5px; }

.shape-star {
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.shape-hex {
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}

/* ─── Shooter Area ──────────────────────────────── */
#shooter-hint {
  position: fixed;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.72rem;
  color: var(--text-muted);
  z-index: 50;
  pointer-events: none;
  transition: opacity 0.5s;
}

/* ─── Settings Panel ────────────────────────────── */
.settings-group {
  margin-bottom: 20px;
}
.settings-group h3 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.toggle-row label { font-size: 0.9rem; }

/* Toggle switch */
.toggle-switch {
  position: relative; width: 46px; height: 26px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.3s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.3s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Slider */
.range-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.range-row label { font-size: 0.9rem; flex: 1; }
.range-row input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 120px; height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.15);
  outline: none;
}
.range-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

/* ─── Tutorial Overlay ──────────────────────────── */
#tutorial-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
}
.tutorial-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  width: min(360px, 90vw);
  text-align: center;
}
.tutorial-card .step-icon { font-size: 3rem; margin-bottom: 12px; }
.tutorial-card h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 8px; }
.tutorial-card p  { font-size: 0.88rem; color: var(--text-muted); line-height: 1.6; }
.tutorial-dots {
  display: flex; gap: 8px; justify-content: center; margin: 16px 0;
}
.tutorial-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border);
  transition: background 0.3s;
}
.tutorial-dot.active { background: var(--accent); }

/* ─── Victory / Defeat Screens ──────────────────── */
#screen-victory .stars-display {
  font-size: 3rem;
  letter-spacing: 4px;
  margin: 12px 0;
  animation: starPop 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes starPop {
  from { transform: scale(0) rotate(-30deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}

#screen-defeat .defeat-icon {
  font-size: 4rem;
  animation: shake 0.5s ease;
  display: block; text-align: center;
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60%  { transform: translateX(-8px); }
  40%,80%  { transform: translateX(8px); }
}

/* Score breakdown */
.score-breakdown {
  background: var(--bg3);
  border-radius: 12px;
  padding: 14px 18px;
  margin: 14px 0;
}
.score-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 0;
  font-size: 0.88rem;
}
.score-row .val { font-weight: 700; color: var(--accent); }

/* ─── Floating Score Pop ────────────────────────── */
.score-pop {
  position: fixed;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 700;
  font-size: 1.6rem;
  color: #ffd43b;
  pointer-events: none;
  z-index: 300;
  animation: scorePop 1s ease forwards;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}
@keyframes scorePop {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  80%  { opacity: 1; transform: translateY(-60px) scale(1.2); }
  100% { opacity: 0; transform: translateY(-80px) scale(0.9); }
}

/* ─── Item Collection Tray ──────────────────────── */
#item-tray {
  position: fixed;
  bottom: calc(95px + env(safe-area-inset-bottom, 0px));
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 50;
  pointer-events: none;
}
.item-slot {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--glass);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  transition: transform 0.3s, background 0.3s;
}
.item-slot.collected {
  background: rgba(255,212,59,0.2);
  border-color: #ffd43b;
  animation: collectPop 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes collectPop {
  0%   { transform: scale(0); }
  100% { transform: scale(1); }
}

/* ─── Combo Flash ───────────────────────────────── */
#combo-display {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Cormorant Garamond', serif;
  font-size: 3.5rem;
  font-weight: 700;
  pointer-events: none;
  z-index: 300;
  opacity: 0;
  transition: opacity 0.2s;
}
#combo-display.active {
  opacity: 1;
  animation: comboFlash 0.8s ease forwards;
}
@keyframes comboFlash {
  0%   { transform: translate(-50%,-50%) scale(0.5); opacity: 0; }
  30%  { transform: translate(-50%,-50%) scale(1.3); opacity: 1; }
  70%  { transform: translate(-50%,-50%) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(1); opacity: 0; }
}

/* ─── Colorblind Mode ───────────────────────────── */
body.cb-mode canvas { filter: none; }

/* ─── Mobile touch shooter arrow hint ───────────── */
.touch-arrow {
  position: fixed;
  width: 60px; height: 60px;
  pointer-events: none;
  z-index: 60;
  opacity: 0;
  transition: opacity 0.2s;
}
.touch-arrow.visible { opacity: 0.7; }

/* ─── Scrollbars ────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 2px; }

/* ─── Score comparison grid (VS result) ─────────── */
.coop-scores {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0;
}
.coop-player {
  background: var(--bg3);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}
.coop-player h4 { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 6px; }
.coop-player .coop-val {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2.5rem;
  font-weight: 600;
  color: var(--accent);
}

/* ─── Mode select tabs ──────────────────────────── */
.tabs {
  display: flex; gap: 4px;
  background: var(--bg3);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 18px;
}
.tab {
  flex: 1;
  padding: 8px 12px;
  border-radius: 9px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  color: var(--text-muted);
  border: none;
  background: none;
}
.tab.active {
  background: var(--accent);
  color: #fff;
}

/* ─── Reduced motion ────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── Responsive tweaks ─────────────────────────── */
@media (max-width: 400px) {
  .panel { padding: 22px 18px; }
  .panel h1 { font-size: 2rem; }
  .level-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 390px) {
  /* Hide the Level box on narrow phones — it shows "#unlimited" which wastes space */
  #hud-center .hud-box:first-child { display: none; }
}

@media (max-width: 600px) {
  #hud.hud-unlimited #hud-center .hud-box:first-child { display: none; }
}

/* ─── Daily Challenge Badge ─────────────────────── */
.daily-badge {
  background: linear-gradient(135deg, #ff922b, #ffd43b);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #1a1a38;
  letter-spacing: 0.04em;
}

/* ─── Bubble type legend (tutorial / settings) ──── */
.bubble-legend {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 12px 0;
}
.legend-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.legend-dot {
  width: 20px; height: 20px; border-radius: 50%;
  flex-shrink: 0;
}

/* ─── VS Friend ─────────────────────────────────── */
.vs-code-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vs-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.vs-code-area {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: monospace;
  font-size: 0.68rem;
  line-height: 1.4;
  padding: 10px;
  resize: none;
  height: 76px;
  word-break: break-all;
  outline: none;
  display: block;
}
.vs-code-area:focus {
  border-color: var(--accent);
}

.vs-status {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
  min-height: 1.2em;
}

/* Opponent score in HUD — inherits .hud-box layout, just needs accent colour */
#vs-opponent-hud .hud-value {
  color: #ffd43b;
}

/* ─── Top-scores table ──────────────────────────── */
.scores-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.scores-table th, .scores-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.scores-table th { color: var(--text-muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; }
.scores-table tr:last-child td { border-bottom: none; }
.scores-table .rank { color: var(--accent); font-weight: 700; }
