/* ============================================
   RESET & BASE
   ============================================ */

   * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }
  
  body {
    overflow: hidden;
    font-family: 'VCR OSD Mono', monospace;
    background: #000000;
    color: #ffffff;
    width: 100vw;
    height: 100vh;
  }
  
  /* ============================================
     PARALLAX BACKGROUND
     ============================================ */
  
  .parallax-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
  }
  
  #bg-image {
    position: absolute;
    min-width: 120%;
    min-height: 120%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    filter: blur(8px);
    will-change: transform;
    transition: transform 0.1s ease-out;
  }
  
  /* ============================================
     GAME CONTAINER - CENTERED & SCALED
     ============================================ */
  
  .game-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 800px;
    height: 900px;
    max-width: 95vw;
    max-height: 95vh;
    overflow: hidden;
  }
  
  /* Fallback scaling for smaller viewports */
  @media (max-width: 850px), (max-height: 950px) {
    .game-container {
      transform: translate(-50%, -50%) scale(min(calc(95vw / 800), calc(95vh / 900)));
      transform-origin: center;
    }
  }
  
  /* ============================================
     SCREENS
     ============================================ */
  
  .screen {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
  }
  
  .screen.active {
    opacity: 1;
    pointer-events: all;
  }
  
  /* ============================================
     START SCREEN
     ============================================ */
  
  #start-screen {
    gap: 20px;
  }
  
  .logo {
    width: 300px;
    height: auto;
  }
  
  .game-title {
    font-size: 42px;
    text-align: center;
  }
  
  .pixel-button {
    border: 4px solid #ffffff;
    padding: 12px 36px;
    font-size: 22px;
    font-family: 'VCR OSD Mono', monospace;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    background: #333333;
    color: #ffffff;
  }
  
  .pixel-button.orange {
    background: #FF8C00;
  }
  
  .pixel-button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
  }

  .pixel-button.green {
    background: #2ecc71;
  }
  
  .pixel-button.green:hover {
    background: #34d27c;
  }  
  
  .pixel-button:active {
    transform: scale(0.95);
  }
  
  /* ============================================
     GAME SCREEN - UNIFIED CENTERED LAYOUT
     ============================================ */
  
  #game-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    padding: 70px 20px 20px;
    overflow-y: auto;
  }
  
  /* ============================================
     TOP UI BAR - FIXED POSITION
     ============================================ */
  
  .score-container {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #FFD700;
    padding: 8px 16px;
    font-size: 24px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 10;
    height: 44px;
    box-sizing: border-box;
  }
  
  .score-label {
    color: #FFFFFF;
  }
  
  .score-value {
    color: #FFFFFF;
    font-weight: bold;
    transition: transform 0.3s ease, color 0.3s ease;
  }
  
  .mute-button {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    border: 2px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    font-size: 18px;
    box-sizing: border-box;
  }
  
  .mute-button:hover {
    background: rgba(0, 0, 0, 0.95);
    border-color: #FFD700;
  }
  
  .progress-indicator {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 8px 14px;
    border: 2px solid #888;
    font-size: 16px;
    z-index: 10;
    height: 44px;
    display: flex;
    align-items: center;
    box-sizing: border-box;
  }
  
  /* 確保 progress-indicator 與其他頂部元素底部對齊 */
  #game-screen .progress-indicator {
    top: 10px;
  }
  

  
  /* ============================================
     CHARACTERS - SIDE BY SIDE (BUNNY LEFT, NPC RIGHT)
     ============================================ */
  
  .character-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
  }
  
  .character-sprite {
    width: 100px;
    height: 100px;
    image-rendering: pixelated;
    object-fit: contain;
    animation: sprite-idle 2s ease-in-out infinite;
  }
  
  @keyframes sprite-idle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
  }

  /* Characters row: bunny (left) and NPC (right) on the same baseline */
.characters-row {
  width: 100%;
  max-width: 700px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;   /* align by bottom of sprite */
  margin: -1.5rem auto 0.5rem;   /* negative top margin to move up, small gap below */
  order: 2;                /* sits after the progress indicator */
}

/* Each character container still stacks its own content vertically */
.character-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
}

/* Container reset – no weird margins or padding */
#bunny-container,
#npc-container {
  position: relative;
  margin: 0;
  padding: 0;
}

