/* ============================================================
   Color Flow - HTML5 Web Version Stylesheet
   Theme: Minimalist Cyber Dark (#0A0F1D) with Vibrant Neon Accents
   ============================================================ */

:root {
  --bg-main: #0A0F1D;
  --bg-surface: #131D31;
  --bg-card: #182238;
  --border-subtle: #1E293B;
  --border-active: #334155;
  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  
  /* Game Brand & Color Accents */
  --color-red: #EF4444;
  --color-orange: #F97316;
  --color-yellow: #EAB308;
  --color-green: #22C55E;
  --color-cyan: #06B6D4;
  --color-blue: #3B82F6;
  --color-purple: #A855F7;
  --color-pink: #EC4899;
  --color-lime: #84CC16;
  --color-teal: #14B8A6;

  --accent-primary: #38BDF8;
  --accent-glow: rgba(56, 189, 248, 0.35);
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 9999px;
  
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 15px rgba(56, 189, 248, 0.4);
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  touch-action: manipulation;
}

.app-container {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  position: relative;
  background-color: var(--bg-main);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
}

@media (min-width: 600px) {
  .app-container {
    height: 94vh;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
  }
}

/* Screens */
.screen {
  display: none;
  flex-direction: column;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
}

.screen.active {
  display: flex;
}

/* ============================================================
   LEVEL SELECT SCREEN
   ============================================================ */

.levels-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px 12px;
  background-color: var(--bg-main);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

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

.brand-logo {
  display: flex;
  gap: 4px;
}

.brand-logo .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
}

.dot-red { background-color: var(--color-red); color: var(--color-red); }
.dot-cyan { background-color: var(--color-cyan); color: var(--color-cyan); }
.dot-yellow { background-color: var(--color-yellow); color: var(--color-yellow); }

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #FFF 30%, #38BDF8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn, .nav-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover, .nav-btn:hover {
  background: #1C2945;
  border-color: var(--border-active);
  transform: translateY(-1px);
}

.svg-icon {
  width: 22px;
  height: 22px;
}

/* Progress Stats Card */
.progress-summary-card {
  margin: 12px 18px 8px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #131E33 0%, #15243F 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.progress-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.progress-stat .stat-value {
  font-size: 1rem;
  font-weight: 800;
  color: #38BDF8;
}

.progress-stat .stat-label {
  font-size: 0.68rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

.stat-divider {
  width: 1px;
  height: 24px;
  background: var(--border-subtle);
}

/* World / Tier Tabs */
.tiers-tab-bar {
  display: flex;
  gap: 8px;
  padding: 10px 18px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.tiers-tab-bar::-webkit-scrollbar {
  display: none;
}

.tier-tab {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tier-tab .tier-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.tier-tab:hover {
  color: var(--text-primary);
  border-color: var(--border-active);
}

.tier-tab.active {
  background: #1E2E4E;
  color: #FFF;
  border-color: #38BDF8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}

/* Tier Info Banner */
.tier-info-banner {
  margin: 4px 18px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tier-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(56, 189, 248, 0.15);
  color: #38BDF8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.tier-details {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  text-align: right;
}

/* Levels Grid */
.levels-grid-container {
  flex: 1;
  overflow-y: auto;
  padding: 0 18px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
}

.levels-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

@media (min-width: 400px) {
  .levels-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

.level-card {
  aspect-ratio: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.level-card:hover:not(.locked) {
  transform: translateY(-2px);
  border-color: #38BDF8;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.2);
}

.level-card .level-num {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.level-card .level-stars-row {
  display: flex;
  gap: 2px;
  margin-top: 4px;
  font-size: 0.65rem;
}

.level-card .star-empty {
  color: #334155;
}

.level-card .star-filled {
  color: #FACC15;
  text-shadow: 0 0 6px rgba(250, 204, 21, 0.5);
}

.level-card.locked {
  opacity: 0.45;
  cursor: not-allowed;
  background: #0E1524;
}

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

.level-card.current {
  border: 1.5px solid #38BDF8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
}

/* ============================================================
   ACTIVE GAME SCREEN
   ============================================================ */

.game-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px 8px;
}

.level-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.level-number-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.level-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.tier-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(56, 189, 248, 0.15);
  color: #38BDF8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.game-sub-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.meta-dot {
  color: var(--border-active);
}

.lifelines-container {
  display: flex;
  gap: 3px;
  font-size: 0.85rem;
}

.lifelines-container .heart {
  filter: grayscale(100%) opacity(0.3);
  transition: all 0.2s ease;
}

.lifelines-container .heart.active {
  filter: grayscale(0%) opacity(1);
  text-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
}

/* Floating Warning Toast */
.warning-toast {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: #E11D48;
  color: #FFF;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 15px rgba(225, 29, 72, 0.5);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.25s ease;
  pointer-events: none;
}

.warning-toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(-10px);
}

/* Minimalist Stats Pill */
.stats-pill {
  align-self: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 6px 20px;
  margin: 6px 0;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-pill-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #38BDF8;
  transition: background-color 0.2s ease;
}

.status-indicator.complete {
  background: #22C55E;
  box-shadow: 0 0 8px #22C55E;
}

.pill-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.pill-val {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
}

.pill-val.complete {
  color: #22C55E;
}

.pill-divider {
  width: 1px;
  height: 14px;
  background: var(--border-subtle);
}

/* Board Wrapper & High-DPI Canvas */
.board-wrapper {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px 16px;
  width: 100%;
}

.board-card {
  width: 100%;
  max-width: 420px;
  aspect-ratio: 1;
  background: #0E1626;
  border-radius: var(--radius-lg);
  border: 1px solid #1E293B;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6), 0 8px 24px rgba(0, 0, 0, 0.4);
  padding: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  touch-action: none;
}

#game-canvas {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-md);
  display: block;
  touch-action: none;
}

/* Bottom Controls */
.game-bottom-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px 20px;
  gap: 8px;
}

.ctrl-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  padding: 10px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 44px;
}

.ctrl-btn:hover {
  background: #1C2945;
  color: var(--text-primary);
  border-color: var(--border-active);
}

.ctrl-btn.highlight {
  background: linear-gradient(135deg, #0284C7 0%, #0369A1 100%);
  color: #FFF;
  border-color: #38BDF8;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
}

.ctrl-btn.highlight:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.ctrl-label {
  font-size: 0.78rem;
}

/* ============================================================
   MODALS & OVERLAYS
   ============================================================ */

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 15, 29, 0.85);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-surface);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-lg);
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  animation: modalPop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
  0% { transform: scale(0.92); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

#confetti-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.celebrate-pill {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: rgba(34, 197, 94, 0.2);
  color: #22C55E;
  border: 1px solid rgba(34, 197, 94, 0.4);
  margin-bottom: 8px;
}

