@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
  --bg-dark: #090d16;
  --bg-primary: #0b0f19;
  --bg-secondary: #131b2e;
  --bg-tertiary: #1c2742;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.18);
  
  --text-main: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-pink: #ec4899;
  --accent-purple: #a855f7;
  --accent-gold: #eab308;
  --accent-rose: #f43f5e;
  --accent-emerald: #10b981;
  --accent-cyan: #06b6d4;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

/* Frameless Color Swatch Picker */
input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  padding: 0;
  overflow: hidden;
}
input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: 6px;
}
input[type="color"]::-webkit-color-swatch {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-dark);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* HEADER */
header.bp-header {
  height: 60px;
  padding: 0 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-back-hub {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.btn-back-hub:hover {
  color: #fff;
  border-color: var(--accent-pink);
}

.bp-title {
  font-size: 18px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.02em;
}

/* STUDIO DASHBOARD */
.bp-dashboard-container {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
  flex: 1;
}

.dashboard-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.section-title-group h1 {
  font-size: 24px;
  font-weight: 800;
  color: #fff;
}

.section-title-group p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.btn-create-game {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: linear-gradient(135deg, #ec4899 0%, #a855f7 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(236, 72, 153, 0.35);
  transition: all 0.15s ease;
}

.btn-create-game:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(236, 72, 153, 0.5);
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.bp-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: all 0.15s ease;
}

.bp-card:hover {
  border-color: rgba(236, 72, 153, 0.4);
  transform: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.bp-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bp-card-title {
  font-size: 17px;
  font-weight: 800;
  color: #fff;
}

.bp-card-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-chip {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.bp-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.btn-play {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--accent-pink);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-play:hover {
  background: #db2777;
}

.btn-edit-card, .btn-delete-card {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-edit-card:hover {
  color: #fff;
  border-color: var(--accent-pink);
}

.btn-delete-card:hover {
  color: var(--accent-rose);
  border-color: var(--accent-rose);
}

/* CONFIGURATOR MODAL */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 740px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

#balloonsContainer {
  overflow: visible !important;
  max-height: none !important;
}
#balloonsContainer::-webkit-scrollbar {
  width: 6px;
}
#balloonsContainer::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 4px;
}
#balloonsContainer::-webkit-scrollbar-thumb {
  background: rgba(236, 72, 153, 0.4);
  border-radius: 4px;
}
#balloonsContainer::-webkit-scrollbar-thumb:hover {
  background: rgba(236, 72, 153, 0.7);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}

.modal-close-btn:hover {
  color: #fff;
}

.modal-body {
  padding: 24px;
  overflow-y: auto !important;
  flex: 1 1 auto;
  min-height: 0;
  max-height: calc(88vh - 130px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}
.modal-body::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.5);
}
.modal-body::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
}

.form-input {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent-pink);
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: rgba(15, 23, 42, 0.4);
}

