:root {
  --phone-max-w: 450px;
  --frame-radius: 18px;
  --bg-gray: #edeef0;
  --ink: #555;
  --key-bg: #edeef0;
  --chip: #bbb;
  --accent: rgb(128,121,210);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Century Gothic', 'Tahoma', 'Helvetica', 'Arial', 'Verdana', 'Sans-Serif';
  background: var(--bg-gray);
  color: var(--ink);
}

/* ==========================================
   APP FRAME & LAYOUT
   ========================================== */

.app-wrap {
  height: calc(var(--vh, 1vh) * 100);  /* fixed, not min-height */
  overflow: hidden;                      /* prevent body scroll */
  margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.game-frame {
  width: min(100%, var(--phone-max-w));
  height: 100%;                          /* fill the app-wrap exactly */
  margin: 0 auto;
  background: #fff;
  border-radius: 0;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 3vh, 24px) 16px 8px;
}

.logo img { 
  max-width: 70%; 
  height: auto; 
}

.content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  align-items: center;
  padding: 8px 16px 16px;  /* add bottom padding to push content away from keyboard */
  gap: clamp(8px, 2vh, 16px);
  overflow: hidden;          /* prevent any content from bleeding into keyboard */
}

/* ==========================================
   VOWEL GAME ELEMENTS
   ========================================== */

.lives {
  min-height: 20px;
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: clamp(8px, 2vh, 16px) 0;
}

.heart { 
  height: 20px; 
  width: auto; 
  margin: 0 12%;
}

.diamond {
  width: 20px;
  height: 20px;
  background-color: #E1604C;
  transform: rotate(45deg);
  margin: 0 6px;
  display: inline-block;
}

.word {
  min-height: 40px;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 8px;
  flex-wrap: nowrap;
  gap: 4px;
  margin: clamp(12px, 3vh, 20px) 0;
  width: 100%;
}

.letter {
  height: var(--tile-size, 40px);
  width: var(--tile-size, 40px);
  min-width: 0;
  flex-shrink: 1;
  margin: 2px;
  background: var(--chip);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--tile-font, 22px);
  font-weight: 700;
  border-radius: 4px;
}

.letter.correct { 
  background: var(--accent); 
}

.message {
  min-height: 40px;
  text-align: center;
  font-size: clamp(18px, 2.5vh, 22px);
  color: var(--ink);
  opacity: .85;
  padding: 0 12px;
  margin: clamp(12px, 2vh, 16px) 0;
  transition: min-height 0.2s ease, margin 0.2s ease;
}

.message:empty {
  min-height: 0;
  margin: 0;
  padding: 0;
}

.typed-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: clamp(6px, 1.5vh, 16px) 0;  /* tightened min from 8px */
  padding-bottom: 4px;
  flex-shrink: 0;                      /* never let this collapse to 0 */
}

.typed {
  color: #555;
  font-size: clamp(28px, 6vh, 50px);
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  height: clamp(34px, 7vh, 60px);
  min-width: 50px;
}

.typed-underline {
  width: clamp(40px, 10vw, 60px);
  height: clamp(4px, 0.8vh, 8px);
  min-height: 3px;                     /* floor so it never visually vanishes */
  background: var(--ink);
  border-radius: 2px;
  flex-shrink: 0;
}

.rules-login-nudge {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem 1.25rem;  /* add bottom padding */
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 0.85rem;
  text-align: center;
  opacity: 0.75;
  line-height: 1.4;
}

.rules-login-nudge a {
  color: var(--accent);
  text-decoration: underline;
  white-space: nowrap;
}

/* ==========================================
   TOP BAR & ICON BUTTONS - UPDATED WITH AVATAR
   Replace the existing top-bar CSS in your main.css with this
   ========================================== */

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  min-height: 48px;
  background: transparent; /* Transparent background for use on any page */
}

/* Left side - back and info buttons */
.top-bar-left {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Right side - score display AND avatar */
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px; /* Space between scores and avatar */
}

/* Scores container */
.top-bar-scores {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.score-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}

.score-label {
  text-transform: lowercase;
  font-weight: 700;
}

.score-value {
  color: #555;
  font-weight: 600;
}

/* Color the labels with branding colors */
.score-item.daily .score-label {
  color: var(--accent); /* primary color */
}

.score-item.total .score-label {
  color: var(--secondary, #E1604C); /* secondary color */
}

/* Icon buttons remain the same */
.icon-button {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--ink);
  text-decoration: none;
  flex-shrink: 0;
}

.icon-button:hover {
  background: rgba(0, 0, 0, 0.05);
  transform: scale(1.1);
}

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

.icon-button i {
  font-size: 24px;
}

/* ==========================================
   RULES MODAL - FIXED TO PHONE SCREEN
   ========================================== */

.rules-overlay[hidden] {
  display: none;
}

.rules-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

/* On desktop, constrain to phone frame width */
@media (min-width: 768px) {
  .rules-overlay {
    left: 50%;
    transform: translateX(-50%);
    max-width: var(--phone-max-w);
    width: 100%;
  }
}

.rules-modal {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 450px;
  max-height: calc(100vh - 32px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease;
}

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

.rules-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 2px solid #eee;
  flex-shrink: 0;
}

.rules-header h2 {
  margin: 0;
  font-size: 20px;
  color: var(--ink);
  font-weight: bold;
}

.close-rules {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--ink);
  flex-shrink: 0;
}

.close-rules:hover {
  background: rgba(0, 0, 0, 0.05);
}

.close-rules i {
  font-size: 24px;
}

.rules-content {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

.rule-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 20px;
}

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

.rule-item > i {
  font-size: 28px;
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 2px;
}

.rule-item h3 {
  margin: 0 0 6px 0;
  font-size: 16px;
  color: var(--ink);
  font-weight: bold;
}

.rule-item p {
  margin: 0;
  font-size: 14px;
  color: var(--ink);
  opacity: 0.85;
  line-height: 1.4;
}

/* ==========================================
   KEYBOARD
   ========================================== */