/* Sprite sizes; both characters get same dimensions */
.character-sprite {
  width: 100px;
  height: 100px;
  image-rendering: pixelated;
  object-fit: contain;
  animation: sprite-idle 2s ease-in-out infinite;
}

/* Desktop: slightly larger, still aligned by baseline */
@media (min-width: 769px) {
  .character-sprite {
    width: 120px;
    height: 120px;
  }
}

/* Small screens: slightly smaller, still aligned by baseline */
@media (max-width: 500px), (max-height: 600px) {
  .character-sprite {
    width: 80px;
    height: 80px;
  }
}

  
  /* ============================================
     UNIFIED TEXTBOX - SINGLE ELEMENT
     ============================================ */
  
  .textbox.unified-box {
    width: 90%;
    max-width: 600px;
    background: rgba(0, 0, 0, 0.92);
    border: 3px solid #ffffff;
    padding: 16px;
    font-size: 16px;
    line-height: 1.6;
    color: #ffffff;
    min-height: 100px;
    max-height: 180px;
    overflow-y: auto;
    text-align: left;
    margin: 0.5rem auto;
    z-index: 3;
    order: 4;
  }
  
  /* Story text (bunny) - with emoji prefix */
  #story-text:not(:empty) {
    margin-bottom: 0.8rem;
    padding-bottom: 0.8rem;
    border-bottom: 2px solid #555;
    color: #87CEEB;
  }
  
  #story-text:not(:empty)::before {
    content: '🐰: ';
    font-weight: bold;
  }
  
  /* Question text (NPC) - with emoji prefix and color */
  #question-text:not(:empty) {
    color: #FFD700;
  }
  
  #question-text:not(:empty)::before {
    content: '❓: ';
    font-weight: bold;
  }
  
  /* Hide old textboxes */
  .textbox.story-box,
  .textbox.question-box {
    display: none;
  }
  
  /* ============================================
     ANSWER OPTIONS - RESPONSIVE GRID
     ============================================ */
  
  .answers-container {
    width: 90%;
    max-width: 600px;
    display: grid;
    grid-template-columns: 1fr;   /* 1 column by default */
    gap: 12px;
    z-index: 5;
    margin: 1rem auto 0;
    order: 5;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
  }
  
  /* Custom scrollbar for answers-container */
  .answers-container::-webkit-scrollbar {
    width: 8px;
  }
  
  .answers-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
  }
  
  .answers-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 4px;
  }
  
  .answers-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.7);
  }
  
  .game-container.desktop-layout .answers-container {
    grid-template-columns: 1fr 1fr;
    max-width: 700px;
  }

  .answers-wrapper {
    width: 90%;
    max-width: 600px;
    margin: 1rem auto 0;
    order: 5;           /* same order as answers before */
    position: relative; /* needed for clipping on mobile */
  }
  
  .answer-option {
    width: 100%;
    padding: 14px 12px;
    font-size: 15px;
    line-height: 1.3;
    font-family: 'VCR OSD Mono', monospace;
    background: rgba(50, 50, 50, 0.95);
    border: 3px solid #888888;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 60px;
    word-wrap: break-word;
  }
  
  .answer-option:hover {
    border-color: #ffffff;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    background: rgba(80, 80, 80, 0.95);
  }
  
  .answer-option:active {
    animation: pulse 0.2s ease;
  }
  
  .answer-option.correct-answer {
    background-color: #4CAF50 !important;
    border-color: #45a049 !important;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.6);
    transition: all 0.3s ease;
  }
  
  .answer-option.wrong-answer {
    background-color: #f44336 !important;
    border-color: #da190b !important;
    transform: scale(0.95);
    box-shadow: 0 0 20px rgba(244, 67, 54, 0.6);
    transition: all 0.3s ease;
  }
  

  @keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
  }
  
  /* Desktop: 2x2 grid for answers */
  @media (min-width: 769px) {
    .answers-container {
      max-width: 700px;
    }
    
    .answer-option {
      min-height: 70px;
    }
  }
  /* MOBILE LAYOUT TWEAKS */
