/* 
  Memory Matrix - Design System and Styles
  Dark mode theme with glassmorphism and electric neon cyan highlights.
*/

@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 300;
  font-stretch: normal;
  font-display: swap;
  src: url('fonts/fredoka-300.ttf') format('truetype');
}
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 400;
  font-stretch: normal;
  font-display: swap;
  src: url('fonts/fredoka-400.ttf') format('truetype');
}
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 500;
  font-stretch: normal;
  font-display: swap;
  src: url('fonts/fredoka-500.ttf') format('truetype');
}
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 600;
  font-stretch: normal;
  font-display: swap;
  src: url('fonts/fredoka-600.ttf') format('truetype');
}
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 700;
  font-stretch: normal;
  font-display: swap;
  src: url('fonts/fredoka-700.ttf') format('truetype');
}

:root {
  --font-main: 'Fredoka', system-ui, -apple-system, sans-serif;
  
  /* Dark Color Palette */
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #122c42 100%);
  --panel-bg: rgba(30, 41, 59, 0.45);
  --panel-border: rgba(255, 255, 255, 0.08);
  
  --primary: #00ccff;
  --primary-hover: #0099cc;
  --primary-glow: rgba(0, 204, 255, 0.25);
  --success: #00f5d4;
  --danger: #ff5e7e;
  --text-dark: #f8fafc;
  --text-light: #ffffff;
  --text-muted: #94a3b8;
  
  /* Shadows & Radius */
  --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 10px 25px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.4);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  
  /* Transitions */
  --transition-bounce: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --transition-smooth: all 0.2s ease;
}

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

html {
  scrollbar-gutter: stable;
}

body {
  font-family: var(--font-main);
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-x: hidden;
  padding: 1.5rem 1rem;
}

/* Floating background stars decorative */
body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(white, rgba(255,255,255,.15) 1.5px, transparent 20px),
    radial-gradient(white, rgba(255,255,255,.1) 1px, transparent 15px);
  background-size: 400px 400px, 250px 250px;
  background-position: 0 0, 50px 70px;
  opacity: 0.25;
  z-index: -1;
  pointer-events: none;
}

/* Header & Navigation */
header {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.logo-icon {
  font-size: 2.8rem;
  animation: float 3s ease-in-out infinite;
  filter: drop-shadow(0 0 10px var(--primary));
}

h1 {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-light);
  text-shadow: 0 0 15px rgba(0, 204, 255, 0.4), 2px 2px 0px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.5px;
}

nav {
  display: flex;
  background: var(--panel-bg);
  padding: 0.4rem;
  border-radius: 50px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--panel-border);
  gap: 0.4rem;
  width: 100%;
  max-width: 480px;
  backdrop-filter: blur(15px);
}

nav button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.65rem 1rem;
  border-radius: 50px;
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-bounce);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

nav button.active {
  background: var(--primary);
  color: #0f172a;
  box-shadow: 0 4px 15px var(--primary-glow);
  transform: scale(1.03);
  font-weight: 700;
}

nav button:hover:not(.active) {
  background: rgba(0, 204, 255, 0.08);
  color: var(--primary);
}

/* Main Content Containers */
main {
  width: 100%;
  max-width: 900px;
  flex-grow: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  margin-bottom: 2rem;
}

.screen {
  width: 100%;
  display: none;
  animation: slideIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.1) forwards;
}

.screen.active {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

/* Cards & Layout Panels */
.card {
  background: var(--panel-bg);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(15px);
  position: relative;
}

/* User Progress Bar Dashboard */
.progress-bar-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--panel-bg);
  padding: 0.8rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--panel-border);
  flex-wrap: wrap;
  width: 100%;
}

.progress-stat {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 1.15rem;
  font-weight: 700;
}

.stat-icon {
  font-size: 1.4rem;
}

.star-count {
  color: #ffbe0b;
}

.streak-count {
  color: #ff5e7e;
}

/* Welcome Screen */
.welcome-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  text-align: center;
}

.welcome-mascot {
  font-size: 4.5rem;
  animation: float 4s ease-in-out infinite;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.3));
}

.welcome-title {
  font-size: 1.8rem;
  color: var(--text-light);
}

.welcome-text {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 580px;
  line-height: 1.5;
}