.btn-secondary {
  padding: 10px 18px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.btn-secondary:hover {
  color: #fff;
}

/* ── GAMEPLAY ARENA ──────────────────────────────────── */
.game-workspace {
  display: flex;
  flex: 1;
  height: calc(100vh - 60px);
  overflow: hidden;
}

.game-main-area {
  flex: 1;
  position: relative;
  background: var(--bg-primary);
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  overflow: hidden;
  background-image: radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 24px 24px;
}

.bp-play-area {
  position: relative;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #111827 0%, #030712 100%);
  border: none;
  border-radius: 0;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}

/* ── BALLOON & BOMB OBJECT SYSTEM ─────────────────────── */
.balloon-wrapper {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  user-select: none;
  will-change: transform;
  transform-origin: center top;
}

/* Balloon Body */
.balloon-body {
  width: 100%;
  height: 100%;
  border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
  position: relative;
  box-shadow: inset -10px -10px 20px rgba(0, 0, 0, 0.4), 0 10px 25px rgba(0, 0, 0, 0.5);
  transition: transform 0.08s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Specular Gloss Highlight */
.balloon-body::before {
  content: '';
  position: absolute;
  top: 12%;
  left: 18%;
  width: 28%;
  height: 28%;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  transform: rotate(-30deg);
  filter: blur(1px);
}

/* Balloon Knot */
.balloon-body::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 8px solid inherit;
  border-bottom-color: inherit;
}

/* Wavy Animated String Tail */
.balloon-string-svg {
  width: 24px;
  height: 45px;
  margin-top: 4px;
  overflow: visible;
  animation: wavyString 2s ease-in-out infinite alternate;
}

@keyframes wavyString {
  0% { transform: rotate(-5deg); }
  50% { transform: rotate(5deg); }
  100% { transform: rotate(-5deg); }
}

/* SPECIAL GOLDEN BALLOON */
.balloon-body.special {
  background: radial-gradient(circle at 35% 35%, #fffde7 0%, #facc15 45%, #eab308 75%, #ca8a04 100%) !important;
  box-shadow: 0 0 40px #facc15, 0 0 80px rgba(234, 179, 8, 0.8), inset -12px -12px 24px rgba(0, 0, 0, 0.4);
  animation: specialPulseGlow 0.9s ease-in-out infinite alternate !important;
}

.balloon-body.special::after {
  border-bottom-color: #ca8a04 !important;
}

@keyframes specialPulseGlow {
  0% {
    transform: scale(1);
    filter: brightness(1) drop-shadow(0 0 15px #facc15);
  }
  100% {
    transform: scale(1.1);
    filter: brightness(1.4) drop-shadow(0 0 35px #fef08a);
  }
}

/* BOMB BALLOON */
.balloon-body.bomb {
  width: 100%;
  height: 100%;
  border-radius: 50% !important;
  background: radial-gradient(circle at 35% 35%, #475569 0%, #0f172a 70%, #020617 100%) !important;
  box-shadow: 0 0 30px rgba(244, 63, 94, 0.6), inset -8px -8px 15px rgba(0, 0, 0, 0.8) !important;
  border: 3px solid #f43f5e;
}

/* Bomb Lit Fuse */
.bomb-fuse {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 14px;
  background: #78350f;
  border-radius: 3px;
}

.bomb-spark {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  background: #f97316;
  border-radius: 50%;
  box-shadow: 0 0 12px #ef4444, 0 0 20px #eab308;
  animation: fuseSpark 0.2s ease-in-out infinite alternate;
}

@keyframes fuseSpark {
  0% { transform: translateX(-50%) scale(0.8); opacity: 0.7; }
  100% { transform: translateX(-50%) scale(1.4); opacity: 1; }
}

/* POP PARTICLE EFFECT */
.pop-particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  animation: popParticle 0.45s ease-out forwards;
}

@keyframes popParticle {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}

/* ── BOMB EXPLOSION ANIMATIONS ───────────────────────── */
.screen-shake {
  animation: arenaScreenShake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes arenaScreenShake {
  10%, 90% { transform: translate3d(-4px, 2px, 0); }
  20%, 80% { transform: translate3d(6px, -4px, 0); }
  30%, 50%, 70% { transform: translate3d(-8px, 6px, 0); }
  40%, 60% { transform: translate3d(8px, -6px, 0); }
}

.bomb-explosion-flash {
  position: absolute;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0%, #ff5722 30%, #ef4444 65%, transparent 100%);
  pointer-events: none;
  z-index: 400;
  transform: translate(-50%, -50%) scale(0.2);
  animation: explosionFlash 0.5s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

@keyframes explosionFlash {
  0% { transform: translate(-50%, -50%) scale(0.1); opacity: 1; filter: brightness(2); }
  50% { transform: translate(-50%, -50%) scale(1.2); opacity: 0.9; }
  100% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; filter: brightness(1); }
}

.bomb-shockwave-ring {
  position: absolute;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 6px solid #f97316;
  box-shadow: 0 0 30px #f97316, inset 0 0 20px #ef4444;
  pointer-events: none;
  z-index: 399;
  transform: translate(-50%, -50%) scale(0.2);
  animation: shockwaveRing 0.55s ease-out forwards;
}

@keyframes shockwaveRing {
  0% { transform: translate(-50%, -50%) scale(0.2); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(4.5); opacity: 0; border-width: 1px; }
}

.bomb-fire-shard {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 401;
  animation: fireShardFly 0.5s cubic-bezier(0.15, 0.85, 0.35, 1.2) forwards;
}

@keyframes fireShardFly {
  0% { transform: translate(0, 0) scale(1.2); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}

/* ── CONFETTI BURST ANIMATION (SPECIAL BALLOON) ──────── */
.confetti-piece {
  position: absolute;
  pointer-events: none;
  z-index: 402;
  will-change: transform;
  animation: confettiBurst 0.85s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes confettiBurst {
  0% {
    transform: translate(0, 0) rotateX(0deg) rotateY(0deg) rotateZ(0deg) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) rotateX(720deg) rotateY(360deg) rotateZ(180deg) scale(0.3);
    opacity: 0;
  }
}

/* ── SIDEBAR ─────────────────────────────────────────── */
.game-sidebar-right {
  width: 320px;
  height: 100%;
  max-height: calc(100vh - 60px);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

.sidebar-big-num {
  font-size: 36px;
  font-weight: 900;
  color: var(--accent-pink);
  line-height: 1;
}

.sidebar-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 4px;
}

.attempts-log-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

/* Custom Styled Scrollbar for Log List */
.attempts-log-list::-webkit-scrollbar {
  width: 5px;
}
.attempts-log-list::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 4px;
}
.attempts-log-list::-webkit-scrollbar-thumb {
  background: rgba(236, 72, 153, 0.4);
  border-radius: 4px;
}
.attempts-log-list::-webkit-scrollbar-thumb:hover {
  background: rgba(236, 72, 153, 0.7);
}

.attempt-log-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.attempt-log-card.success {
  border-color: rgba(236, 72, 153, 0.4);
  background: rgba(236, 72, 153, 0.1);
}

.attempt-log-card.special {
  border-color: rgba(234, 179, 8, 0.5);
  background: rgba(234, 179, 8, 0.15);
}

.attempt-log-card.bomb {
  border-color: rgba(244, 63, 94, 0.5);
  background: rgba(244, 63, 94, 0.15);
}

/* OVERLAYS */
.countdown-overlay {
  position: absolute;
  inset: 0;
  background: rgba(9, 13, 22, 0.93);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.countdown-title {
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.countdown-number {
  font-size: 260px;
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(180deg, #ffffff 0%, #ec4899 50%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 50px rgba(236, 72, 153, 0.8));
  user-select: none;
}

.countdown-number.pop {
  animation: arcadeNumberPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes arcadeNumberPop {
  0% { transform: scale(0.4); opacity: 0; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}


/* ========================================================================== */
/* FLAWLESS FULL-HEIGHT SCROLLABLE MODAL SYSTEM                               */
/* ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 13, 0.85);
  backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px 16px;
}

.modal-content {
  background: #0f1424;
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75);
  overflow: hidden;
  margin: auto;
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: #0f1424;
}

.modal-body {
  padding: 22px 24px;
  overflow-y: auto !important;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
  max-height: calc(90vh - 130px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-shrink: 0;
  background: rgba(10, 14, 26, 0.8);
}

/* Custom Scrollbar on Modal Body */
.modal-body::-webkit-scrollbar {
  width: 7px;
}
.modal-body::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
}
.modal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 6px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.7);
}

/* Ensure all inner item lists expand naturally without internal nested cutoff */
#balloonsContainer, .bal-sections-wrapper,
#discountsContainer, #discountsList,
#fishesContainer, #fishesList,
#recipesContainer, #recipesList,
#ingredientsContainer, #ingredientsList,
#normalBalloonsList, #specialBalloonsList, #bombBalloonsList {
  max-height: none !important;
  overflow: visible !important;
  height: auto !important;
}

.form-input, input[type="text"].form-input, input[type="number"].form-input {
  box-sizing: border-box;
  height: 44px;
  line-height: normal;
  font-family: inherit;
}

.modal-body > * { flex-shrink: 0; }
