/* ==========================================================================
   Sound Darts - Premium Arcade CSS System
   ========================================================================== */

:root {
  --bg-dark: #0b0e17;
  --bg-secondary: #131927;
  --bg-tertiary: #1c2536;
  --border-color: #2a364f;
  
  --accent-cyan: #06b6d4;
  --accent-cyan-hover: #0891b2;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --accent-amber: #f59e0b;
  --accent-purple: #a855f7;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

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;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

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

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

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

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

.sd-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

/* ── DASHBOARD LANDING ───────────────────────────────── */
.sd-dashboard-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
  width: 100%;
  flex: 1;
}

.dashboard-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.header-text h1 {
  font-size: 26px;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.03em;
}

.btn-create-game {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-cyan);
  color: #0f172a;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.btn-create-game:hover {
  background: var(--accent-cyan-hover);
  transform: translateY(-1px);
}

/* GRID & CARDS */
.sd-grid {
  padding-top: 6px;
  padding-bottom: 6px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.sd-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.2s ease;
  position: relative;
}

.sd-card:hover {
  border-color: rgba(6, 182, 212, 0.5);
  transform: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

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

.sd-card-preview {
  display: flex;
  gap: 4px;
  padding: 10px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: var(--radius-sm);
  height: 48px;
  align-items: center;
}

.sd-preview-tile {
  flex: 1;
  height: 100%;
  border-radius: 4px;
  opacity: 0.85;
}

.sd-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.btn-play-card {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent-cyan);
  color: #0f172a;
  font-weight: 800;
  font-size: 13px;
  padding: 9px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-play-card:hover {
  background: var(--accent-cyan-hover);
}

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

.btn-icon-card:hover {
  color: #fff;
  border-color: var(--text-muted);
}

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

/* ── CONFIG MODAL ────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 14, 23, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

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

.modal-header {
  padding: 18px 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;
}

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

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

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Custom Scrollbar for Modal Body */
.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: 13px;
  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-cyan);
}

.level-configs-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 4px;
}

.level-configs-container::-webkit-scrollbar {
  width: 5px;
}
.level-configs-container::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

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

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

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

.btn-secondary:hover {
  border-color: var(--text-muted);
}

.btn-primary {
  background: var(--accent-cyan);
  color: #0f172a;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
}

.btn-primary:hover {
  background: var(--accent-cyan-hover);
}

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

.game-main-area {
  flex: 1;
  background: #070a12;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  position: relative;
  padding: 0;
}

/* 16:9 Widescreen Game Arena Container */
.sd-play-area {
  width: 100%;
  height: 100%;
  background: #0f172a;
  border: none;
  border-radius: 0;
  position: relative;
  overflow: hidden;
  box-shadow: none;
}

/* ZERO-GAP SOUND TILES GRID */
.sound-tiles-grid {
  display: flex;
  width: 100%;
  height: 100%;
  gap: 0;
}

.sound-tile {
  flex: 1;
  height: 100%;
  position: relative;
  border-right: 3px solid #0f172a;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 28px;
  font-size: 24px;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.9);
  user-select: none;
  transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.15s ease, box-shadow 0.15s ease;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.3);
}

.sound-tile:last-child {
  border-right: none;
}

.sound-tile:active {
  transform: scaleY(0.98);
}

.sound-tile.lit {
  filter: brightness(2.2) drop-shadow(0 0 45px rgba(255, 255, 255, 0.9));
  transform: scale(1.05) translateY(-4px);
  z-index: 50;
  box-shadow: inset 0 0 80px rgba(255, 255, 255, 0.8), 0 0 50px currentColor;
  border-radius: 8px;
}

.sound-tile-label {
  font-size: 18px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(15, 23, 42, 0.6);
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* RIGHT SIDEBAR */
.game-sidebar-right {
  width: 280px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px;
}

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

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

.level-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;
  overflow-y: auto;
}

.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(6, 182, 212, 0.4);
  background: rgba(6, 182, 212, 0.1);
}

.attempt-log-card.miss {
  border-color: rgba(244, 63, 94, 0.4);
  background: rgba(244, 63, 94, 0.1);
}

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

.countdown-number {
  font-size: clamp(140px, 22vw, 260px);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.04em;
  color: #38bdf8;
  background: linear-gradient(180deg, #ffffff 0%, #38bdf8 50%, #0284c7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 15px 35px rgba(56, 189, 248, 0.7)) drop-shadow(0 8px 0 #0f172a);
  user-select: none;
}

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

@keyframes numPopOnce {
  0% { transform: scale(0.6); opacity: 0.3; }
  100% { transform: scale(1); opacity: 1; }
}

.countdown-title {
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.8);
}

/* Universal Modal & Input Full-Height Fix */
.modal-content {
  max-height: 90vh !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.modal-body {
  overflow-y: auto !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
}

.form-input {
  box-sizing: border-box !important;
  height: 44px !important;
  line-height: normal !important;
  font-family: inherit !important;
}


/* ========================================================================== */
/* 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; }