/* Game Modes Selection Layout */
.game-modes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
  width: 100%;
  margin-top: 1rem;
}

.mode-btn {
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 1.5rem 1rem;
  cursor: pointer;
  transition: var(--transition-bounce);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  text-align: center;
  color: var(--text-light);
}

.mode-btn:hover {
  transform: translateY(-8px);
  background: rgba(30, 41, 59, 0.6);
}

.mode-btn.easy-grid:hover {
  border-color: #00f5d4;
  box-shadow: 0 10px 25px rgba(0, 245, 212, 0.15);
}

.mode-btn.medium-grid:hover {
  border-color: #00ccff;
  box-shadow: 0 10px 25px rgba(0, 204, 255, 0.15);
}

.mode-btn.hard-grid:hover {
  border-color: #a29bfe;
  box-shadow: 0 10px 25px rgba(162, 155, 254, 0.15);
}

.mode-icon {
  font-size: 2.8rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.mode-name {
  font-size: 1.3rem;
  font-weight: 700;
}

.mode-btn.easy-grid .mode-name { color: #00f5d4; }
.mode-btn.medium-grid .mode-name { color: #00ccff; }
.mode-btn.hard-grid .mode-name { color: #a29bfe; }

.mode-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Active Game Play Screen Header */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 0.8rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.back-btn {
  border: 1px solid var(--panel-border);
  background: rgba(15, 23, 42, 0.3);
  color: var(--text-light);
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 0.8rem;
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--text-light);
}

.level-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-light);
}

.round-progress {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Active Level Game Layout */
.game-body {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 2rem;
}

.left-play-area {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

/* Round Progress Dots Tracker */
#round-dots-tracker {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
}

.tracker-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: rgba(15, 23, 42, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-bounce);
}

.tracker-dot.dot-correct {
  background: var(--success);
  border-color: var(--success);
}

.tracker-dot.dot-incorrect {
  background: var(--danger);
  border-color: var(--danger);
  animation: shake 0.3s ease;
}

.tracker-dot-icon {
  font-size: 0.75rem;
  font-weight: 800;
  color: #0f172a;
}

/* Status Banner Instruction display */
.status-banner {
  width: 100%;
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.3);
  border: 1px solid var(--panel-border);
  text-align: center;
}

#status-instruction-text {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  transition: var(--transition-smooth);
}

#status-instruction-text.prepare { color: #ffbe0b; }
#status-instruction-text.watch { color: #00ccff; }
#status-instruction-text.play { color: #00f5d4; }
#status-instruction-text.success { color: #00f5d4; }
#status-instruction-text.fail { color: #ff5e7e; }

/* Memory Board Grid Container */
.board-area {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin-top: 0.5rem;
}

#matrix-grid-board {
  aspect-ratio: 1 / 1;
  max-width: 400px;
  width: 100%;
  display: grid;
  gap: 0.5rem;
  background: rgba(15, 23, 42, 0.4);
  border: 1.5px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 0.6rem;
  box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.3);
}

#matrix-grid-board.grid-3x3 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}

#matrix-grid-board.grid-4x4 {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
}

#matrix-grid-board.grid-5x5 {
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
}

/* Individual Tiles */
.matrix-tile {
  background: rgba(30, 41, 59, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  overflow: hidden;
}

.matrix-tile:hover:not(.locked) {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(0, 204, 255, 0.25);
}

.matrix-tile.locked {
  cursor: not-allowed;
}

/* Flash active states */
.matrix-tile.active-flash {
  background: #00ccff !important;
  box-shadow: 0 0 18px #00ccff, inset 0 0 10px #ffffff;
  border-color: #00ccff !important;
}

.matrix-tile.correct-flash {
  background: #00f5d4 !important;
  box-shadow: 0 0 18px #00f5d4, inset 0 0 10px #ffffff;
  border-color: #00f5d4 !important;
}

.matrix-tile.incorrect-flash {
  background: #ff5e7e !important;
  box-shadow: 0 0 18px #ff5e7e, inset 0 0 10px #ffffff;
  border-color: #ff5e7e !important;
  animation: shake 0.25s ease;
}

/* Mascot character Sidebar Layout */
.mascot-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  justify-content: flex-start;
  padding-top: 1rem;
}