@media (max-width: 768px) {

  /* Top UI: smaller and fixed to viewport */
  .score-container {
    position: fixed;
    top: 8px;
    left: 8px;
    font-size: 16px;        /* smaller score on mobile */
    padding: 4px 10px;
    border-width: 2px;
    z-index: 1000;
    height: 38px;
    display: flex;
    align-items: center;
    box-sizing: border-box;
  }

  .progress-indicator {
    position: fixed;        /* fixed to screen, not game box */
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    padding: 4px 10px;
    z-index: 1000;
    height: 38px;
    display: flex;
    align-items: center;
    box-sizing: border-box;
  }

  .mute-button {
    position: fixed;
    top: 8px;
    right: 8px;
    width: 38px;
    height: 38px;
    font-size: 16px;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }

  /* In‑game content starts below fixed top bar */
  #game-screen {
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;  
  }

  /* Characters not pulled up on mobile */
  #bunny-container,
  #npc-container {
    margin-top: 0;
  }

  /* Move characters row up on mobile */
  .characters-row {
    margin-top: -1rem;
  }

  /* Question/story box: slightly reduced bottom margin */
  .textbox.unified-box {
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;   /* tighter gap to answers than before */
  }

  /* Scrollable answers box: closer to textbox */
  .answers-wrapper {
    width: 90%;
    max-width: 600px;
    margin: 0.25rem auto 0;   /* smaller gap under textbox */
    position: relative;
    background: transparent;
  }

  .answers-container {
    position: relative;
    z-index: 1;
    padding: 6px 4px 10px;
    margin: 0 auto 0;         /* REMOVE extra top margin on mobile */
    background: transparent;
    max-height: 40vh;
    overflow-y: auto;
    overflow-x: hidden;
  }
}

  
  /* ============================================
     ANIMATIONS
     ============================================ */
  
  @keyframes hop {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
  }
  
  .hopping {
    animation: hop 0.5s ease-in-out;
  }
  
  /* ============================================
     ENDING SCREEN
     ============================================ */
  
     #ending-screen {
      position: fixed !important;
      top: 0 !important;
      left: 0 !important;
      width: 100vw !important;
      height: 100vh !important;
      transform: none !important;
      padding: 3vh 4vw;
      overflow-y: auto;
      justify-content: center;  /* Changed from flex-start */
    }
    @media (max-height: 600px) {
      #ending-screen {
        justify-content: flex-start;  /* Revert to top-align for short viewports to avoid clipping */
      }
    }
    
  .ending-title {
    font-size: 48px;
    text-align: center;
    margin-bottom: 12px;
  }
  
  .ending-description {
    font-size: 18px;
    max-width: 600px;
    text-align: center;
    line-height: 1.6;
  }
  
  .score-summary {
    font-size: 24px;
    text-align: center;
    margin: 16px 0;
  }
  
  .ending-characters {
    display: flex;
    gap: 30px;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
  }
  
  .ending-characters img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    image-rendering: pixelated;
  }

  #ending-npc {
    display: none;
  }
  
  .ending-buttons {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 16px;              /* space between the two buttons */
    width: 100%;
    max-width: 480px;       /* match .discount-container / discount-box width */
    margin: 32px auto 0;    /* centered under the discount box */
  }
  
  .ending-buttons .pixel-button {
    flex: 1 1 0;            /* each takes half the available width */
    text-align: center;
  }

  @media (max-width: 480px) {
    .ending-buttons .pixel-button {
      padding: 8px 12px;    /* less horizontal padding */
      font-size: 18px;      /* slightly smaller to avoid wrap */
      white-space: nowrap;  /* force single-line text */
    }
  }
  
  
  /* ============================================
     DISCOUNT CODE
     ============================================ */

.discount-container {
  width: 100%;
  max-width: 480px;
  margin: 24px auto 0;
}

