/* --- Pastel Connect CSS Design System --- */

:root {
  /* Cute Pastel Theme Color Tokens */
  --color-pink: #ff9aa2;
  --color-peach: #ffb7b2;
  --color-yellow: #ffd97d;
  --color-mint: #b5ead7;
  --color-blue: #97c1a9;
  --color-lavender: #c7ceea;
  --color-purple: #e8aeff;
  
  --bg-gradient: linear-gradient(135deg, #fff0f3 0%, #f0f4ff 100%);
  --text-primary: #5c4e5e;
  --text-muted: #8c7a8e;
  --card-bg: rgba(255, 255, 255, 0.55);
  --card-border: rgba(255, 255, 255, 0.8);
  --card-shadow: 0 8px 32px 0 rgba(242, 203, 210, 0.37);
  --font-family: 'Nunito', 'Outfit', system-ui, -apple-system, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-family);
  color: var(--text-primary);
  background: var(--bg-gradient);
}

/* --- Floating Background Elements --- */
.floating-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.floating-shape {
  position: absolute;
  bottom: -50px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  animation: floatUp 15s linear infinite;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 20px;
  opacity: 0.5;
}

@keyframes floatUp {
  0% {
    transform: translateY(0) rotate(0deg) scale(0.8);
    opacity: 0;
  }
  10% {
    opacity: 0.5;
  }
  90% {
    opacity: 0.5;
  }
  100% {
    transform: translateY(-110vh) rotate(360deg) scale(1.2);
    opacity: 0;
  }
}

/* --- App Container & Navigation --- */
.app-container {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100%;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1;
}

/* Screen visibility classes */
.screen {
  display: none;
  width: 100%;
  height: 100%;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  animation: fadeIn 0.4s ease;
}

.screen.active {
  display: flex;
}

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

/* --- Buttons & UI Elements --- */
.btn {
  width: 100%;
  padding: 16px 28px;
  font-family: var(--font-family);
  font-size: 1.15rem;
  font-weight: 800;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 4px 15px rgba(255, 154, 162, 0.2);
  outline: none;
  text-align: center;
}

