/* =========================================================
   EMOJI MATCH - MASTER STYLESHEET
   ========================================================= */

:root {
  --primary-teal: #00a896;
  --card-bg-gradient: linear-gradient(145deg, #00b4d8 0%, #009688 50%, #028090 100%);
  --card-border: rgba(255, 255, 255, 0.4);
  --cell-bg: #f4f6f8;
  --cell-border: #d0dbe5;
  --cell-hover: #e2e8f0;
  
  --btn-green-top: #38b000;
  --btn-green-bottom: #007200;
  --btn-green-shadow: #004b00;
  
  --gold-text-gradient: linear-gradient(180deg, #fff3b0 0%, #ffbe0b 50%, #fb8500 100%);
  --text-shadow-3d: 0 4px 0 #9d4edd, 0 6px 12px rgba(0, 0, 0, 0.35);
  
  --font-main: 'Fredoka', 'Outfit', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji', system-ui, sans-serif;
  --font-display: 'Fredoka', cursive, 'Apple Color Emoji', 'Segoe UI Emoji', sans-serif;
}

/* Twemoji and Emoji Vector Styling to prevent missing boxes */
.game-svg-icon {
  width: 72%;
  height: 72%;
  display: block;
  pointer-events: none;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.25));
}

.cell-emoji {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  pointer-events: none;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

img.emoji {
  width: 2.2em;
  height: 2.2em;
  vertical-align: -0.1em;
  pointer-events: none;
  display: inline-block;
  user-select: none;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.22));
}

.preview-cell img.emoji {
  width: 2.1em;
  height: 2.1em;
}

.grid-3x3 .cell img.emoji {
  width: 2.2em;
  height: 2.2em;
}

.grid-4x4 .cell img.emoji {
  width: 1.85em;
  height: 1.85em;
}