.discount-box {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: 4px solid #FFD700;
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.discount-title {
  font-size: 24px;
  color: #FFD700;
  margin-bottom: 16px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

/* Code + vertical copy button side-by-side */
.discount-code-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 20px 0;
}

.discount-code-text {          /* replaced #discount-code-text */
  font-size: 32px;
  font-weight: bold;
  color: #FFFFFF;
  background: rgba(0, 0, 0, 0.4);
  padding: 12px 28px;
  border: 3px dashed #FFD700;
  border-radius: 10px;
  letter-spacing: 3px;
  min-width: 240px;
  text-align: center;
}

/* Fixed vertical copy button – matches your mockup perfectly */
.copy-button.vertical {
  writing-mode: vertical-rl;
  text-orientation: upright;          /* <─ This makes 複製 display correctly upright */
  width: 56px;
  height: 140px;                      /* same height as the code box */
  padding: 0;
  font-size: 28px;
  font-weight: bold;
  font-family: 'VCR OSD Mono', monospace;
  background: #FF8C00;
  border: 6px solid #FFFFFF;          /* thick white border like in your picture */
  color: #FFFFFF;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.copy-button.vertical:hover {
  background: #FFA500;
  transform: scale(1.06);
  box-shadow: 0 8px 20px rgba(0,0,0,0.5);
}

/* Mobile – normal horizontal button */
@media (max-width: 480px) {
  .discount-code-row {
    flex-direction: column;
  }
  .copy-button.vertical {
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    width: 160px;
    height: 56px;
    font-size: 24px;
  }
}

.discount-subtitle {
  font-size: 20px;
  color: #FFD700;
  margin: 8px 0 16px;
  font-weight: bold;
}

.discount-description {
  font-size: 18px;
  color: #FFFFFF;
  margin: 12px 0 4px 0;
  line-height: 1.6;
}

.discount-expiry {
  font-size: 15px;
  color: #FFD700;
  font-style: italic;
  margin-top: 12px;
}

/* Mobile fallback – horizontal layout on small screens */
@media (max-width: 480px) {
  .discount-code-row {
    flex-direction: column;
    gap: 12px;
  }
  .discount-code-text {
    font-size: 28px;
    min-width: 200px;
  }
  .copy-button.vertical {
    writing-mode: horizontal-tb;
    width: 120px;
    height: 44px;
  }
}

/* === Unified discount code layout: button always under code === */

.discount-code-row {
  display: flex;
  flex-direction: column;      /* Always vertical stack */
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 20px 0;
}

.discount-code-text {
  font-size: 32px;
  font-weight: bold;
  color: #FFFFFF;
  background: rgba(0, 0, 0, 0.4);
  padding: 12px 28px;
  border: 3px dashed #FFD700;
  border-radius: 10px;
  letter-spacing: 3px;
  min-width: 240px;
  text-align: center;
}

/* Copy button: now always horizontal, sits under the code */
.copy-button.vertical {
  writing-mode: horizontal-tb;  /* override old vertical */
  text-orientation: mixed;
  width: 100%;
  max-width: 240px;
  height: 52px;
  padding: 0 16px;
  font-size: 24px;
  font-weight: bold;
  font-family: 'VCR OSD Mono', monospace;
  background: #FF8C00;
  border: 6px solid #FFFFFF;
  color: #FFFFFF;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.copy-button.vertical:hover {
  background: #FFA500;
  transform: scale(1.06);
  box-shadow: 0 8px 20px rgba(0,0,0,0.5);
}

/* Optional: slightly smaller on very small screens, same layout */
@media (max-width: 480px) {
  .discount-code-text {
    font-size: 28px;
    min-width: 200px;
  }

  .copy-button.vertical {
    font-size: 20px;
    height: 48px;
    max-width: 220px;
  }
}

  
  /* ============================================
     SMALL SCREEN ADJUSTMENTS
     ============================================ */
  
  @media (max-width: 500px), (max-height: 600px) {
    .game-container {
      transform: translate(-50%, -50%) scale(min(calc(95vw / 800), calc(95vh / 900)));
    }
    
    .answer-option {
      font-size: 14px;
      padding: 12px 10px;
      min-height: 55px;
    }
    
    .textbox.unified-box {
      font-size: 14px;
      padding: 12px;
    }
    
    .character-sprite {
      width: 80px;
      height: 80px;
    }
  }
  
  /* ============================================
     LANDSCAPE ORIENTATION
     ============================================ */
  
  @media (orientation: landscape) and (max-height: 600px) {
    .game-container {
      height: 850px;
    }
    
    #game-screen {
      padding: 60px 20px 10px;
    }
    
    .textbox.unified-box {
      max-height: 120px;
      min-height: 80px;
    }
  }
  