.speech-bubble {
  position: relative;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-size: 0.95rem;
  color: var(--text-dark);
  line-height: 1.45;
  text-align: center;
  width: 100%;
}

.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 10px 10px 0;
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.05) transparent;
  display: block;
  width: 0;
}

.mascot-character {
  font-size: 5.5rem;
  animation: float 4s ease-in-out infinite;
  filter: drop-shadow(0 6px 15px rgba(0,0,0,0.4));
  cursor: pointer;
}

/* Sticker Album page */
.sticker-book-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sticker-header {
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 0.8rem;
}

.sticker-header h2 {
  font-size: 1.7rem;
  color: var(--text-light);
  margin-bottom: 0.3rem;
}

.sticker-header p {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1.2rem;
  width: 100%;
}

.sticker-slot {
  background: rgba(15, 23, 42, 0.35);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  position: relative;
  overflow: hidden;
  min-height: 140px;
  justify-content: center;
}

.sticker-slot.unlocked {
  background: rgba(255, 255, 255, 0.03);
  transform: rotate(var(--rotation, 0deg));
  border-color: rgba(0, 204, 255, 0.15);
  box-shadow: 0 4px 12px rgba(0, 204, 255, 0.05);
}

.sticker-visual {
  font-size: 3.2rem;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.sticker-name {
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  color: var(--text-light);
}

/* Lock overlays */
.lock-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  backdrop-filter: blur(2px);
}

.lock-overlay:hover {
  background: rgba(15, 23, 42, 0.6);
}

.lock-icon {
  font-size: 1.6rem;
}

.lock-cost {
  font-size: 0.85rem;
  font-weight: 700;
  color: #ffbe0b;
}

/* Settings Controls Panel styling */
.settings-container {
  display: flex;
  flex-direction: column;
  gap: 1.8rem;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 1.5rem;
}

.settings-section:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.settings-section h3 {
  font-size: 1.15rem;
  color: var(--text-light);
  font-weight: 700;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  width: 100%;
}

.setting-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-light);
}

.setting-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 0.15rem;
}

/* Toggle Switches */
.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(71, 85, 105, 0.8);
  transition: .3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(24px);
}

/* Button Selection Groups */
.btn-group {
  display: flex;
  border: 1px solid var(--panel-border);
  border-radius: 50px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.3);
}

.btn-group button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-group button.active {
  background: var(--primary);
  color: #0f172a;
}

.btn-group button:hover:not(.active) {
  background: rgba(0, 204, 255, 0.08);
}

.reset-btn {
  background: var(--danger);
  border: none;
  border-radius: 50px;
  color: var(--text-light);
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.6rem 1.2rem;
  cursor: pointer;
  transition: var(--transition-bounce);
  box-shadow: 0 3px 0 #b32b47;
}

.reset-btn:hover {
  background: #e04b68;
}

.reset-btn:active {
  transform: scale(0.97);
}

/* Dialog Overlay Modals */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100000;
  backdrop-filter: blur(8px);
}

.overlay.active {
  display: flex;
}

.modal {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 2.2rem;
  max-width: 420px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.2rem;
  box-shadow: var(--shadow-lg);
  animation: modalEnter 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.modal-mascot {
  font-size: 4.5rem;
  animation: float 3s ease-in-out infinite;
}

.modal-title {
  font-size: 1.6rem;
  color: var(--text-light);
}

.modal-text {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.modal-stars {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ffbe0b;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-primary {
  background: var(--primary);
  color: #0f172a;
  border: none;
  border-radius: 50px;
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 700;
  padding: 0.75rem 1.8rem;
  cursor: pointer;
  transition: var(--transition-bounce);
  box-shadow: 0 3px 0 #0099cc;
  width: 100%;
}

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

.btn-primary:active {
  transform: scale(0.97);
}

.confirm-modal-buttons {
  display: flex;
  gap: 0.8rem;
  width: 100%;
}

.confirm-modal-buttons button {
  flex: 1;
}

/* Animations Keyframes definitions */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

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

/* Mobile & Tablet Adjustments rules */
@media (max-width: 768px) {
  .game-body {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .mascot-area {
    display: none; /* Hide side panel to give active screen maximum space */
  }
  
  .card {
    padding: 1.2rem;
  }
}
