:root {
      --bg-primary: #0f0f1a;
      --bg-secondary: #1a1a2e;
      --card-bg: #16213e;
      --card-front: #e94560;
      --accent: #e94560;
      --accent-glow: rgba(233, 69, 96, 0.4);
      --gold: #ffd700;
      --text: #fff;
      --text-muted: #888;
      --correct: #4ade80;
      --wrong: #ef4444;
    }

    body {
      font-family: 'Segoe UI', system-ui, sans-serif;
      background: var(--bg-primary);
      color: var(--text);
      min-height: 100dvh;
      min-height: -webkit-fill-available;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      touch-action: manipulation;
      -webkit-tap-highlight-color: transparent;
      -webkit-user-select: none;
      user-select: none;
      overscroll-behavior: none;
    }

    /* Badges (below header) */
    .badges-row {
      display: flex;
      gap: 0.5rem;
      justify-content: center;
      margin-top: 0.3rem;
    }

    .badge {
      display: inline-block;
      padding: 0.2rem 0.6rem;
      border-radius: 12px;
      font-size: 0.7rem;
      font-weight: 700;
    }

    .combo-badge {
      background: linear-gradient(135deg, var(--gold), #ff8c00);
      color: #000;
      display: none;
    }

    .combo-badge.active { display: inline-block; }

    .streak-badge {
      background: linear-gradient(135deg, #e94560, #c73e54);
      color: #fff;
    }

    /* Stats Bar */
    .stats-bar {
      display: flex;
      justify-content: center;
      gap: 1.5rem;
      padding: 0.8rem;
      background: var(--bg-secondary);
      border-bottom: 1px solid rgba(255,255,255,0.1);
    }

    .stat {
      text-align: center;
    }

    .stat-value {
      font-size: 1.4rem;
      font-weight: 700;
      color: var(--accent);
    }

    .stat-label {
      font-size: 0.7rem;
      color: var(--text-muted);
      text-transform: uppercase;
    }

    .timer-stat .stat-value {
      font-family: 'Courier New', monospace;
    }

    .timer-stat.warning .stat-value { color: #f59e0b; }
    .timer-stat.danger .stat-value { color: #ef4444; animation: pulse 0.5s infinite; }

    @keyframes pulse {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.5; }
    }

    /* Power-ups Bar */
    .powerups-bar {
      display: flex;
      justify-content: center;
      gap: 1rem;
      padding: 0.6rem;
      background: rgba(0,0,0,0.2);
    }

    .powerup-btn {
      display: flex;
      align-items: center;
      gap: 0.4rem;
      background: linear-gradient(135deg, #374151, #1f2937);
      border: 2px solid rgba(255,255,255,0.1);
      color: var(--text);
      padding: 0.5rem 0.8rem;
      border-radius: 8px;
      font-size: 0.8rem;
      cursor: pointer;
      transition: all 0.2s;
    }

    .powerup-btn:hover:not(:disabled) {
      border-color: var(--accent);
      transform: translateY(-2px);
    }

    .powerup-btn:disabled {
      opacity: 0.4;
      cursor: not-allowed;
    }

    .powerup-btn.active {
      border-color: var(--gold);
      box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
    }

    .powerup-icon { font-size: 1.2rem; }
    .powerup-count {
      background: var(--accent);
      padding: 0.1rem 0.4rem;
      border-radius: 4px;
      font-size: 0.7rem;
      font-weight: 700;
    }

    /* Game Area */
    .game-container {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 1rem;
    }

    .game-board {
      display: grid;
      gap: 0.5rem;
      perspective: 1000px;
      max-width: 100%;
    }

    .game-board.easy { grid-template-columns: repeat(4, 1fr); }
    .game-board.medium { grid-template-columns: repeat(4, 1fr); }
    .game-board.hard { grid-template-columns: repeat(5, 1fr); }

    /* Card */
    .card {
      aspect-ratio: 1;
      cursor: pointer;
      position: relative;
      transform-style: preserve-3d;
      transition: transform 0.4s ease;
    }

    .card.flipped { transform: rotateY(180deg); }
    .card.matched {
      animation: matchPop 0.4s ease;
    }

    .card.matched .card-front {
      background: linear-gradient(135deg, var(--correct), #22c55e);
      box-shadow: 0 0 20px rgba(74, 222, 128, 0.5);
    }

    .card.wrong {
      animation: shake 0.4s ease;
    }

    .card.wrong .card-front {
      background: linear-gradient(135deg, var(--wrong), #dc2626);
    }

    @keyframes matchPop {
      0%, 100% { transform: rotateY(180deg) scale(1); }
      50% { transform: rotateY(180deg) scale(1.1); }
    }

    @keyframes shake {
      0%, 100% { transform: rotateY(180deg) translateX(0); }
      25% { transform: rotateY(180deg) translateX(-5px); }
      75% { transform: rotateY(180deg) translateX(5px); }
    }

    .card-face {
      position: absolute;
      width: 100%;
      height: 100%;
      backface-visibility: hidden;
      border-radius: 12px;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .card-back {
      background: linear-gradient(135deg, var(--card-bg), #0e1628);
      border: 2px solid rgba(255,255,255,0.1);
    }

    .card-back::before {
      content: '?';
      font-size: 2rem;
      color: rgba(255,255,255,0.3);
      font-weight: 700;
    }

    .card-front {
      background: linear-gradient(135deg, var(--card-front), #c73e54);
      transform: rotateY(180deg);
      font-size: 2.5rem;
    }

    .card.peek .card-back {
      border-color: var(--gold);
      box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
    }

    .card.frozen {
      filter: hue-rotate(180deg) brightness(1.2);
    }

    /* Combo Popup */
    .combo-popup {
      position: fixed;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%) scale(0);
      font-size: 3rem;
      font-weight: 900;
      text-shadow: 0 0 20px var(--accent-glow);
      pointer-events: none;
      z-index: 100;
      opacity: 0;
    }

    .combo-popup.show {
      animation: comboPopup 0.8s ease forwards;
    }

    @keyframes comboPopup {
      0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
      30% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
      100% { transform: translate(-50%, -80%) scale(0.8); opacity: 0; }
    }

    /* Menu Screen */
    .menu-screen {
      position: fixed;
      inset: 0;
      background: var(--bg-primary);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 2rem;
      z-index: 200;
    }

    .menu-screen.hidden { display: none; }

    .menu-header {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 0.8rem 1rem;
      background: var(--bg-secondary);
      border-bottom: 1px solid rgba(255,255,255,0.1);
    }

    .menu-header .back-btn {
      color: var(--text-muted);
      text-decoration: none;
      font-size: 0.9rem;
      transition: color 0.2s;
    }

    .menu-header .back-btn:hover { color: var(--text); }

    .menu-header .logo {
      font-size: 1rem;
      font-weight: 700;
      color: var(--accent);
      text-decoration: none;
    }

    .menu-title {
      font-size: 2.5rem;
      font-weight: 900;
      background: linear-gradient(135deg, var(--accent), #ff6b8a, var(--gold));
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      margin-bottom: 0.5rem;
    }

    .menu-subtitle {
      color: var(--text-muted);
      margin-bottom: 2rem;
    }

    .menu-section {
      margin-bottom: 1.5rem;
      text-align: center;
    }

    .menu-section-title {
      font-size: 0.8rem;
      color: var(--text-muted);
      text-transform: uppercase;
      margin-bottom: 0.8rem;
    }

    .mode-buttons {
      display: flex;
      flex-wrap: wrap;
      gap: 0.8rem;
      justify-content: center;
      max-width: 350px;
    }

    .mode-btn {
      background: var(--bg-secondary);
      border: 2px solid rgba(255,255,255,0.1);
      color: var(--text);
      padding: 0.8rem 1.2rem;
      border-radius: 12px;
      cursor: pointer;
      transition: all 0.2s;
      min-width: 100px;
    }

    .mode-btn:hover {
      border-color: var(--accent);
      transform: translateY(-2px);
    }

    .mode-btn.selected {
      border-color: var(--accent);
      background: rgba(233, 69, 96, 0.2);
    }

    .mode-btn .mode-icon { font-size: 1.5rem; display: block; margin-bottom: 0.3rem; }
    .mode-btn .mode-name { font-weight: 700; font-size: 0.9rem; }
    .mode-btn .mode-desc { font-size: 0.7rem; color: var(--text-muted); }

    .daily-challenge-btn {
      background: linear-gradient(135deg, var(--gold), #ff8c00);
      border: none;
      color: #000;
      padding: 1rem 2rem;
      border-radius: 12px;
      font-size: 1rem;
      font-weight: 700;
      cursor: pointer;
      margin-top: 1rem;
      transition: all 0.2s;
    }

    .daily-challenge-btn:hover {
      transform: scale(1.05);
      box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
    }

    .daily-challenge-btn.completed {
      background: linear-gradient(135deg, #4ade80, #22c55e);
    }

    .start-btn {
      background: linear-gradient(135deg, var(--accent), #c73e54);
      border: none;
      color: var(--text);
      padding: 1rem 3rem;
      border-radius: 12px;
      font-size: 1.1rem;
      font-weight: 700;
      cursor: pointer;
      margin-top: 1.5rem;
      transition: all 0.2s;
    }

    .start-btn:hover {
      transform: scale(1.05);
      box-shadow: 0 0 20px var(--accent-glow);
    }

    /* Results Modal */
    .modal-overlay {
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.8);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 300;
      opacity: 0;
      visibility: hidden;
      transition: all 0.3s;
    }

    .modal-overlay.show {
      opacity: 1;
      visibility: visible;
    }

    .modal {
      background: var(--bg-secondary);
      border-radius: 20px;
      padding: 2rem;
      text-align: center;
      max-width: 350px;
      width: 90%;
      transform: scale(0.9);
      transition: transform 0.3s;
    }

    .modal-overlay.show .modal {
      transform: scale(1);
    }

    .modal-icon { font-size: 4rem; margin-bottom: 1rem; }
    .modal-title { font-size: 1.8rem; font-weight: 700; margin-bottom: 0.5rem; }
    .modal-subtitle { color: var(--text-muted); margin-bottom: 1.5rem; }

    .results-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 1rem;
      margin-bottom: 1.5rem;
    }

    .result-item {
      background: rgba(0,0,0,0.2);
      padding: 0.8rem;
      border-radius: 10px;
    }

    .result-value {
      font-size: 1.5rem;
      font-weight: 700;
      color: var(--accent);
    }

    .result-label {
      font-size: 0.7rem;
      color: var(--text-muted);
      text-transform: uppercase;
    }

    .modal-buttons {
      display: flex;
      gap: 0.8rem;
      justify-content: center;
    }

    .modal-btn {
      padding: 0.8rem 1.5rem;
      border-radius: 10px;
      font-weight: 700;
      cursor: pointer;
      transition: all 0.2s;
    }

    .modal-btn.primary {
      background: linear-gradient(135deg, var(--accent), #c73e54);
      border: none;
      color: var(--text);
    }

    .modal-btn.secondary {
      background: transparent;
      border: 2px solid rgba(255,255,255,0.2);
      color: var(--text);
    }

    .modal-btn:hover { transform: translateY(-2px); }

    /* Responsive - Mobile Full Screen */
    @media (max-width: 600px) {
      .stats-bar {
        padding: 0.5rem;
        gap: 0.8rem;
      }

      .stat-value { font-size: 1rem; }

      .powerups-bar {
        padding: 0.4rem;
        gap: 0.5rem;
      }

      .powerup-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.7rem;
      }

      .game-container {
        padding: 0.5rem;
        min-height: calc(100vh - 150px);
        justify-content: flex-start;
        padding-top: 1rem;
      }

      .game-board {
        width: 100%;
        max-width: calc(100vw - 1rem);
      }

      .card-front { font-size: 1.8rem; }
      .card-back::before { font-size: 1.5rem; }
    }

    @media (max-width: 480px) {
      .game-container {
        padding: 0.25rem;
        min-height: calc(100vh - 140px);
      }

      .stats-bar { gap: 0.6rem; }
      .stat-value { font-size: 0.95rem; }
      .stat-label { font-size: 0.6rem; }
    }

    /* Large screens - scale up */
    @media (min-width: 1200px) {
      .game-container {
        padding: 2rem;
      }

      .game-board {
        gap: 0.8rem;
      }

      .game-board.easy {
        width: 500px;
      }

      .game-board.medium {
        width: 560px;
      }

      .game-board.hard {
        width: 650px;
      }

      .card-front { font-size: 3rem; }
      .card-back::before { font-size: 2.5rem; }

      .stats-bar {
        gap: 3rem;
        padding: 1.2rem;
      }

      .stat-value { font-size: 1.8rem; }
      .stat-label { font-size: 0.85rem; }

      .powerups-bar {
        gap: 1.5rem;
        padding: 1rem;
      }

      .powerup-btn {
        padding: 0.8rem 1.2rem;
        font-size: 1rem;
      }
    }

    /* Extra large screens (1920px+) */
    @media (min-width: 1600px) {
      .game-board.easy {
        width: 600px;
      }

      .game-board.medium {
        width: 680px;
      }

      .game-board.hard {
        width: 800px;
      }

      .game-board {
        gap: 1rem;
      }

      .card-front { font-size: 3.5rem; }
      .card-back::before { font-size: 3rem; }
    }

    /* Freeze effect */
    .game-board.frozen .card:not(.matched):not(.flipped) {
      pointer-events: none;
    }

    .game-board.frozen .card:not(.matched) .card-back {
      background: linear-gradient(135deg, #0ea5e9, #0284c7);
      border-color: #38bdf8;
    }

    /* More Games Section */
    .more-games {
      background: var(--bg-secondary);
      border-top: 1px solid rgba(255,255,255,0.1);
      padding: 1.5rem;
      margin-top: auto;
    }

    .more-games-title {
      font-size: 1rem;
      color: var(--text-muted);
      margin-bottom: 1rem;
      text-align: center;
    }

    .more-games-grid {
      display: flex;
      gap: 0.75rem;
      justify-content: center;
      flex-wrap: wrap;
    }

    .more-game-link {
      background: var(--bg-primary);
      border: 1px solid rgba(255,255,255,0.1);
      border-radius: 10px;
      padding: 0.75rem 1rem;
      text-decoration: none;
      color: var(--text);
      display: flex;
      align-items: center;
      gap: 0.5rem;
      font-size: 0.9rem;
      transition: transform 0.2s, border-color 0.2s;
    }

    .more-game-link:hover {
      transform: translateY(-2px);
      border-color: var(--accent);
    }

    .more-game-link span:first-child {
      font-size: 1.2rem;
    }

    @media (max-width: 768px) {
      .more-games { display: none; }
    }

    /* Accessibility: Respect reduced motion preferences */