.grid-5x5 .cell img.emoji {
  width: 1.5em;
  height: 1.5em;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body {
  font-family: var(--font-main);
  background: radial-gradient(circle at 50% 20%, #70a1ff 0%, #474787 50%, #2c2c54 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  color: #2d3748;
}

/* Background floating particles */
.bg-effects {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-emoji {
  position: absolute;
  font-size: 2rem;
  opacity: 0.15;
  filter: blur(1px);
  animation: floatUp 14s infinite linear;
}

@keyframes floatUp {
  0% {
    transform: translateY(105vh) rotate(0deg) scale(0.8);
    opacity: 0;
  }
  20% {
    opacity: 0.18;
  }
  80% {
    opacity: 0.18;
  }
  100% {
    transform: translateY(-10vh) rotate(360deg) scale(1.1);
    opacity: 0;
  }
}

/* App Container */
.app-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

/* Game Screens */
.game-screen {
  display: none;
  width: 100%;
  flex-direction: column;
  align-items: center;
  animation: fadeInScale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.game-screen.active {
  display: flex;
}

@keyframes fadeInScale {
  0% {
    opacity: 0;
    transform: scale(0.92) translateY(10px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* =========================================================
   THE SIGNATURE TEAL CARD (MATCHING SCREENSHOT)
   ========================================================= */
.card-frame {
  width: 100%;
  max-width: 380px;
  background: var(--card-bg-gradient);
  border-radius: 36px;
  padding: 22px 18px 20px;
  box-shadow: 
    0 20px 40px -10px rgba(0, 40, 60, 0.6),
    0 0 0 4px rgba(255, 255, 255, 0.35),
    inset 0 2px 4px rgba(255, 255, 255, 0.6),
    inset 0 -4px 8px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

/* Logo Badge */
.logo-container {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.logo-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-sparkle {
  font-size: 1.4rem;
  animation: pulseSpin 3s infinite ease-in-out;
}

@keyframes pulseSpin {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.25) rotate(15deg); }
}

.logo-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.95;
  text-align: center;
}

.logo-row-1 {
  font-family: var(--font-display);
  font-size: 2.3rem;
  font-weight: 800;
  letter-spacing: 2px;
  background: var(--gold-text-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 0 #b35900) drop-shadow(0 5px 6px rgba(0, 0, 0, 0.4));
  display: inline-flex;
  align-items: center;
}

.logo-row-2 {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: 3px;
  background: var(--gold-text-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 0 #b35900) drop-shadow(0 5px 6px rgba(0, 0, 0, 0.4));
}

.logo-face {
  -webkit-text-fill-color: initial;
  display: inline-block;
  font-size: 1.9rem;
  transform: translateY(-2px);
  animation: bounceMini 2s infinite ease-in-out;
}

@keyframes bounceMini {
  0%, 100% { transform: translateY(-2px); }
  50% { transform: translateY(-6px) rotate(10deg); }
}

/* Home Preview Grid (3x3 matching screenshot exactly) */
.home-preview-grid {
  width: 290px;
  height: 290px;
  background: #ffffff;
  border-radius: 20px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 3px;
  padding: 4px;
  box-shadow: 
    inset 0 4px 8px rgba(0, 0, 0, 0.15),
    0 8px 16px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}

.preview-cell {
  background: #edf2f7;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  position: relative;
  z-index: 2;
  transition: transform 0.2s ease;
}

.preview-cell span {
  filter: drop-shadow(0 3px 4px rgba(0,0,0,0.2));
  animation: gentlePulse 3s infinite ease-in-out;
}

.preview-cell.p1 span { animation-delay: 0s; }
.preview-cell.p2 span { animation-delay: 0.5s; }
.preview-cell.p3 span { animation-delay: 1s; }

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

.preview-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.preview-path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 6;
}

.path-cyan {
  stroke: #00d2ff;
  filter: drop-shadow(0 0 8px rgba(0, 210, 255, 0.8));
}

.path-yellow {
  stroke: #ffb703;
  filter: drop-shadow(0 0 8px rgba(255, 183, 3, 0.8));
}

.home-tagline {
  margin-top: 14px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #e0f7fa;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  letter-spacing: 0.5px;
}

/* =========================================================
   BIG JUICY GREEN PLAY BUTTON (MATCHING SCREENSHOT)
   ========================================================= */
.home-actions {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.btn-play {
  width: 170px;
  height: 68px;
  background: linear-gradient(180deg, #55d610 0%, #32aa04 48%, #1f8500 100%);
  border: none;
  border-radius: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 
    0 10px 0 #135500,
    0 16px 25px rgba(0, 0, 0, 0.45),
    inset 0 3px 4px rgba(255, 255, 255, 0.6),
    inset 0 -3px 4px rgba(0, 0, 0, 0.3);
  transition: all 0.12s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.btn-play:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 12px 0 #135500,
    0 20px 30px rgba(0, 0, 0, 0.5),
    inset 0 3px 4px rgba(255, 255, 255, 0.7);
}

.btn-play:active {
  transform: translateY(6px);
  box-shadow: 
    0 4px 0 #135500,
    0 8px 15px rgba(0, 0, 0, 0.4),
    inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.play-icon {
  width: 38px;
  height: 38px;
  color: #ffffff;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
  margin-left: 4px;
}

/* Secondary Buttons */
.secondary-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
  width: 100%;
}

.btn-bubble {
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 20px;
  padding: 10px 18px;
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), inset 0 1px 2px rgba(255, 255, 255, 0.5);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-bubble:hover {
  background: rgba(255, 255, 255, 0.32);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

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

.btn-sound {
  padding: 10px 14px;
}

/* =========================================================
   IN-GAME HUD & LAYOUT
   ========================================================= */
.game-hud {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.hud-group-left,
.hud-group-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.game-level-info {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-level-title {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.game-level-sub {
  font-size: 0.75rem;
  font-weight: 700;
  color: #d1fae5;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.btn-hint {
  position: relative;
}

.hint-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #38b000;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 800;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.btn-icon-round {
  width: 42px;
  height: 42px;
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(8px);
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25), inset 0 1px 2px rgba(255, 255, 255, 0.6);
  transition: all 0.12s ease;
}

.btn-icon-round:hover {
  background: rgba(255, 255, 255, 0.4);
  transform: scale(1.08);
}

.btn-icon-round:active {
  transform: scale(0.95);
}

/* =========================================================
   TARGETS GUIDE TRAY & PAIR HIGHLIGHTS
   ========================================================= */
.targets-guide-container {
  width: 100%;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 16px;
  padding: 8px 10px;
  margin-bottom: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

.targets-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  padding: 0 4px;
}

.targets-title {
  font-size: 0.82rem;
  font-weight: 800;
  color: #fff3b0;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.targets-subtext {
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
}

.targets-list {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.targets-list::-webkit-scrollbar {
  display: none;
}

.target-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 12px;
  padding: 4px 9px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #1e293b;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 2px solid transparent;
  user-select: none;
}

.target-chip:hover {
  transform: translateY(-2px) scale(1.04);
}

.target-chip:active {
  transform: scale(0.96);
}

.target-chip .chip-arrow {
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 900;
}

.target-chip .chip-emoji {
  font-size: 1.15rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

.target-chip.completed {
  background: #10b981;
  color: #ffffff;
  border-color: #059669;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
  animation: chipSuccess 0.4s ease;
}

.target-chip.completed .chip-arrow {
  color: #d1fae5;
}

.target-chip.completed .chip-check {
  font-size: 0.85rem;
  margin-left: 2px;
}

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

/* Pair Action Toast Notification */
.pair-action-toast {
  width: 100%;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 12px;
  padding: 5px 12px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  transition: all 0.25s ease;
}

.pair-action-toast.highlight {
  background: rgba(255, 235, 59, 0.3);
  border-color: #ffeb3b;
  color: #fffde7;
  transform: scale(1.02);
}

/* =========================================================
   GAME BOARD & CANVAS OVERLAY
   ========================================================= */
.board-outer-container {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.board-wrapper {
  position: relative;
  width: 310px;
  height: 310px;
  background: #ffffff;
  border-radius: 22px;
  padding: 4px;
  box-shadow: 
    inset 0 4px 10px rgba(0, 0, 0, 0.15),
    0 10px 24px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  touch-action: none;
}

.grid-board {
  width: 100%;
  height: 100%;
  display: grid;
  gap: 4px;
}

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

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

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

.cell {
  background: #f1f5f9;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.2s ease, box-shadow 0.2s ease;
  font-size: 2.2rem;
  border: 2px solid transparent;
}

.grid-4x4 .cell {
  font-size: 1.8rem;
  border-radius: 10px;
}

.grid-5x5 .cell {
  font-size: 1.45rem;
  border-radius: 8px;
}

.cell.has-emoji {
  cursor: grab;
  background: #f8fafc;
}

.cell.has-emoji:active {
  cursor: grabbing;
}

/* Endpoint Color Ring Indicator (Shows pair colors clearly) */
.cell.endpoint {
  box-shadow: inset 0 0 0 3px var(--pair-color, #00d2ff), 0 3px 6px rgba(0, 0, 0, 0.1);
  background: #ffffff;
}

.cell.endpoint::after {
  content: '';
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--pair-color, #00d2ff);
  box-shadow: 0 0 4px var(--pair-color, #00d2ff);
}

.grid-5x5 .cell.endpoint::after {
  width: 6px;
  height: 6px;
  bottom: 2px;
  right: 2px;
}

/* Active Source & Target Partner Highlighting */
.cell.active-source {
  transform: scale(1.12);
  box-shadow: 0 0 16px var(--pair-color, #00d2ff), inset 0 0 0 3.5px var(--pair-color, #00d2ff);
  z-index: 20;
}

.cell.target-partner {
  animation: targetPulse 1s infinite alternate ease-in-out;
  box-shadow: 0 0 18px var(--pair-color, #00d2ff), inset 0 0 0 3.5px var(--pair-color, #00d2ff);
  z-index: 20;
  background: #fffbeb;
}

@keyframes targetPulse {
  0% { transform: scale(1); box-shadow: 0 0 8px var(--pair-color, #00d2ff), inset 0 0 0 2.5px var(--pair-color, #00d2ff); }
  100% { transform: scale(1.16); box-shadow: 0 0 22px var(--pair-color, #00d2ff), inset 0 0 0 4px var(--pair-color, #00d2ff); }
}

.cell.flash-highlight {
  animation: flashBeacon 0.8s 3 ease-in-out;
}

@keyframes flashBeacon {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.22); box-shadow: 0 0 20px #ffbe0b, inset 0 0 0 4px #ffbe0b; }
}

.cell.dimmed {
  opacity: 0.38;
}

.cell-emoji {
  position: relative;
  z-index: 10;
  pointer-events: none;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,0.2));
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell.active-source .cell-emoji {
  transform: scale(1.22);
}

.cell.connected .cell-emoji {
  animation: connectBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes connectBounce {
  0% { transform: scale(1); }
  50% { transform: scale(1.35) rotate(10deg); }
  100% { transform: scale(1); }
}

/* Pipe Canvas (Smooth Glowing Connections) */
.pipe-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* Bottom status bar */
.game-bottom-bar {
  margin-top: 14px;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
}

.pairs-status {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.status-count {
  color: #fff3b0;
  font-size: 1.1rem;
  font-weight: 800;
}

.pairs-dots {
  display: flex;
  gap: 6px;
}

.pair-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.7);
  transition: all 0.3s ease;
}

.pair-dot.filled {
  transform: scale(1.25);
  box-shadow: 0 0 8px currentColor;
}

/* =========================================================
   LEVEL SELECT SCREEN
   ========================================================= */
.levels-card {
  max-width: 400px;
}

.header-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.stars-counter {
  background: rgba(255, 255, 255, 0.25);
  padding: 6px 12px;
  border-radius: 16px;
  font-weight: 800;
  color: #ffffff;
  border: 1.5px solid rgba(255, 255, 255, 0.5);
}

.levels-scroll-wrapper {
  width: 100%;
  max-height: 380px;
  overflow-y: auto;
  padding: 6px;
}

.levels-scroll-wrapper::-webkit-scrollbar {
  width: 6px;
}
.levels-scroll-wrapper::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.4);
  border-radius: 4px;
}

.levels-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  width: 100%;
}

.level-card-btn {
  background: #ffffff;
  border: none;
  border-radius: 18px;
  padding: 14px 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  box-shadow: 
    0 6px 0 #b0bec5,
    0 10px 16px rgba(0, 0, 0, 0.2);
  transition: all 0.12s ease;
  position: relative;
}

.level-card-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 
    0 8px 0 #b0bec5,
    0 14px 20px rgba(0, 0, 0, 0.25);
}

.level-card-btn:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 
    0 2px 0 #b0bec5,
    0 6px 10px rgba(0, 0, 0, 0.2);
}

.level-card-btn:disabled {
  background: #cfd8dc;
  box-shadow: 0 4px 0 #90a4ae;
  opacity: 0.7;
  cursor: not-allowed;
}

.level-num {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  color: #00796b;
}

.level-card-btn:disabled .level-num {
  color: #607d8b;
}

.level-stars {
  font-size: 0.75rem;
  letter-spacing: -1px;
}

.level-size-tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: #78909c;
}

/* =========================================================
   MODALS (HOW TO PLAY, VICTORY)
   ========================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 25, 47, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.25s ease forwards;
}

@keyframes fadeIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.modal-card {
  background: #ffffff;
  border-radius: 28px;
  width: 100%;
  max-width: 380px;
  padding: 24px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  animation: modalPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

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

.modal-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: #00796b;
}

.btn-close-modal {
  background: #eceff1;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-weight: bold;
  color: #546e7a;
}

.modal-body {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.howto-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #f8fafc;
  padding: 10px 12px;
  border-radius: 14px;
  border-left: 4px solid #00a896;
}

.step-num {
  background: #00a896;
  color: #ffffff;
  font-weight: 800;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
}

.howto-step p {
  font-size: 0.9rem;
  line-height: 1.4;
  color: #334155;
}

.btn-action-big {
  width: 100%;
  background: linear-gradient(180deg, #00b4d8 0%, #0077b6 100%);
  color: #ffffff;
  border: none;
  border-radius: 20px;
  padding: 14px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 0 #023e8a, 0 12px 20px rgba(0, 0, 0, 0.25);
  transition: all 0.12s ease;
}

.btn-action-big:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #023e8a, 0 16px 24px rgba(0, 0, 0, 0.3);
}

.btn-action-big:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #023e8a;
}

/* Victory Card */
.victory-card {
  text-align: center;
  background: linear-gradient(180deg, #ffffff 0%, #f0fdfa 100%);
  border: 4px solid #a7f3d0;
}

.victory-trophy {
  font-size: 4rem;
  margin-bottom: 4px;
  animation: trophySpin 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes trophySpin {
  0% { transform: scale(0) rotate(-180deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.victory-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: #059669;
  letter-spacing: 1px;
}

.victory-sub {
  color: #64748b;
  font-weight: 600;
  margin-bottom: 12px;
}

.stars-awarded {
  display: flex;
  justify-content: center;
  gap: 12px;
  font-size: 2.8rem;
  margin: 12px 0 20px;
}

.star {
  opacity: 0;
  transform: scale(0.2);
  display: inline-block;
  animation: starPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.star-1 { animation-delay: 0.2s; }
.star-2 { animation-delay: 0.4s; }
.star-3 { animation-delay: 0.6s; }

@keyframes starPop {
  0% { opacity: 0; transform: scale(0.2) rotate(-30deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

.victory-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-next {
  background: linear-gradient(180deg, #38b000 0%, #007200 100%);
  box-shadow: 0 6px 0 #004b00, 0 12px 20px rgba(0, 0, 0, 0.25);
}

.btn-next:hover {
  box-shadow: 0 8px 0 #004b00, 0 16px 24px rgba(0, 0, 0, 0.3);
}

.btn-next:active {
  box-shadow: 0 2px 0 #004b00;
}

.victory-secondary-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.victory-secondary-actions .btn-bubble {
  background: #f1f5f9;
  color: #334155;
  border-color: #cbd5e1;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
}

/* Confetti particles */
.confetti-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  border-radius: 28px;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #ffd166;
  opacity: 0.9;
  animation: confettiFall 2.2s ease-out forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(-20px) rotate(0deg) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(350px) rotate(720deg) scale(0.5);
    opacity: 0;
  }
}

/* Responsive tweaks */
@media (max-width: 360px) {
  .card-frame {
    padding: 16px 12px;
  }
  .home-preview-grid,
  .board-wrapper {
    width: 270px;
    height: 270px;
  }
}
