/* Pages layer - page-specific styles */
@layer pages {
  /* Mobile-specific layout fixes */
  @media (max-width: 640px) {
    /* Add bottom padding to main to account for fixed mascot */
    main {
      padding-bottom: 80px;
    }

    /* Reduce card padding on mobile */
    .card {
      padding: var(--space-3);
    }

    /* Reduce gaps between elements */
    main {
      gap: var(--space-2);
    }

    /* Smaller round images on mobile */
    .round-image {
      max-width: 100%;
      max-height: 150px;
    }

    /* Flags and silhouettes need to be smaller on mobile to fit buttons on screen */
    .round-image.flag,
    .round-image.silhouette {
      max-height: 100px;
    }

    /* Smaller prompt text on mobile */
    .prompt-calc {
      font-size: 1.4rem;
    }

    .prompt-word {
      font-size: 2rem;
    }

    .prompt-flag,
    .prompt-silhouette {
      font-size: 1.25rem;
    }

    .prompt-capital,
    .prompt-currency {
      font-size: 1.2rem;
    }

    /* Smaller letter buttons on mobile */
    .btn-letter {
      width: 60px;
      height: 60px;
      font-size: 1.5rem;
    }
  }

  /* Lobby specific */
  .lobby-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
  }

  .waiting-text {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 1rem;
  }

  .status-banner {
    border: 2px dashed var(--color-text-muted);
    border-radius: var(--radius-xl);
    padding: 1rem 2rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 1rem;
    font-weight: var(--font-medium);
    min-height: 3.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
  }

  .btn-row {
    display: flex;
    gap: var(--space-3);
  }

  .btn-row > * {
    flex: 1 1 0;
  }

  @media (max-width: 420px) {
    .btn-row {
      flex-direction: column;
    }
  }

  .player-count {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 1rem;
  }

  /* History page styles */
  .personal-bests-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.75rem;
  }

  @media (min-width: 768px) {
    .personal-bests-grid {
      grid-template-columns: repeat(3, 1fr);
    }
  }

  .best-card {
    background: var(--bg);
    border-radius: 8px;
    padding: 0.75rem;
    text-align: center;
  }

  .best-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
  }

  .best-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
  }

  .best-card.high-score .best-value { color: #ffd700; }
  .best-card.calc-time .best-value { color: var(--primary); }
  .best-card.word-time .best-value { color: var(--warning); }
  .best-card.flag-time .best-value { color: var(--secondary); }
  .best-card.silhouette-time .best-value { color: var(--success); }

  .best-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
  }

  .history-header h2 {
    margin-bottom: 0;
  }

  .mode-filters {
    display: flex;
    gap: 0.25rem;
  }

  .filter-btn {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s ease;
  }

  .filter-btn:hover {
    border-color: var(--primary);
    color: var(--text);
  }

  .filter-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
  }

  /* Expandable Match Items */
  details.match-item {
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 0.75rem;
    overflow: hidden;
  }

  details.match-item:last-child {
    margin-bottom: 0;
  }

  details.match-item summary {
    padding: 1rem;
    cursor: pointer;
    list-style: none;
  }

  details.match-item summary::-webkit-details-marker {
    display: none;
  }

  details.match-item summary::after {
    content: '\25BC';
    float: right;
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
  }

  details.match-item[open] summary::after {
    transform: rotate(180deg);
  }

  .match-summary .match-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
  }

  .match-summary .match-header .match-date {
    flex-grow: 1;
  }

  /* Match Details (expanded) */
  .match-details {
    padding: 0 1rem 1rem 1rem;
    border-top: 1px solid var(--border);
    margin-top: 0;
  }

  .match-summary-stats {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 0;
    color: var(--text-muted);
    font-size: 0.875rem;
  }

  /* Rounds Table */
  .rounds-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
  }

  .rounds-table th,
  .rounds-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
  }

  .rounds-table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.7rem;
    text-transform: uppercase;
  }

  .rounds-table tr.round-correct {
    color: var(--success);
  }

  .rounds-table tr.round-wrong {
    color: var(--text-muted);
  }

  @keyframes current-player-pulse {
    0%, 100% {
      box-shadow: 0 0 0 0 rgba(255, 200, 0, 0.4);
    }
    50% {
      box-shadow: 0 0 8px 2px rgba(255, 200, 0, 0.2);
    }
  }

  @keyframes score-flash {
    0% {
      color: var(--color-warning);
      transform: scale(1.2);
    }
    100% {
      color: var(--color-text);
      transform: scale(1);
    }
  }
}