footer.keyboard {
  margin-top: auto;
  padding: 8px 10px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  bottom: env(safe-area-inset-bottom);
  z-index: 1;
  background: #fff;
  touch-action: manipulation;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 4px;
}

.key {
  height: 45px;
  width: 30px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #edeef0;
  color: #333;
  font-weight: bold;
  font-size: 14px;
  margin: 0;
  border-radius: 5px;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s ease;
  font-family: inherit;
  user-select: none;
  touch-action: manipulation;
}

.key:hover {
  background-color: #d8d9dd;
}

.key:active {
  background-color: #c8c9cd;
}

.key.special {
  width: auto;
  padding: 0 12px;
  font-size: 12px;
  text-transform: lowercase;
}

.key.guessed {
  background-color: #bbb;
  color: #888;
}

.key.selected { 
  background: var(--accent); 
  color: #fff; 
  font-weight: 700; 
}

.ph {
  font-size: 18px;
}

/* ==========================================
   SHARE MODAL
   ========================================== */

.share-overlay[hidden] { 
  display: none; 
}

.share-overlay {
  position: fixed; 
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  animation: shareModalFadeIn 0.2s ease;
  padding: 16px;
}

@keyframes shareModalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.share-modal {
  width: min(92vw, 420px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: shareModalSlideUp 0.3s ease;
  max-height: calc(100vh - 32px);
}

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

.share-modal .share-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 2px solid #eee;
  flex-shrink: 0;
}

.share-modal .share-header h3 {
  margin: 0;
  font-size: 20px;
  color: var(--ink);
  font-weight: bold;
}

.share-modal .share-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--ink);
  flex-shrink: 0;
}

.share-modal .share-close:hover {
  background: rgba(0, 0, 0, 0.05);
}

.share-modal .share-close i {
  font-size: 24px;
}