.solved-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: #FFF;
}

.solved-header p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.stars-display {
  display: flex;
  gap: 10px;
  margin: 16px 0;
  font-size: 2.2rem;
}

.stars-display .star-icon {
  color: #FACC15;
  text-shadow: 0 0 16px rgba(250, 204, 21, 0.7);
  animation: starBounce 0.4s ease backwards;
}

.stars-display .star-icon:nth-child(2) { animation-delay: 0.1s; }
.stars-display .star-icon:nth-child(3) { animation-delay: 0.2s; }

.stars-display .star-icon.dim {
  color: #334155;
  text-shadow: none;
}

@keyframes starBounce {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.3); }
  100% { transform: scale(1); opacity: 1; }
}

.solved-stats-box {
  width: 100%;
  display: flex;
  justify-content: space-around;
  background: #0E1626;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 20px;
}

.modal-stat {
  display: flex;
  flex-direction: column;
}

.stat-number {
  font-size: 1.15rem;
  font-weight: 800;
  color: #FFF;
}

.stat-desc {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.modal-actions {
  width: 100%;
  display: flex;
  gap: 8px;
}

.btn {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  flex: 1;
}

.btn.primary {
  background: linear-gradient(135deg, #0284C7 0%, #0369A1 100%);
  color: #FFF;
  border: 1px solid #38BDF8;
  box-shadow: 0 4px 15px rgba(2, 132, 199, 0.4);
}

.btn.primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn.secondary {
  background: #1E293B;
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.btn.secondary:hover {
  background: #27354D;
}

.btn.full-width {
  width: 100%;
}

/* Lifeline Warning Modal */
.lifeline-icon-burst {
  font-size: 3rem;
  margin-bottom: 8px;
  animation: pulseBeat 1.2s infinite;
}

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

.warning-card h2 {
  font-size: 1.35rem;
  color: #EF4444;
  margin-bottom: 8px;
}

.warning-card p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 20px;
}

.highlight-glow {
  background: linear-gradient(135deg, #E11D48 0%, #BE123C 100%) !important;
  border-color: #FB7185 !important;
  box-shadow: 0 4px 15px rgba(225, 29, 72, 0.4) !important;
}

/* Help Modal */
.help-card h2 {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 16px;
  color: #FFF;
}

.help-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
  margin-bottom: 22px;
}

.help-rule {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.rule-icon {
  font-size: 1.2rem;
  background: #0E1626;
  padding: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  min-width: 36px;
  text-align: center;
}

.help-rule strong {
  font-size: 0.82rem;
  color: #F8FAFC;
  display: block;
  margin-bottom: 2px;
}

.help-rule p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.35;
}