.btn-primary {
  background: linear-gradient(135deg, #ff9aa2 0%, #ffb7b2 100%);
  color: white;
  text-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.btn-secondary {
  background: white;
  color: var(--text-primary);
  border: 2px solid #ffe3e5;
}

.btn-info {
  background: linear-gradient(135deg, #c7ceea 0%, #b5ead7 100%);
  color: #4a587d;
}

.btn:hover, .btn:active {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(255, 154, 162, 0.35);
}

.btn:active {
  transform: translateY(1px);
}

.btn-bounce {
  animation: pulseBounce 2s infinite;
}

@keyframes pulseBounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

/* Rounded Header Button */
.btn-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: white;
  border: none;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-circle-sm {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: white;
  border: none;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(0,0,0,0.05);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-circle:active, .btn-circle-sm:active {
  transform: scale(0.92);
}

/* --- 1. HOME SCREEN --- */
#home-screen {
  justify-content: space-around;
  padding: 40px 10px;
}

.logo-container {
  text-align: center;
}

.logo-hearts {
  font-size: 2.2rem;
  margin-bottom: 12px;
  letter-spacing: 8px;
  animation: floatMini 3s ease-in-out infinite alternate;
}

@keyframes floatMini {
  0% { transform: translateY(0); }
  100% { transform: translateY(-8px); }
}

.game-title {
  font-family: 'Outfit', sans-serif;
  font-size: 3rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ff9aa2 0%, #e8aeff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 5px rgba(255, 154, 162, 0.2));
  letter-spacing: -1px;
}

.game-subtitle {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 4px;
  margin-top: 4px;
}

.menu-container {
  width: 100%;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.home-footer {
  font-weight: 700;
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  padding: 8px 20px;
  border-radius: 50px;
  box-shadow: var(--card-shadow);
  color: var(--text-primary);
  backdrop-filter: blur(10px);
}

/* --- 2. LEVEL SELECT SCREEN --- */
.screen-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.screen-header h2 {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
}

.stars-counter {
  font-weight: 800;
  background: white;
  padding: 6px 14px;
  border-radius: 50px;
  box-shadow: 0 4px 10px rgba(255, 217, 125, 0.2);
  border: 1.5px solid #fff5da;
}

.levels-grid {
  flex-grow: 1;
  width: 100%;
  overflow-y: auto;
  padding: 10px 5px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  align-content: start;
}

/* Custom scrollbar for levels list */
.levels-grid::-webkit-scrollbar {
  width: 6px;
}
.levels-grid::-webkit-scrollbar-track {
  background: transparent;
}
.levels-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 154, 162, 0.25);
  border-radius: 50px;
}

.level-card {
  aspect-ratio: 1 / 1;
  background: var(--card-bg);
  border: 2px solid var(--card-border);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0,0,0,0.02);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.level-card:hover {
  transform: translateY(-2px);
  border-color: var(--color-peach);
  box-shadow: 0 5px 12px rgba(255, 154, 162, 0.15);
}

.level-card:active {
  transform: scale(0.95);
}

.level-number {
  font-family: 'Outfit', sans-serif;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-primary);
}

.level-size {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 1px;
}

.level-card-stars {
  font-size: 0.65rem;
  margin-top: 4px;
  letter-spacing: -1px;
}

.level-card.locked {
  opacity: 0.6;
  background: rgba(230, 230, 235, 0.4);
  border: 2px dashed rgba(0,0,0,0.08);
  box-shadow: none;
  cursor: not-allowed;
}

.level-card.locked:hover {
  transform: none;
  border-color: rgba(0,0,0,0.08);
  box-shadow: none;
}

.level-card.locked .level-number,
.level-card.locked .level-size {
  display: none;
}

.level-card-lock-icon {
  font-size: 1.2rem;
  color: var(--text-muted);
}

/* --- 3. GAME SCREEN --- */
.game-hud {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.level-info {
  text-align: center;
}

.level-info h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
}

.hud-stars {
  font-size: 0.8rem;
  letter-spacing: 2px;
  margin-top: -2px;
}

.hud-right {
  display: flex;
  gap: 8px;
}

.hidden {
  display: none !important;
}

/* HUD STATS ROW */
.game-stats {
  width: 100%;
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.stat-card {
  flex: 1;
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 15px rgba(242, 203, 210, 0.2);
  border-radius: 15px;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
}

/* GAME BOARD CONTAINER */
.board-outer-container {
  flex-grow: 1;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 15px;
  padding: 5px;
}

.board-wrapper {
  width: 100%;
  max-width: 380px;
  aspect-ratio: 1 / 1;
  background: var(--card-bg);
  border: 3px solid var(--card-border);
  border-radius: 24px;
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
  padding: 6px;
}

/* Cells Grid */
.cells-grid {
  display: grid;
  width: 100%;
  height: 100%;
  gap: 6px;
}

.board-cell {
  background: rgba(255, 255, 255, 0.4);
  border: 1px dashed rgba(255, 154, 162, 0.12);
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  z-index: 1;
  transition: background-color 0.2s ease;
}

/* Dot/Node element inside cell */
.node-block {
  width: 70%;
  height: 70%;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 2;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.node-block:active {
  transform: scale(1.15);
}

.node-block.connected {
  animation: heartbeat 2s infinite alternate;
}

@keyframes heartbeat {
  0% { transform: scale(1); }
  100% { transform: scale(1.08); }
}

/* Canvas Overlays */
.connections-canvas,
.particles-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.connections-canvas {
  z-index: 2;
}

.particles-canvas {
  z-index: 3;
}

/* Game Info Footer */
.game-footer {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 0.88rem;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.4);
  border: 1.5px solid var(--card-border);
  border-radius: 16px;
  margin-bottom: 5px;
}

.connections-progress, .board-fill-progress {
  color: var(--text-primary);
}

/* --- MODAL DIALOGS --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(92, 78, 94, 0.35);
  backdrop-filter: blur(6px);
  z-index: 99;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 340px;
  background: rgba(255, 255, 255, 0.9);
  border: 3px solid white;
  border-radius: 28px;
  box-shadow: 0 15px 45px rgba(92, 78, 94, 0.2);
  padding: 30px 24px;
  text-align: center;
  position: relative;
}

.modal-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 15px;
}

.modal-content {
  text-align: left;
  font-size: 0.92rem;
  line-height: 1.6;
  color: #665668;
  margin-bottom: 25px;
}

.modal-content p {
  margin-bottom: 12px;
}

.modal-content strong {
  color: var(--color-pink);
}

/* WIN SPECIAL CARD */
.win-card {
  background: linear-gradient(to bottom, #ffffff, #fff0f3);
}

.win-sparkles {
  font-size: 1.8rem;
  margin-bottom: 10px;
  animation: floatMini 2s infinite alternate;
}

.win-message {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.win-stars {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 22px;
}

.star-large {
  font-size: 2.8rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.05));
  opacity: 0.2;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.star-large.active {
  opacity: 1;
  transform: scale(1.15);
  filter: drop-shadow(0 4px 10px rgba(255, 217, 125, 0.6));
}

.win-stats-summary {
  background: white;
  border-radius: 18px;
  padding: 12px 18px;
  border: 1px solid #ffe5e8;
  margin-bottom: 25px;
}

.win-stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  padding: 6px 0;
}

.win-stat-row:not(:last-child) {
  border-bottom: 1px dashed #fce8eb;
}

.win-stat-row span {
  color: var(--text-muted);
}

.win-stat-row strong {
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
}

#win-pb-row {
  display: none;
  justify-content: center;
  color: #ff9aa2;
  font-weight: 800;
  font-size: 0.9rem;
  animation: pulse 1s infinite alternate;
  padding-top: 8px;
}

@keyframes pulse {
  from { transform: scale(0.98); }
  to { transform: scale(1.02); }
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-actions .btn {
  padding: 12px 20px;
  font-size: 1rem;
}

.scale-in {
  animation: scaleIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}