.share-modal .share-content {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.share-modal pre {
  margin: 0;
  background: #f5f5f7;
  padding: 16px;
  border-radius: 8px;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
}

.share-modal .share-actions { 
  display: flex;
  gap: 8px;
  justify-content: center;
}

.share-modal .share-actions .share-action-button {
  flex: 1;
  min-width: 100px;
  padding: 12px 20px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
  font-family: inherit;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.share-modal .share-actions .share-action-button:hover {
  background: #6f68b8;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

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

.share-modal .share-actions .share-action-button i {
  font-size: 18px;
  line-height: 1;
}

/* ==========================================
   SHARE BUTTON (separate from share modal)
   ========================================== */

.share-button {
    /* Background color is set inline via Django template */
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-top: 16px;
    color: white;
}

.share-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    opacity: 0.95;
}

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

.share-button i {
    font-size: 20px;
    line-height: 1;
}

/* Ensure button is hidden by default */
.share-button[style*="display:none"],
.share-button[style*="display: none"] {
    display: none !important;
}

/* When shown, override display */
.share-button.show {
    display: inline-flex !important;
}
/* ==========================================
   RULE DESCRIPTION (in modal)
   ========================================== */

.rule-description {
  padding: 16px;
  background: rgba(128, 121, 210, 0.05);
  border: 2px solid var(--accent);
  border-radius: 6px;
  margin-bottom: 20px;
}

.rule-description p {
  margin: 0;
  font-size: 15px;
  color: var(--ink);
  line-height: 1.5;
}

/* ==========================================
   GAMES LIST PAGE
   ========================================== */

.games-list-frame {
    width: min(100%, var(--phone-max-w, 450px));
    min-height: 100vh;
    margin: 0 auto;
    background: white;
    border-radius: 0;
    box-shadow: 0 8px 24px rgba(0,0,0,.08);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

@media (min-width: 768px) {
    .games-list-frame {
        border-radius: var(--frame-radius, 18px);
        min-height: calc(100vh - 48px);
    }
}

/* Games grid within frame - no extra top padding */
.games-list-frame .games-grid {
    flex: 1;
    display: flex; /* Use flexbox instead of grid for single column */
    flex-direction: column;
    align-items: center; /* Center the cards */
    gap: clamp(20px, 3vh, 32px);
    width: 100%;
    padding: 16px;
    padding-top: 8px; /* Reduced padding since top bar provides spacing */
}

/* Ensure game cards don't stretch */
.games-list-frame .game-card {
    width: 100%;
    max-width: 360px;
}

/* Index body - NO PADDING on mobile, only on desktop */
.index-body {
    background: var(--bg-gray);
    padding: 0 !important; /* Override .content padding */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Remove .app-wrap padding for games list */
.index-body .app-wrap {
    padding: 0 !important;
}

/* Desktop: Add padding to index-body for spacing around frame */
@media (min-width: 768px) {
    .index-body {
        padding: 24px 0 !important; /* Only add vertical padding on desktop */
    }
}

body:has(.index-body) .game-frame {
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

/* Ensure app-wrap has no padding when games list is active */
body:has(.index-body) .app-wrap {
    padding: 0 !important;
}

.games-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(20px, 3vh, 32px);
  width: 100%;
  max-width: 400px;
  padding: 16px;
  margin: 0 auto;
  padding-top: clamp(16px, 3vh, 24px);
  background-color: white;
}

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: clamp(16px, 4vh, 24px) 16px;
  border: 2px black solid;
  border-radius: var(--frame-radius, 18px);
  background: white;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  min-height: 200px;
  gap: clamp(12px, 2vh, 16px);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.game-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.game-card-info-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--ink);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  z-index: 10;
}

.game-card-info-btn:hover {
  background: rgba(255, 255, 255, 1);
  transform: scale(1.1);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.game-card-info-btn:active {
  transform: scale(0.95);
}

.game-card-info-btn i {
  font-size: 18px;
}

.game-card img {
  width: 100%;
  max-width: 240px;
  height: auto;
  object-fit: contain;
  margin-bottom: 0;
}

.game-card h2 {
  margin: 0;
  font-size: clamp(22px, 3vh, 28px);
  text-align: center;
}

.game-card p {
  margin: 0;
  text-align: center;
  opacity: 0.8;
  font-size: clamp(14px, 2vh, 16px);
}

.game-card a {
  text-decoration: none;
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: auto;
}

.game-card .game-name {
  margin: 0;
  font-size: clamp(24px, 4vh, 32px);
  font-weight: bold;
  text-align: center;
  margin-bottom: 8px;
}

.game-card .game-description {
  margin: 0;
  font-size: clamp(14px, 2vh, 16px);
  text-align: center;
  color: var(--ink);
  opacity: 0.85;
  padding: 0 12px;
  margin-bottom: 12px;
  max-width: 280px;
}

.play-button {
  background-color: var(--accent);
  color: #fff;
  padding: 12px 32px;
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none;
  border: none;
  font-size: clamp(18px, 2.5vh, 22px);
  font-weight: bold;
  transition: all 0.3s ease;
  font-family: inherit;
  box-shadow: 0 4px 12px rgba(128, 121, 210, 0.3);
}

.play-button:hover {
  background-color: color-mix(in srgb, var(--accent) 85%, #000);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.play-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(128, 121, 210, 0.3);
}

/* Ensure top bar is always visible on games list page */
.index-body .top-bar {
    opacity: 1 !important;
}

/* Override any intro animation rules for games list */
body:has(.index-body) .top-bar {
    opacity: 1 !important;
}

/* ==========================================
   RESPONSIVE / MEDIA QUERIES
   ========================================== */

@media (min-width: 768px) {
  .app-wrap {
    padding: 24px 0;
    height: auto;           /* let desktop scroll naturally */
    min-height: calc(var(--vh, 1vh) * 100);
    overflow: visible;
  }

  .game-frame {
    border-radius: var(--frame-radius);
    height: calc(var(--vh, 1vh) * 100 - 48px);
  }

  footer.keyboard {
    border-bottom-left-radius: var(--frame-radius);
    border-bottom-right-radius: var(--frame-radius);
  }

  .key { width: 35px; }
  
  .games-grid {
    max-width: 100%;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    max-width: 1200px;
  }
}

/* ==========================================
   ENHANCED TOOLTIP STYLING
   ========================================== */

/* Ensure game-card has proper context for absolute positioning */
.game-card {
  position: relative;
  overflow: visible; /* Allow tooltip to show outside card */
}

/* Custom tooltip for game card info button */
.game-card-info-btn[title]:hover::after {
  content: attr(title);
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.4;
  white-space: normal;
  min-width: 250px;
  max-width: min(calc(100vw - 48px), 360px); /* Constrain to viewport or card */
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: tooltipFadeIn 0.2s ease;
  pointer-events: none;
}

/* Tooltip arrow */
.game-card-info-btn[title]:hover::before {
  content: '';
  position: absolute;
  top: calc(100% + 2px);
  right: 8px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid rgba(0, 0, 0, 0.9);
  z-index: 1001;
  animation: tooltipFadeIn 0.2s ease;
  pointer-events: none;
}

@keyframes tooltipFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Hide custom tooltip on mobile (touch devices) */
@media (max-width: 767px) {
  .game-card-info-btn[title]:hover::after,
  .game-card-info-btn[title]:hover::before {
    display: none;
  }

  body {
    background: #fff;
  }
}

/* Adjust for smaller screens */
@media (max-width: 480px) {
  .game-card-info-btn[title]:hover::after {
    font-size: 13px;
    padding: 10px 14px;
    min-width: 200px;
  }
}
/* ============================================
   VOWEL GAME INTRO ANIMATION
   ============================================ */

/* PRELOAD: Hide elements before JS determines if intro should play */
.game-frame:not(.game-loaded):not(.no-intro) .lives,
.game-frame:not(.game-loaded):not(.no-intro) .word,
.game-frame:not(.game-loaded):not(.no-intro) .message,
.game-frame:not(.game-loaded):not(.no-intro) .typed-group,
.game-frame:not(.game-loaded):not(.no-intro) .typed-underline,
.game-frame:not(.game-loaded):not(.no-intro) .keyboard,
.game-frame:not(.game-loaded):not(.no-intro) .top-bar {
    opacity: 0;
}

/* Hide all game elements initially during intro */
.game-intro .lives,
.game-intro .word,
.game-intro .message,
.game-intro .typed-group,
.game-intro .typed-underline,
.game-intro .keyboard {
    opacity: 0;
    transform: translateY(20px);
}

.game-intro .top-bar {
    opacity: 0;
}

/* Logo stays visible and in place - no animation */
.game-intro header.logo {
    opacity: 1;
}

/* Fade in top bar */
.game-intro.animating .top-bar {
    animation: gameIntroFadeIn 0.4s ease-out 0.2s forwards;
}

/* Stagger the game elements */
.game-intro.animating .lives {
    animation: gameIntroSlideUp 0.5s ease-out 0.3s forwards;
}

.game-intro.animating .word {
    animation: gameIntroSlideUp 0.5s ease-out 0.4s forwards;
}

.game-intro.animating .message {
    animation: gameIntroSlideUp 0.5s ease-out 0.5s forwards;
}

.game-intro.animating .typed-group,
.game-intro.animating .typed-underline {
    animation: gameIntroSlideUp 0.5s ease-out 0.6s forwards;
}

.game-intro.animating .keyboard {
    animation: gameIntroSlideUp 0.5s ease-out 0.7s forwards;
}

/* Keyframe animations */
@keyframes gameIntroFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

/* ==========================================
   STATS MODAL
   ========================================== */

.stats-modal-overlay {
    position: absolute; /* Changed from fixed */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
    padding: 16px;
}

/* On desktop, constrain to phone frame width */
@media (min-width: 768px) {
    .stats-modal-overlay {
        left: 50%;
        transform: translateX(-50%);
        max-width: var(--phone-max-w);
        width: 100%;
    }
}

.stats-modal {
    background: white;
    border-radius: 12px;
    max-width: 100%;
    width: 100%;
    max-height: calc(100vh - 32px);
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
    display: flex;
    flex-direction: column;
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 2px solid #eee;
    flex-shrink: 0;
}

.stats-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: bold;
    color: var(--ink);
}

.stats-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--ink);
    flex-shrink: 0;
}

.stats-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

.stats-close i {
    font-size: 24px;
}

.stats-content {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 24px;
}

.stat-card {
    text-align: center;
    padding: 16px 8px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.stat-value {
    font-size: 28px;
    font-weight: bold;
    line-height: 1;
    color: var(--accent);
}

.stat-label {
    font-size: 11px;
    color: #666;
    margin-top: 6px;
    text-transform: uppercase;
    font-weight: 600;
}

.stats-distribution {
    margin-bottom: 24px;
}

.stats-distribution h3 {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 12px;
}

.distribution-chart {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.distribution-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.distribution-label {
    width: 20px;
    text-align: center;
    font-weight: bold;
    font-size: 14px;
}

.distribution-bar-container {
    flex: 1;
    height: 28px;
    position: relative;
}

.distribution-bar {
    height: 100%;
    background-color: #d3d3d3;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    min-width: 32px;
    transition: width 0.5s ease;
    border-radius: 4px;
}

.distribution-row.current-game .distribution-bar {
    background-color: var(--accent, #8079d2);
}

.distribution-count {
    color: white;
    font-weight: bold;
    font-size: 14px;
}

.stats-today {
    text-align: center;
    padding: 16px 20px 20px; /* Reduced top padding from 20px to 16px */
    background-color: #f8f9fa;
    border-radius: 8px;
}

.stats-today h3 {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 8px; /* Reduced from 12px to 8px */
    margin-top: 0;
}

.today-language {
    font-size: 14px; /* Reduced from 18px */
    font-weight: 400; /* Changed from 600 to normal */
    margin-bottom: 16px; /* Increased from 8px for more spacing */
    color: #555;
}

.today-lives {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}

.today-lives .diamond {
    width: 16px;
    height: 16px;
    background-color: #E1604C;
    transform: rotate(45deg);
}

.today-word {
    font-size: 16px;
    margin: 16px 0; /* Changed from margin-bottom: 8px to symmetric margin */
}

.today-score {
    font-size: 20px;
    font-weight: bold;
    color: #28a745;
    margin-top: 10px; /* Added margin-top for spacing */
}

.stats-share {
    text-align: center;
}

.stats-share .share-button {
    width: 100%;
    max-width: 300px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity 0.2s;
}

.stats-share .share-button:hover {
    opacity: 0.9;
}

.today-lives {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 8px 0;
}

.today-lives .diamond {
    width: 16px;
    height: 16px;
    background-color: #E1604C;
    transform: rotate(45deg);
}

/* ============================================
   SCORE BREAKDOWN STYLES - INLINE VERSION
   Fixed space that's always present in layout
   ============================================ */

/* Main container for score breakdown - hidden when empty */
#scoreBreakdownContainer {
    width: 100%;
    height: 0; /* Start with 0 height */
    margin: 0;
    padding: 0;
    position: relative;
    overflow: hidden;
    /* NO transition on height - prevents jumpiness during sequential load */
}

/* When it has content (score breakdown is showing) */
#scoreBreakdownContainer:not(:empty) {
    height: 80px; /* Expand to 80px when content appears */
}

/* Main wrapper */
.score-breakdown-main {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

/* Transfer container with two columns - CENTERED */
.score-transfer-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    align-items: center;
    height: 80px;
    transition: opacity 0.3s ease; /* Only opacity transitions */
    padding: 0;
    max-width: 100%;
}

/* Left side (source points) */
.score-left {
    text-align: right;
    padding-right: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    position: relative; /* Needed for ::after pseudo-element */
}

.score-left-label {
    font-size: 0.75rem;
    color: rgba(85, 85, 85, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.25rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    font-weight: 600;
}

.score-left-value {
    font-size: 2rem;
    font-weight: bold;
    color: #555;
    opacity: 0;
    transition: opacity 0.3s ease;
    font-variant-numeric: tabular-nums;
}

/* Divider line - CENTERED between columns */
.score-left::after {
    content: '';
    position: absolute;
    right: 0; /* Changed from left: 50% */
    top: 50%;
    transform: translate(50%, -50%); /* Changed from translate(-50%, -50%) */
    height: 60%;
    width: 2px;
    background: rgba(128, 121, 210, 0.3);
}

/* Right side (daily total) */
.score-right {
    text-align: left;
    padding-left: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
}

.score-right-label {
    font-size: 0.75rem;
    color: rgba(85, 85, 85, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.score-right-value {
    font-size: 2rem;
    font-weight: bold;
    color: #E1604C;
    font-variant-numeric: tabular-nums;
}

/* Type-specific colors for left side */
.score-transfer-container[data-type="base"] .score-left-value {
    color: var(--accent, #8079d2);
}

.score-transfer-container[data-type="play-streak"] .score-left-value,
.score-transfer-container[data-type="win-streak"] .score-left-value,
.score-transfer-container[data-type="global-streak"] .score-left-value {
    color: #4ade80;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    #scoreBreakdownContainer:not(:empty) {
        height: 70px;
    }
    
    .score-transfer-container {
        height: 70px;
    }
    
    .score-left {
        padding-right: 1rem;
    }
    
    .score-right {
        padding-left: 1rem;
    }
    
    .score-left-value,
    .score-right-value {
        font-size: 1.75rem;
    }
    
    .score-left-label,
    .score-right-label {
        font-size: 0.7rem;
    }
}

/* ==========================================
   USER AVATAR COMPONENT
   Reusable avatar showing user initials
   
   Usage:
   <div class="user-avatar user-avatar-medium" style="background-color: #8079d2;">
     <span class="user-avatar-initials">JD</span>
   </div>
   ========================================== */

.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: var(--accent, #8079d2);
    color: white;
    font-weight: 700;
    flex-shrink: 0;
    user-select: none;
    border: none;
    padding: 0;
    font-family: inherit;
}

.user-avatar-initials {
    line-height: 1;
    text-transform: uppercase;
}

/* Size variants */
.user-avatar-small {
    width: 28px;
    height: 28px;
    font-size: 12px;
}

.user-avatar-medium {
    width: 36px;
    height: 36px;
    font-size: 14px;
}

.user-avatar-large {
    width: 48px;
    height: 48px;
    font-size: 18px;
}

/* Clickable state (for future use) */
.user-avatar-clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-avatar-clickable:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.user-avatar-clickable:active {
    transform: scale(0.95);
}

/* Focus state for accessibility */
.user-avatar-clickable:focus {
    outline: 2px solid var(--accent, #8079d2);
    outline-offset: 2px;
}

/* ==========================================
   HAMBURGER MENU COMPONENT
   Reusable navigation menu with overlay
   ========================================== */

/* Hamburger button */
.hamburger-button {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--ink, #555);
    flex-shrink: 0;
    position: relative;
    z-index: 1001;
}

.hamburger-button:hover {
    background: rgba(0, 0, 0, 0.05);
    transform: scale(1.1);
}

.hamburger-button:active {
    transform: scale(0.95);
}

.hamburger-button i {
    font-size: 24px;
}

/* Menu overlay - covers entire screen */
.hamburger-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1100;
    overflow: hidden; /* Prevent menu from showing outside bounds */
}

/* On desktop, constrain to phone frame dimensions */
@media (min-width: 768px) {
    .hamburger-overlay {
        top: 24px; /* Match .app-wrap padding */
        bottom: 24px; /* Match .app-wrap padding */
        left: 50%;
        transform: translateX(-50%);
        max-width: var(--phone-max-w, 450px);
        width: 100%;
        border-radius: var(--frame-radius, 18px); /* Match phone screen rounded corners */
        height: auto; /* Allow height to be determined by top/bottom */
    }
}

.hamburger-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Menu panel - full width, slides in from left */
.hamburger-menu {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0; /* Use right: 0 instead of width: 100% for true full width */
    background: white;
    transform: translateX(-100%); /* Start completely off-screen to the left */
    transition: transform 0.3s ease;
    z-index: 1101;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Border radius only on desktop within overlay */
@media (min-width: 768px) {
    .hamburger-menu {
        border-radius: var(--frame-radius, 18px);
    }
}

.hamburger-overlay.active .hamburger-menu {
    transform: translateX(0);
}

/* Menu header */
.hamburger-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 2px solid #eee;
    flex-shrink: 0;
}

.hamburger-menu-title {
    font-size: 18px;
    font-weight: bold;
    color: var(--ink, #555);
    margin: 0;
}

.hamburger-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--ink, #555);
    flex-shrink: 0;
}

.hamburger-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

.hamburger-close i {
    font-size: 24px;
}

/* Menu content */
.hamburger-menu-content {
    flex: 1;
    padding: 8px 0;
}

/* Menu items */
.hamburger-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    color: var(--ink, #555);
    text-decoration: none;
    transition: background-color 0.2s ease;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-size: 16px;
    font-family: inherit;
}

.hamburger-menu-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.hamburger-menu-item i {
    font-size: 20px;
    width: 20px;
    color: var(--accent, #8079d2);
    flex-shrink: 0;
}

.hamburger-menu-item span {
    flex: 1;
}

/* Menu divider */
.hamburger-menu-divider {
    height: 1px;
    background: #eee;
    margin: 8px 0;
}

/* Menu footer (optional) */
.hamburger-menu-footer {
    padding: 16px;
    border-top: 2px solid #eee;
    flex-shrink: 0;
    font-size: 14px;
    color: #999;
    text-align: center;
}

/* Prevent body scroll when menu is open */
body.hamburger-menu-open {
    overflow: hidden;
}

/* ==========================================
   ABOUT PAGE STYLES
   Add these styles to your main.css file
   ========================================== */

/* About page body wrapper */
.about-page {
    background: var(--bg-gray, #edeef0);
    padding: 0 !important;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Remove .app-wrap padding for about page */
.about-page .app-wrap {
    padding: 0 !important;
}

/* Remove game-frame wrapper for about page (similar to games list) */
body:has(.about-page) .game-frame {
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

/* Ensure app-wrap has no padding when about page is active */
body:has(.about-page) .app-wrap {
    padding: 0 !important;
}

/* About page frame - matches games list frame */
.about-frame {
    width: min(100%, var(--phone-max-w, 450px));
    min-height: 100vh;
    margin: 0 auto;
    background: #fff;
    border-radius: 0;
    box-shadow: 0 8px 24px rgba(0,0,0,.08);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-y: auto;
}

@media (min-width: 768px) {
    .about-frame {
        border-radius: var(--frame-radius, 18px);
        min-height: calc(100vh - 48px);
    }
    
    .about-page {
        padding: 24px 0 !important;
    }
}

/* About content container */
.about-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

/* Page title */
.about-title {
    font-size: clamp(28px, 5vw, 36px);
    font-weight: bold;
    color: var(--ink, #555);
    margin: 0 0 24px 0;
    text-align: center;
}

/* Section spacing */
.about-section {
    margin-bottom: 32px;
}

.about-section:last-of-type {
    margin-bottom: 0;
}

/* Section headings */
.about-heading {
    font-size: clamp(20px, 4vw, 24px);
    font-weight: bold;
    color: var(--ink, #555);
    margin: 0 0 16px 0;
}

/* Introduction paragraphs */
.about-intro {
    font-size: 16px;
    line-height: 1.6;
    color: var(--ink, #555);
    margin-bottom: 16px;
}

.about-intro:last-child {
    margin-bottom: 0;
}

/* Brand name highlight */
.about-brand {
    font-weight: 600;
    color: var(--accent, #8079d2);
}

/* General text */
.about-text {
    font-size: 15px;
    line-height: 1.6;
    color: var(--ink, #555);
    margin-bottom: 16px;
}

/* Highlight box (for scoring section) */
.about-highlight {
    background: color-mix(in srgb, var(--accent, #8079d2) 8%, transparent);
    border: 1px solid var(--accent, #8079d2);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.about-highlight-main {
    font-size: 16px;
    font-weight: 600;
    color: var(--ink, #555);
    margin: 0 0 8px 0;
}

.about-highlight-sub {
    font-size: 15px;
    color: var(--ink, #555);
    margin: 0;
}

.about-points {
    color: var(--accent, #8079d2);
    font-weight: bold;
}

/* Streaks container */
.about-streaks {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

/* Individual streak card */
.about-streak-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.about-streak-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Streak icon */
.about-streak-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(34, 197, 94, 0.1);
}

.about-streak-icon i {
    font-size: 18px;
    color: #22c55e;
}

.about-streak-icon-win {
    background: rgba(234, 179, 8, 0.1);
}

.about-streak-icon-win i {
    color: #eab308;
}

.about-streak-icon-global {
    background: color-mix(in srgb, var(--accent, #8079d2) 10%, transparent);
}

.about-streak-icon-global i {
    color: var(--accent, #8079d2);
}

/* Streak content */
.about-streak-content {
    flex: 1;
}

.about-streak-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--ink, #555);
    margin: 0 0 6px 0;
}

.about-streak-text {
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink, #555);
    opacity: 0.85;
    margin: 0;
}

/* Call to action section */
.about-cta {
    background: linear-gradient(135deg, var(--accent, #8079d2) 0%, color-mix(in srgb, var(--accent, #8079d2) 75%, #fff) 100%);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    margin-top: 32px;
}

.about-cta-title {
    font-size: clamp(20px, 4vw, 24px);
    font-weight: bold;
    color: #fff;
    margin: 0 0 12px 0;
}

.about-cta-text {
    font-size: 15px;
    color: #fff;
    opacity: 0.95;
    margin: 0 0 20px 0;
    line-height: 1.5;
}

.about-cta-button {
    display: inline-block;
    background: #fff;
    color: var(--accent, #8079d2);
    font-weight: 600;
    padding: 12px 32px;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.about-cta-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background: #f8f8f8;
}

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

/* Responsive adjustments */
@media (max-width: 480px) {
    .about-content {
        padding: 16px;
    }
    
    .about-title {
        margin-bottom: 20px;
    }
    
    .about-section {
        margin-bottom: 28px;
    }
    
    .about-streak-card {
        padding: 14px;
    }
    
    .about-cta {
        padding: 20px 16px;
    }
}

/* ==========================================
   LEADERBOARD PAGE STYLES
   Add these styles to your main.css file
   ========================================== */

/* Leaderboard page body wrapper */
.leaderboard-page {
    background: var(--bg-gray, #edeef0);
    padding: 0 !important;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Remove .app-wrap padding for leaderboard page */
.leaderboard-page .app-wrap {
    padding: 0 !important;
}

/* Remove game-frame wrapper for leaderboard page */
body:has(.leaderboard-page) .game-frame {
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

body:has(.leaderboard-page) .app-wrap {
    padding: 0 !important;
}

/* Leaderboard frame - matches games list frame */
.leaderboard-frame {
    width: min(100%, var(--phone-max-w, 450px));
    min-height: 100vh;
    margin: 0 auto;
    background: #fff;
    border-radius: 0;
    box-shadow: 0 8px 24px rgba(0,0,0,.08);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-y: auto;
}

@media (min-width: 768px) {
    .leaderboard-frame {
        border-radius: var(--frame-radius, 18px);
        min-height: calc(100vh - 48px);
    }
    
    .leaderboard-page {
        padding: 24px 0 !important;
    }
}

/* Page header */
.leaderboard-header {
    padding: 20px 20px 12px;
    text-align: center;
}

.leaderboard-title {
    font-size: clamp(24px, 5vw, 32px);
    font-weight: bold;
    color: var(--ink, #555);
    margin: 0;
}

/* Row 1: Type Tabs (Points vs Streaks) */
.leaderboard-type-tabs {
    display: flex;
    gap: 8px;
    padding: 0 16px 12px;
}

.type-tab {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: #f5f5f5;
    border-radius: 12px;
    text-decoration: none;
    color: var(--ink, #555);
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.type-tab i {
    font-size: 18px;
}

.type-tab:hover {
    background: #e8e8e8;
}

.type-tab.active {
    background: var(--accent, #8079d2);
    color: white;
    border-color: var(--accent, #8079d2);
}

/* Row 2: Game Tabs (All + Individual Games) - RED THEME */
.leaderboard-game-tabs {
    display: flex;
    gap: 6px;
    padding: 0 16px 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.leaderboard-game-tabs::-webkit-scrollbar {
    display: none;
}

.game-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    background: #f5f5f5;
    border-radius: 20px;
    text-decoration: none;
    color: var(--ink, #555);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    flex-shrink: 0;
}

.game-tab:hover {
    background: color-mix(in srgb, var(--secondary, #E1604C) 12%, #fff);
    border-color: color-mix(in srgb, var(--secondary, #E1604C) 30%, transparent);
}

.game-tab.active {
    background: var(--secondary, #E1604C);
    color: white;
    border-color: var(--secondary, #E1604C);
}

/* Row 3: Period Tabs (Day, Week, Month, etc.) */
.leaderboard-period-tabs {
    display: flex;
    gap: 4px;
    padding: 0 16px 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.leaderboard-period-tabs::-webkit-scrollbar {
    display: none;
}

.period-tab {
    flex: 1;
    padding: 8px 12px;
    text-align: center;
    background: #f5f5f5;
    border-radius: 8px;
    text-decoration: none;
    color: var(--ink, #555);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.period-tab:hover {
    background: #e8e8e8;
}

.period-tab.active {
    background: var(--accent, #8079d2);
    color: white;
}

/* User Stats Card */
.user-stats-card {
    margin: 0 16px 16px;
    padding: 16px;
    background: linear-gradient(135deg, var(--accent, #8079d2) 0%, color-mix(in srgb, var(--accent, #8079d2) 75%, #fff) 100%);
    border-radius: 12px;
    color: white;
}

.user-stats-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
    margin-bottom: 8px;
    font-weight: 600;
}

.user-stats-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-stats-rank {
    font-size: 32px;
    font-weight: bold;
    line-height: 1;
}

.user-stats-value {
    font-size: 16px;
    opacity: 0.95;
}

/* Leaderboard Content */
.leaderboard-content {
    flex: 1;
    padding: 0 16px 16px;
    overflow-y: auto;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Leaderboard Entry */
.leaderboard-entry {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.leaderboard-entry:hover {
    background: #f0f1f3;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Top 3 styling */
.leaderboard-entry.rank-1 {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 215, 0, 0.05) 100%);
    border: 2px solid rgba(255, 215, 0, 0.3);
}

.leaderboard-entry.rank-2 {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.15) 0%, rgba(192, 192, 192, 0.05) 100%);
    border: 2px solid rgba(192, 192, 192, 0.3);
}

.leaderboard-entry.rank-3 {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.15) 0%, rgba(205, 127, 50, 0.05) 100%);
    border: 2px solid rgba(205, 127, 50, 0.3);
}

/* Current user highlight */
.leaderboard-entry.current-user {
    background: color-mix(in srgb, var(--accent, #8079d2) 10%, transparent);
    border: 2px solid var(--accent, #8079d2);
}

/* Rank display */
.leaderboard-rank {
    width: 40px;
    text-align: center;
    flex-shrink: 0;
}

.leaderboard-rank i {
    font-size: 24px;
}

.rank-number {
    font-size: 16px;
    font-weight: bold;
    color: var(--ink, #555);
}

/* User info */
.leaderboard-user {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.leaderboard-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--accent, #8079d2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.leaderboard-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink, #555);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Score display */
.leaderboard-score {
    font-size: 18px;
    font-weight: bold;
    color: var(--accent, #8079d2);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.streak-value {
    font-size: 18px;
    font-weight: bold;
}

.streak-icon {
    font-size: 16px;
}

/* Empty state */
.leaderboard-empty {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.leaderboard-empty i {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.leaderboard-empty p {
    margin: 0;
    font-size: 16px;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .leaderboard-header {
        padding: 16px 16px 8px;
    }
    
    .category-tab {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .period-tab {
        padding: 6px 8px;
        font-size: 12px;
    }
    
    .leaderboard-entry {
        padding: 10px;
    }
    
    .leaderboard-avatar {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    
    .leaderboard-name {
        font-size: 14px;
    }
    
    .leaderboard-score {
        font-size: 16px;
    }
}

/* ==========================================
   AVATAR DROPDOWN MENU
   ========================================== */

.avatar-menu-wrap {
    position: relative;
}

.avatar-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    padding: 6px;
    z-index: 1200;
    animation: avatarDropdownFade 0.15s ease;
}

.avatar-dropdown[hidden] {
    display: none;
}

@keyframes avatarDropdownFade {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.avatar-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--ink, #555);
    text-decoration: none;
    font-size: 15px;
    transition: background-color 0.2s ease;
}

.avatar-dropdown-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.avatar-dropdown-item i {
    font-size: 20px;
    color: var(--accent, #8079d2);
    flex-shrink: 0;
}

/* Account page form */
.account-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 360px;
}

.account-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink, #555);
    margin-top: 8px;
}

.account-input {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: inherit;
    font-size: 15px;
    color: var(--ink, #555);
}

.account-input:focus {
    outline: none;
    border-color: var(--accent, #8079d2);
}

.account-save {
    align-self: flex-start;
    margin-top: 16px;
}

.account-message {
    background: rgba(40, 167, 69, 0.1);
    border: 2px solid #28a745;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--ink, #555);
}

.account-message.error {
    background: rgba(225, 96, 76, 0.1);
    border-color: #E1604C;
}

.games-list-logo {
  text-align: center;
  padding: 0.5rem;
}

.games-list-logo img {
  max-width: 220px;
  width: 100%;
  display: block;
  margin: 0 auto;
}

/* Log in link — shown in the top bar for anonymous users */
.login-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 20px;
  background: var(--accent, #8079d2);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.login-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

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

.login-link i {
  font-size: 16px;
  line-height: 1;
}

/* ==========================================
   USERNAME PROMPT MODAL
   ========================================== */

.username-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
    animation: shareModalFadeIn 0.2s ease; /* reuse existing */
}

.username-modal-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    width: min(92vw, 360px);
    padding: 28px 24px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: slideUp 0.3s ease; /* reuse existing */
}

.username-modal-emoji {
    font-size: 2.5rem;
    line-height: 1;
    margin: 0;
}

.username-modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0;
}

.username-modal-body {
    font-size: 0.9rem;
    color: var(--ink);
    opacity: 0.7;
    margin: 0;
    line-height: 1.5;
}

/* ---------------------------------------------------------------
   Anonymous user CTA — shown in place of stat cards + charts
   when the player hasn't logged in.
--------------------------------------------------------------- */

/* Collapse the top padding when there are no stat cards above */
.stats-content--anon {
    padding-top: 4px;
}

/* Stat cards now sit below the share button — give them breathing room */
.stats-share + .stats-summary {
    margin-top: 8px;
}

/* 1. Remove top gap on score section when it's the first thing in the modal */
.stats-score-section--flush {
    margin-top: 0;
    padding-top: 0;
}

/* 2. Extra breathing room below the share button before the divider */
.stats-share--spaced {
    margin-bottom: 4px;
}

/* 3. See All toggle button inline with "Today's Words" heading */
.stats-today h3 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
    margin-top: 0;
}

.affix-see-all-btn {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent, #8079d2);
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: inherit;
    flex-shrink: 0;
    transition: opacity 0.15s ease;
}

.affix-see-all-btn:hover {
    opacity: 0.7;
}

/* Missed word chips — dark grey, same shape as found chips */
.affix-chip--missed {
    background-color: #666 !important;
    animation: none;
}

/* ---------------------------------------------------------------
   Stats modal overlay — anchor to top so tall content never
   pushes the modal header off screen.
   Overrides the base .stats-modal-overlay align-items: center.
--------------------------------------------------------------- */
.stats-modal-overlay {
    align-items: flex-start;
    overflow-y: auto;           /* let the overlay itself scroll if needed */
    padding-top: 16px;
    padding-bottom: 16px;
}

/* Modal fills overlay width but doesn't exceed what's visible */
.stats-modal {
    max-height: none;           /* let content grow naturally; overlay scrolls */
    flex-shrink: 0;             /* don't compress — scroll instead */
}

/* Divider with label between share button and stat cards */
.stats-section-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0 8px;
    color: #aaa;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.stats-section-divider::before,
.stats-section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e8e8e8;
}

.anon-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 0.5rem 0.25rem;
    text-align: center;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    margin-top: 0.5rem;
}

.anon-cta p {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.75;
    line-height: 1.45;
    max-width: 28ch;
}

.anon-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.6rem 1.4rem;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.anon-cta-btn:hover {
    opacity: 0.85;
}


/* ---------------------------------------------------------------------------
   Inline share block (results modals — replaces the old share overlay)
   --------------------------------------------------------------------------- */

.stats-share-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;          /* children control their own spacing */
    width: 100%;
    padding: 0.75rem 0 0;
}

/* Buttons sit snug under the preview */
.stats-share-block .share-preview {
    margin-bottom: 0.4rem;
}

/* Space below the buttons separates them from the next section */
.stats-share-block .share-buttons {
    margin-bottom: 1.25rem;
}

/* Pre-formatted share text preview */
.share-preview {
    background: rgba(0, 0, 0, 0.04);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    text-align: center;
    font-size: 0.95rem;
    line-height: 1.55;
    width: 100%;
    box-sizing: border-box;
    word-break: break-word;
}

.share-preview-line {
    min-height: 1.4em;
}

/* Row of Share + Copy buttons */
.share-buttons {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Secondary (Copy) button — outline style */
.share-button--secondary {
    background-color: transparent !important;
    border: 2px solid var(--accent, #8079d2);
    color: var(--accent, #8079d2) !important;
}

.share-button--secondary:hover {
    background-color: rgba(0, 0, 0, 0.04) !important;
}

/* ==========================================
   AFFIX-SPECIFIC DISTRIBUTION OVERRIDES
   Slimmer rows for the 11-bucket word chart
   ========================================== */

.affix-distribution .distribution-label {
    font-size: 12px;
    width: 24px;
    font-weight: normal;
    font-variant-numeric: tabular-nums;
}

.affix-distribution .distribution-bar-container {
    height: 18px;
    border-radius: 3px;
}

.affix-distribution .distribution-bar {
    border-radius: 3px;
    padding-right: 5px;
}

.affix-distribution .distribution-count {
    font-size: 11px;
    font-weight: 600;
}

.affix-distribution .distribution-row {
    gap: 6px;
}

.affix-distribution .distribution-chart {
    gap: 3px;
}

.affix-distribution .distribution-today-marker {
    font-size: 11px;
    color: rgba(85, 85, 85, 0.6);
    flex-shrink: 0;
    white-space: nowrap;
}

.distribution-today-marker {
    display: none; /* hidden by default; affix-distribution overrides this */
}


/* ==========================================
   PROFILE SETUP BANNER
   Shown on games list when username/first/last
   name aren't all set yet.
   ========================================== */

.profile-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 16px 8px;
    padding: 14px 16px;
    background: color-mix(in srgb, var(--accent, #8079d2) 8%, transparent);
    border: 2px solid var(--accent, #8079d2);
    border-radius: 8px;
}

.profile-banner-text {
    font-size: 14px;
    line-height: 1.4;
    color: var(--ink, #555);
}

.profile-banner-button {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border-radius: 20px;
    background: var(--accent, #8079d2);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.profile-banner-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

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

/* Stack on very narrow screens so the button doesn't get squeezed */
@media (max-width: 360px) {
    .profile-banner {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .profile-banner-button {
        justify-content: center;
    }
}

/* ==========================================
   AUTH PAGES (login / signup / verify / password reset)
   ========================================== */

   .auth-logo {
    padding-top: 32px;
  }
  
  .auth-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
  }
  
  .account-form.auth-form {
    max-width: 400px;
    width: 100%;
    margin: 0 auto;
    gap: 14px;
  }
  
  .auth-inline-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: -2px;
  }
  
  .auth-show-password {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--ink, #555);
  }
  
  .auth-show-password input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent, #8079d2);
    cursor: pointer;
  }
  
  .auth-forgot-link {
    font-size: 0.85rem;
    color: var(--accent, #8079d2);
    text-decoration: none;
    white-space: nowrap;
  }
  
  .auth-forgot-link:hover {
    text-decoration: underline;
  }
  
  .auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #aaa;
    font-size: 0.85rem;
    margin: 20px auto;
    max-width: 400px;
  }
  
  .auth-divider::before,
  .auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e8e8e8;
  }
  
  .google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: 12px 24px;
    border-radius: 8px;
    background: #fff;
    color: var(--ink, #555);
    border: 1px solid #ddd;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    transition: all 0.2s ease;
  }
  
  .google-btn:hover {
    background: #f8f8f8;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  }
  
  .google-btn svg {
    flex-shrink: 0;
  }
  
  .auth-submit {
    max-width: 400px;
    width: 100%;
    margin: 6px auto 0;
    display: block;
  }
  
  .auth-footer-link {
    text-align: center;
    margin-top: 16px;
    font-size: 0.9rem;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
  }
  
  .password-requirements {
    list-style: none;
    padding: 0;
    margin: 4px 0 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  
  .password-requirement {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #999;
    transition: color 0.15s ease;
  }
  
  .password-requirement-icon {
    font-size: 0.9rem;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
  }
  
  .password-requirement.met {
    color: #28a745;
  }