/* ------ Base / tokens ------ */
:root{
    --bg: #FFEBCD;         /* Moccasin */
    --brand: #FF6347;      /* Tomato */
    --brand-d: #FF4500;    /* Orange Red */
    --ink: #333;
    --ink-2: #696969;
    --radius: 14px;
    --shadow: 0 6px 18px rgba(0,0,0,.12);
  }
  
  *,
  *::before,
  *::after { box-sizing: border-box; }
  
  html, body {
    height: 100%;
  }
  
  body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.45;
  }
  
  /* Hide the main content initially */
  .hidden { display: none; }
  
  /* ------ Layout wrappers ------ */
  .container{
    width: 100%;
    max-width: 720px;            /* nicer on desktop */
    margin: 0 auto;
    padding: 24px 20px;
  }
  
  .splash{ text-align: center; }
  
  .splash h1{
    font-size: clamp(28px, 4vw, 42px);
    margin: 20px 0 10px;
    color: var(--brand);
  }
  
  .splash p{ font-size: clamp(16px, 2.2vw, 18px); color: var(--ink-2); }
  
  .streak-display{ font-size: 18px; margin-top: 10px; color: var(--ink); }
  
  /* ------ Buttons ------ */
  button{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 20px auto;
    padding: 12px 24px;
    background: var(--brand);
    color: #fff;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    transition: background .2s, transform .1s;
    box-shadow: var(--shadow);
  }
  button:hover{ background: var(--brand-d); transform: translateY(-1px); }
  button:active{ transform: translateY(0); }
  
  /* Special champion share button */
  .champion-share {
    background: linear-gradient(45deg, #FFD700, #FFA500, #FF6347) !important;
    color: #333 !important;
    font-weight: bold !important;
    animation: champion-pulse 2s ease-in-out infinite !important;
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.4) !important;
    border: 2px solid #FFD700 !important;
  }
  
  .champion-share:hover {
    background: linear-gradient(45deg, #FFA500, #FF6347, #FF4500) !important;
    transform: translateY(-2px) scale(1.02) !important;
    box-shadow: 0 12px 35px rgba(255, 215, 0, 0.6) !important;
  }
  
  @keyframes champion-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
  }
  
  /* ------ Card / quiz container ------ */
  .quiz-container{
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.75rem;
    text-align: center;
    margin: 0 auto;
    width: 100%;
  }
  
  @media (max-width: 768px){
    .quiz-container{ padding: 1.25rem; margin: 0 10px; }
  }
  
  h1{
    font-size: clamp(22px, 3.2vw, 32px);
    margin: 0 0 1rem;
    color: var(--brand-d);
    line-height: 1.25;
  }
  
  #question{
    font-size: clamp(16px, 2.4vw, 20px);
    margin-bottom: 1.25rem;
    color: var(--ink);
  }
  
  /* ------ Choices ------ */
  .choices{
    display: grid;
    gap: 12px;
    margin: 1.25rem 0;
  }
  
  /* two columns on larger screens for nicer desktop density */
  @media (min-width: 768px){
    .choices{ grid-template-columns: 1fr 1fr; }
  }
  
  .choices button{
    width: 100%;
    margin: 0;
    padding: 12px 18px;
    background: var(--brand);
    border-radius: 10px;
    font-size: 16px;
    transition: background .2s, transform .1s, box-shadow .2s;
    box-shadow: 0 2px 6px rgba(0,0,0,.1);
  }
  .choices button:hover{
    background: var(--brand-d);
    transform: translateY(-1px);
    box-shadow: 0 6px 12px rgba(0,0,0,.13);
  }
  .choices button:active{ transform: translateY(0); }
  
  /* ------ Correct/incorrect list ------ */
  #correct-answers{ margin-top: 20px; text-align: center; }
  #correct-answers h2{ font-size: 22px; color: var(--brand-d); }
  #correct-answers-list{ list-style: none; padding: 0; }
  #correct-answers-list li{ font-size: 18px; margin: 6px 0; color: var(--ink); }
  
  .correct-answers{ color: #008000; }
  
  .correct::before,
  .incorrect::before{
    display: inline-block;
    width: 1.25em;               /* keeps icons aligned */
    content: '';
    margin-right: 6px;
    font-size: 20px;
  }
  .correct::before{ content: '✅'; color: #008000; }
  .incorrect::before{ content: '❌'; color: red; }
  
  /* ------ Result card ------ */
  #result-container{
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 24px;
    text-align: center;
    animation: slide-up .5s ease-in-out;
  }
  #result-container h2{ color: var(--ink-2); }
  #score{ font-size: 36px; color: var(--brand); }
  
  @keyframes slide-up{
    from{ transform: translateY(50px); opacity: 0; }
    to{ transform: translateY(0); opacity: 1; }
  }
  
  /* ------ Celebration overlay ------ */
  #result-animation-container{
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    animation: explodeEmojis 1.5s ease-in-out;
  }
  @keyframes explodeEmojis{ from{opacity:0; transform:scale(0)} to{opacity:1; transform:scale(1)} }
  
  .emoji{
    position: absolute;
    font-size: 48px;
    opacity: 0;
    animation: explode 1s ease-in-out forwards;
  }
  @keyframes explode{
    from{ opacity:0; transform:translate(0,0) scale(0); }
    to{ opacity:1; transform:translate(-50%,-50%) scale(1); }
  }
  @keyframes explodeFadeOut{ to{ opacity:0; } }
  
  /* ------ Tips UI ------ */
  #tips-container{
    background: #f8f8f8;
    border: 1px solid #ddd;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin: 30px 0;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  
  #tips-input{
    padding: 12px 16px;
    width: 100%;
    min-height: 110px;
    margin-bottom: 12px;
    border: 2px solid var(--brand);
    border-radius: 10px;
    outline: none;
    font-size: 18px;
    font-family: inherit;
    box-shadow: 0 2px 4px rgba(0,0,0,.08);
    transition: border-color .25s, box-shadow .25s;
    resize: vertical;
  }
  #tips-input:focus{
    border-color: var(--brand-d);
    box-shadow: 0 3px 10px rgba(0,0,0,.12);
  }
  
  #tips-button{
    padding: 10px 20px;
    width: min(500px, 100%);
    border: 0;
    border-radius: 10px;
    background: var(--brand);
    color: #fff;
    cursor: pointer;
    transition: background .2s;
    box-shadow: var(--shadow);
  }
  #tips-button:hover{ background: var(--brand-d); }
  
  #tips-container pre{
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 14px;
    box-shadow: 0 2px 4px rgba(0,0,0,.08);
    font-family: inherit;
    font-size: 16px;
    color: var(--ink);
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 16px;
    width: 100%;
    overflow-x: auto;
  }
  #tips-container pre::-webkit-scrollbar{ height: 8px; }
  #tips-container pre::-webkit-scrollbar-thumb{ background: var(--brand); border-radius: 4px; }
  
  /* ------ Loader ------ */
  .broccoli-loader{ font-size: 40px; animation: spin 2s linear infinite; }
  @keyframes spin{ to{ transform: rotate(360deg); } }
  
  /* ------ Game board ------ */
  #game-description{ color: var(--ink-2); }
  #move-counter{ color: var(--ink-2); font-style: oblique; font-weight: 700; }
  
  #game-container{
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 20px auto;
    padding: 12px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 360px;          /* mobile/tablet default */
  }
  
  .tile{
    display: grid;
    place-items: center;
    border: 2px solid var(--brand);
    background: #fff;
    aspect-ratio: 1 / 1;       /* perfect squares */
    font-size: clamp(36px, 6vw, 56px);
    cursor: pointer;
    border-radius: 10px;
  }
  .tile:hover{ background: var(--bg); }
  
  /* Scale up the board & tile size on larger screens */
  @media (min-width: 768px){
    #game-container{ max-width: 480px; gap: 10px; padding: 14px; }
    .tile{ font-size: clamp(44px, 3.5vw, 64px); }
  }
  @media (min-width: 1024px){
    #game-container{ max-width: 560px; gap: 12px; padding: 16px; }
    .tile{ font-size: clamp(52px, 2.6vw, 72px); }
  }
  
    /* ------ Veggie Catch (results page mini-game) ------ */
    .veggie-card{ 
      background: #fff; 
      border-radius: var(--radius); 
      box-shadow: var(--shadow); 
      padding: 16px; 
      margin-bottom: 20px;
    }
    
    .veggie-header{ 
      display: flex; 
      align-items: center; 
      justify-content: space-between; 
      margin-bottom: 12px;
      flex-wrap: wrap;
      gap: 8px;
    }
    
    .veggie-title{ 
      margin: 0; 
      font-size: clamp(18px, 3vw, 24px); 
      color: var(--brand-d); 
      font-weight: 700;
    }
    
    .veggie-hud{ 
      display: flex; 
      gap: 8px; 
      align-items: center; 
      flex-wrap: wrap;
    }
    
    .veggie-badge{ 
      background: #f8f9fa; 
      padding: 6px 12px; 
      border-radius: 20px; 
      font-weight: 600; 
      font-size: 14px;
      border: 1px solid #e9ecef;
      min-width: 60px;
      text-align: center;
    }
    
    /* Mobile HUD improvements */
    @media (max-width: 768px) {
      .veggie-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
      }
      
      .veggie-hud {
        width: 100%;
        justify-content: space-between;
      }
      
      .veggie-badge {
        flex: 1;
        font-size: 13px;
        padding: 8px 6px;
      }
      
      .veggie-card {
        padding: 12px;
      }
    }
    .veggie-stage{ 
      position: relative; 
      width: 100%;
      max-width: 100%;
      margin: 0 auto;
    }
    
    #vc-canvas{ 
      display: block; 
      width: 100%; 
      /* Fallback height for browsers without aspect-ratio support */
      height: 540px;
      /* Maintain aspect ratio to prevent squeezing - made taller */
      aspect-ratio: 900 / 540;
      max-height: 540px;
      background: linear-gradient(180deg,#eaf6ef,#e8f4ff); 
      border-radius: 12px; 
      touch-action: none; 
      -webkit-user-select: none; 
      user-select: none; 
      font-family: -apple-system, system-ui, sans-serif;
      box-shadow: 0 4px 20px rgba(0,0,0,0.1);
      border: 1px solid rgba(255,255,255,0.3);
      /* Prevent image scaling distortion */
      object-fit: contain;
    }
    
    /* For browsers that support aspect-ratio, override height to auto */
    @supports (aspect-ratio: 1) {
      #vc-canvas {
        height: auto;
      }
    }
    
    /* Mobile optimizations */
    @media (max-width: 768px){
      #vc-canvas{ 
        /* Fallback height for older browsers */
        height: 480px;
        max-height: 480px;
        border-radius: 8px;
        /* Ensure proper aspect ratio on tablet */
        aspect-ratio: 900 / 540;
      }
      
      @supports (aspect-ratio: 1) {
        #vc-canvas {
          height: auto;
        }
      }
      
      .container {
        padding: 16px 12px;
      }
    }
    
    @media (max-width: 480px){
      #vc-canvas{ 
        /* Fallback height for older browsers */
        height: 420px;
        max-height: 420px;
        border-radius: 6px;
        /* Maintain aspect ratio on mobile phones */
        aspect-ratio: 900 / 540;
        width: 100%;
      }
      
      @supports (aspect-ratio: 1) {
        #vc-canvas {
          height: auto;
        }
      }
      
      .container {
        padding: 16px 10px; /* slightly more padding for better touch */
      }
      
      /* Ensure container doesn't squeeze the canvas */
      .veggie-stage {
        width: 100%;
        overflow: visible;
        margin-bottom: 16px; /* better spacing */
      }
      
      /* Better mobile button spacing */
      .veggie-controls {
        gap: 12px;
        margin-top: 16px;
      }
      
      .veggie-controls button {
        min-height: 48px; /* better touch targets */
        font-size: 16px;
        padding: 12px 24px;
      }
    }
    
    /* Desktop enhancements */
    @media (min-width: 769px){
      .veggie-stage {
        max-width: 680px;
      }
      #vc-canvas{ 
        height: 580px;
      }
    }
    
    /* Game instructions styling */
    .veggie-hint {
      font-size: 14px;
      line-height: 1.4;
      color: #666;
      margin: 8px 0 12px 0 !important;
      text-align: center;
    }
    
    /* Best scores section */
    .veggie-best-scores {
      display: flex;
      gap: 12px;
      margin-top: 10px;
      flex-wrap: wrap;
    }
    
    .veggie-best-item {
      flex: 1;
      background: linear-gradient(135deg, #f8f9fa, #e9ecef);
      border: 1px solid #dee2e6;
      border-radius: 12px;
      padding: 10px 12px;
      text-align: center;
      min-width: 140px;
    }
    
    .best-label {
      display: block;
      font-size: 11px;
      font-weight: 600;
      color: #6c757d;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      margin-bottom: 2px;
    }
    
    .best-value {
      display: block;
      font-size: 18px;
      font-weight: 700;
      color: var(--brand-d);
    }
    
    /* Daily champion styling */
    .veggie-best-item:first-child {
      background: linear-gradient(135deg, #fff3cd, #ffeaa7);
      border-color: #ffc107;
    }
    
    .veggie-best-item:first-child .best-value {
      color: #b8860b;
    }
    
    @media (max-width: 768px) {
      .veggie-hint {
        font-size: 13px;
        margin: 6px 0 10px 0 !important;
      }
      
      .veggie-best-scores {
        gap: 8px;
        margin-top: 8px;
      }
      
      .veggie-best-item {
        min-width: 120px;
        padding: 8px 10px;
      }
      
      .best-label {
        font-size: 10px;
      }
      
      .best-value {
        font-size: 16px;
      }
    }
    
    @media (max-width: 480px) {
      .veggie-hint {
        font-size: 12px;
        line-height: 1.3;
      }
      
      .veggie-best-scores {
        flex-direction: column;
        gap: 6px;
      }
      
      .veggie-best-item {
        min-width: 100%;
        padding: 8px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: left;
      }
      
      .best-label {
        font-size: 11px;
        margin-bottom: 0;
      }
      
      .best-value {
        font-size: 16px;
      }
    }
  .veggie-final{ position:absolute; inset:0; background:rgba(0,0,0,0.45); display:none; flex-direction:column; align-items:center; justify-content:center; border-radius:8px; padding:16px; color:#fff; }
  .veggie-final:not(.hidden){ display:flex; }
    .veggie-controls{ 
      display: flex; 
      gap: 10px; 
      flex-wrap: wrap; 
      align-items: center; 
      margin-top: 12px;
      justify-content: center;
    }
    
    .veggie-controls .center{ 
      flex: 1; 
      display: flex; 
      justify-content: center; 
      gap: 10px; 
      min-width: 200px;
    }
    
    .veggie-controls button {
      min-width: 80px;
      font-size: 16px;
      padding: 10px 16px;
    }
    
    /* Mobile controls improvements */
    @media (max-width: 768px) {
      .veggie-controls {
        gap: 8px;
        margin-top: 10px;
      }
      
      .veggie-controls .center {
        min-width: 100%;
        gap: 8px;
      }
      
      .veggie-controls button {
        flex: 1;
        min-width: 70px;
        font-size: 15px;
        padding: 12px 8px;
      }
    }
    .veggie-row{ display:flex; gap:8px; align-items:center; margin-top:8px; }
    .veggie-leaderboard .lb-row{ display:flex; justify-content:space-between; padding:6px 8px; border-radius:6px; background:#ffffff22; margin-bottom:6px; color:#fff; }


  