/* Memory Challenge Game - Mobile Styles (for screens ≤ 768px) */
@media screen and (max-width: 768px) {
  * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }

  :root {
    --card-size: 80px;
    --primary-color: #2563eb;
    --success-color: #059669;
    --warning-color: #dc2626;
    --text-color: #333;
    --background-color: #f0f0f0;
    --card-back-color: #2563eb;
    --card-heart-color: #dc2626;
  }

  body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--background-color);
    font-family: Arial, sans-serif;
    padding: 0;
    margin: 0;
  }

  /* Navbar Styles */
  #navbar-container {
    width: 100%;
    background-color: #f7d44c;
  }

  /* Add spacing between navbar and title */
  header {
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .header-controls {
    margin-top: 1rem;
    margin-bottom: 1.5rem;
  }

  .game-container {
    width: 100%;
    margin: 0 auto;
    padding: 15px;
  }

  /* Memory Challenge Header */
  h1 {
    text-align: center;
    color: var(--primary-color);
    margin-top: 2rem;
    margin-bottom: 1.5rem;
    font-size: 2rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
  }

  .game-description {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1rem;
    color: var(--text-color);
  }

  /* Game Header Improvements */
  .game-header {
    margin-bottom: 20px;
  }

  .score-timer-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
    background: white;
    padding: 12px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }

  .score,
  .timer {
    font-size: 1rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .score-label,
  .timer-label {
    color: var(--primary-color);
  }

  #moves-count,
  #time-left {
    background: #f5f7ff;
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid #e6e8f0;
    min-width: 50px;
    text-align: center;
  }

  #time-left.time-warning {
    background: #fff5f5;
    border-color: #fed7d7;
    color: var(--warning-color);
    animation: blink 1s infinite;
  }

  .reset-button {
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s ease;
    width: 100%;
    margin-top: 10px;
  }

  .reset-button:hover {
    background: #1d4ed8;
  }

  /* Timer Styles */
  .game-status {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
  }

  .timer {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--primary-color);
  }

  .time-warning {
    color: var(--warning-color);
    animation: blink 1s infinite;
  }

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

  /* Level Selection Styles */
  .level-select-container {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }

  .level-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .current-level {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--primary-color);
  }

  .level-info .current-level {
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 8px;
  }

  .level-stats {
    padding-top: 0.5rem;
  }

  .level-stats h3 {
    margin-bottom: 0.5rem;
    color: #4b5563;
  }

  .level-stats ul {
    list-style: none;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .level-stats li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: #f9fafb;
    border-radius: 4px;
    border-left: 4px solid var(--primary-color);
  }

  .level-stats li.locked {
    border-left-color: #9ca3af;
    opacity: 0.7;
  }

  .level-select-btn {
    padding: 4px 10px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background-color 0.2s ease;
  }

  .level-select-btn:hover {
    background: #1d4ed8;
  }

  .locked-text {
    font-size: 0.875rem;
    color: #9ca3af;
    font-style: italic;
  }

  /* Memory Challenge Game Grid */
  .card-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
    max-width: 100%;
    justify-content: center;
    margin: 0 auto;
  }

  /* Memory Card Styles */
  .card {
    position: relative;
    aspect-ratio: 2.5/3.5;
    perspective: 1000px;
    cursor: pointer;
    min-height: 60px;
    max-width: var(--card-size);
    margin: 0 auto;
  }

  .card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.5s;
  }

  .card.flipped .card-inner {
    transform: rotateY(180deg);
  }

  .card-front,
  .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  }

  .card-front {
    background: white;
    transform: rotateY(180deg);
    padding: 5px;
  }

  .card-back {
    background: var(--card-back-color);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 5px solid white;
  }

  .card-back::after {
    content: "♠";
    color: white;
    font-size: 1.5rem;
  }

  .card-content {
    position: relative;
    width: 100%;
    height: 100%;
  }

  .card-corner {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 1rem;
    font-weight: bold;
    line-height: 1.2;
  }

  .card-corner.top-left {
    top: 4px;
    left: 4px;
  }

  .card-corner.bottom-right {
    bottom: 4px;
    right: 4px;
    transform: rotate(180deg);
  }

  .card.hearts .card-front,
  .card.diamonds .card-front {
    color: var(--card-heart-color);
  }

  .card-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
  }

  /* Win Message Styles */
  .win-message {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    text-align: center;
    font-size: 1.4rem;
    color: var(--success-color);
    z-index: 1000;
    width: 90%;
  }

  .win-message.show {
    display: block;
  }

  .win-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
  }

  .win-button {
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: background-color 0.3s ease;
  }

  #next-level-btn {
    background: var(--success-color);
    color: white;
  }

  #next-level-btn:hover {
    background: #047857;
  }

  #replay-level-btn,
  #restart-game-btn {
    background: var(--primary-color);
    color: white;
  }

  #replay-level-btn:hover,
  #restart-game-btn:hover {
    background: #1d4ed8;
  }

  /* Game Instructions */
  .game-instructions {
    margin: 1.5rem auto;
    padding: 1.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    color: var(--text-color);
  }

  .game-instructions h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    text-align: center;
    font-size: 1.5rem;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0.5rem;
  }

  .game-instructions p {
    margin-bottom: 1rem;
    line-height: 1.5;
    font-size: 1rem;
  }

  .game-instructions ul {
    margin: 1rem 0;
    padding-left: 1.5rem;
  }

  .game-instructions li {
    margin-bottom: 0.8rem;
    line-height: 1.4;
  }

  .game-instructions strong {
    color: var(--primary-color);
  }

  .game-instructions-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 1rem;
  }

  .instruction-card {
    background: #f9fafb;
    border-radius: 8px;
    padding: 1rem;
    border-left: 4px solid var(--primary-color);
  }

  .instruction-card h3 {
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    font-size: 1.2rem;
  }

  .timer-info {
    background-color: #fff8e6;
    border-left: 4px solid #f7d44c;
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 0 8px 8px 0;
  }

  .timer-info h3 {
    color: #b45309;
    margin-bottom: 0.5rem;
  }

  /* Retry Button Styling */
  .retry-button {
    background: var(--success-color);
    color: white;
    padding: 12px 25px;
    font-size: 1.1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    width: 100%;
  }

  .retry-button:hover {
    background: #047857;
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
  }

  .retry-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }

  /* Update the win message to match the new button styling */
  .win-message {
    color: var(--primary-color);
  }

  .win-message p {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    font-weight: bold;
  }

  /* Add specific styling for smaller mobile devices */
  @media screen and (max-width: 480px) {
    :root {
      --card-size: 60px;
    }

    h1 {
      font-size: 1.7rem;
      margin-top: 1.5rem;
      margin-bottom: 1rem;
    }

    .card-grid {
      gap: 0.3rem;
    }

    .card {
      min-height: 60px;
    }

    .card-corner {
      font-size: 0.8rem;
    }

    .card-center {
      font-size: 2rem;
    }

    .win-message {
      padding: 15px;
      font-size: 1.2rem;
    }

    .win-button {
      padding: 10px 15px;
      font-size: 1rem;
    }

    .game-instructions {
      padding: 1rem;
    }

    .game-instructions h2 {
      font-size: 1.3rem;
    }

    .instruction-card {
      padding: 0.8rem;
    }

    .instruction-card h3 {
      font-size: 1.1rem;
    }
  }
}
