/* --- MOBILE OPTIMIZATION FOR DOMAINKHAN GAME --- */

/* Mobile reset: html/body */
@media (max-width: 950px) {
  html, body {
    width: 100vw !important;
    min-width: 0 !important;
    max-width: 100vw !important;
    min-height: 100vh !important;
    max-height: 100vh !important;
    background: #f9f9f9 !important;
    font-size: 15px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
    height: 100% !important;
  touch-action: none !important; /* Prevent iOS rubber-band scroll */  }

  
#hud {
  position: fixed !important;
  top: 10px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  width: 60vw !important;
  max-width: 60vw !important;
  z-index: 999 !important;
  background: #fff !important;
  box-shadow: 0 4px 24px #29416725 !important;
  border-bottom-left-radius: 15px !important;
  border-bottom-right-radius: 15px !important;
  padding: 8px 3px 6px 3px !important;
  min-height: 38px !important;
  max-height: 60px !important;
  overflow: hidden !important;
  height: auto !important;
  /* ADDED: Prevent growing too tall */
}

#hud, #hud * {
  font-size: 13px !important;
}

  /* Container layout below HUD */
@media (max-width: 950px) {
  #container {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;        /* horizontal center only */
    justify-content: flex-start !important; /* stick to top, not center vertically */
    margin: 0 auto !important;
    padding: 0 !important;
    background: #fff !important;
    border-radius: 18px !important;        /* for rounded effect */
    box-shadow: 0 4px 30px #29416722 !important;  /* subtle shadow */
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    /* Remove forced height! */
    /* height: 100vh !important; */
    /* min-height: 100vh !important; */
    /* max-height: 100vh !important; */
    /* Remove position: fixed! Let it scroll if needed. */
    position: static !important;
    overflow: visible !important;
    z-index: 10 !important;
    box-sizing: border-box !important;
    /* Add a top margin if you want space from the very top */
    margin-top: 10px !important;
  }
}



  /* Overlays: intro/gameover */
  #intro, #gameover {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    z-index: 1500 !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    font-size: 1rem !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  #gameover {
    position: fixed !important;
    z-index: 10000 !important;
    width: 100vw !important;
    height: 100vh !important;
    left: 0 !important;
    top: 0 !important;
    background: #fff !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
  }




.playerinfo,
.playerinfo input,
.playerinfo select {
    width: 92vw !important;
    max-width: 330px !important;
    font-size: 1em !important;
    border-radius: 8px !important;
    box-sizing: border-box !important;
}

.intro-title {
  font-size: 2rem;
  font-weight: 800;
  margin: 15px 0 15px 0;
  text-align: center;
}


#startBtn, .restart-btn {
  width: 92% !important;
  max-width: 180px !important;
  font-size: 1.11em !important;
  padding: 11px 0 !important;
  margin: 14px auto 10px 0 !important;
}

.quote {
  font-size: 1em !important;
  margin: 8px 0 10px 0 !important;
  width: 98% !important;
  max-width: 95% !important;
}

  /* Gameover specifics */
  #gameover {
    max-width: 97vw !important;
    left: 0 !important;
    transform: none !important;
    padding: 0 4vw 24px 4vw !important;
    top: 0 !important;
    min-height: 60vh !important;
  }

  /* HUD row inside gameover, collapse for mobile */
  .go-inline {
    flex-direction: column !important;
    gap: 6px !important;
    font-size: 1em !important;
    text-align: center !important;
  }

  /* Remove scrollbars for cleaner look */
  ::-webkit-scrollbar {
    width: 0 !important;
    background: transparent !important;
  }
}

/* Tiny devices: reduce font/input padding further */
@media (max-width: 400px) {
  html, body, #container, #intro, #gameover {
    font-size: 14px !important;
    padding: 0 !important;
  }
  .playerinfo input, .playerinfo select {
    font-size: 1em !important;
    padding: 10px 4px !important;
  }
}

/* --- Ensure overlays truly hide on mobile too! --- */
#gameover.hide-overlay,
#intro.hide-overlay {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
  z-index: -1 !important;
}

@media (max-width: 950px) {
   #streakBox {
    position: fixed !important;
    top: 5px !important;
    left: 5px !important;
    z-index: 21 !important;
    border-radius: 8px !important;
    padding: 3px 10px 3px 9px !important;
    font-size: 0.8em !important;
    min-width: 78px !important;
    display: flex !important;
    align-items: center !important;
    height: 34px !important;
  }
  /* Add a margin-top to #container so streakBox doesn't overlap the HUD if needed */
  #container { margin-top: 20px !important; }
}

@media (max-width: 950px) {
  .hud-scorebar {
    font-size: 0.97em;
    gap: 6px;
    border-radius: 13px;
    padding: 6px 1vw;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px #25408918;
    backdrop-filter: blur(0.9px) saturate(1.01);
  }
  .hud-score-pill {
    font-size: 0.96em;
    padding: 4.5px 8px 4.5px 6px;
    margin-bottom: 2.5px;
  }
}
@media (max-width: 950px) {
  #streakBanner {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    font-size: 1.18em !important;
    padding: 10px 26px !important;
    border-radius: 14px !important;
    background: rgba(255, 251, 232, 0.85) !important;   /* Translucent to match desktop */
    color: #0b6b24 !important;
    font-weight: 900 !important;
    box-shadow: 0 2px 16px #1d225a33 !important;
    z-index: 2000 !important;
    min-width: 80px !important;
    max-width: 90vw !important;
    text-align: center !important;
    pointer-events: none !important;
    display: none;
    opacity: 1 !important;
    visibility: visible !important;
  }
}




@media (max-width: 950px) {
.intro-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0 !important;
  width: 100vw !important;
  max-width: 100vw !important;
  min-width: 0 !important;
  margin: 0 auto !important;
  padding: 0 !important;
  height: 340px !important; /* Set for landscape mobile, adjust if needed */
}

.intro-img-col {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: flex-start !important;    /* <--- Aligns image to the top */
  width: 50vw !important;
  min-width: 0 !important;
  max-width: 50vw !important;
  height: 100% !important;
  box-sizing: border-box !important;
  padding-top: 0 !important;                 /* Make sure there's no unwanted gap */
}


.intro-img {
  max-width: 75% !important;
  max-height: 280px !important;
  min-width: 100px !important;
  object-fit: contain !important;

  margin: 0 auto !important;
  display: block !important;

}
.intro-col-form {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  justify-content: center !important;
  width: 95% !important;
  min-width: 0 !important;
  max-width: 340px !important;
  height: 100% !important;
  box-sizing: border-box !important;
  padding-left: 12px !important;
}

.form-group {
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
  }

.form-group label {
  font-size: 1em !important;
  min-width: 65px !important;
}
.form-group input,
.form-group select {
  width: 98% !important;
  max-width: 95% !important;
  font-size: 1em !important;
  padding: 10px 10px !important;
  border-radius: 8px !important;
}

.intro-col-form input,
.intro-col-form select {
  width: 92% !important;
  max-width: 320px !important;
  min-width: 80px !important;
  font-size: 1em !important;
  padding: 10px 8px !important;
  border-radius: 8px !important;
}

.choices__inner {
  width: 95% !important;
  max-width: 210px !important;
  min-width: 80px !important;
}

#comboMeter {
  background: transparent !important;
  box-shadow: none !important;
}


}




/* MOBILE: Start Game bigger, Leaderboard 30% smaller, same row, both up by 10px */
@media (max-width: 950px) {
  .intro-btn-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    margin-top: 8px !important;  /* move up by 10px */
    width: 100% !important;
  }

  #startBtn {
    min-width: 100px !important;
    max-width: 45% !important;
    font-size: 1.35rem !important;
    padding: 15px 0 !important;
    font-weight: 800 !important;
    border-radius: 17px !important;
    box-shadow: 0 2px 12px #2563d82a !important;
    flex: none !important;
  }

   #nickname {
    width: 180px !important;
    min-width: 70px !important;
    max-width: 45vw !important;
    font-size: 1em !important;
    box-sizing: border-box !important;
    padding: 10px 6px !important;
    border-radius: 8px !important;
    margin: 0 !important;
    display: inline-block !important;
  }

 #leaderboardIntroBtn {
    min-width: 80px !important;
    max-width: 38vw !important; /* Shrink to fit, use vw for true responsive */
    font-size: 0.90rem !important;
    padding: 10px 14px 5px !important;
    border-radius: 12px !important;
    margin-right: 7vw !important; /* Gives a buffer from the right */
    box-sizing: border-box !important;
    text-align: center !important;
  }
  .intro-btn-row {
    gap: 5vw !important; /* Widen gap a bit for comfort */
  }
}
 
#rotateDeviceOverlay {
  display: none;  /* Default, JS will override */
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 15000 !important;
  background: rgba(255,255,255,0.98) !important;
  justify-content: center !important;
  align-items: center !important;
  flex-direction: column !important;
  text-align: center !important;
  pointer-events: auto !important;
  font-family: inherit !important;
  opacity: 1 !important;
  visibility: visible !important;
}

@media (max-width: 950px) {
  .intro-btn-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    margin-top: 12px !important;
  }
  #startBtn, #leaderboardIntroBtn {
    max-width: 90vw !important;
    min-width: 120px !important;
    width: 100% !important;
    margin: 0 auto !important;
  }
  #leaderboardIntroBtn {
    margin-bottom: 2px !important; /* extra space after leaderboard if you like */
  }
}

@media (max-width: 950px) {
  #startBtn, #leaderboardIntroBtn {
    width: 70% !important;
    max-width: 340px !important;
    min-width: 120px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    font-size: 1.16em !important;  /* optional: slightly smaller font if needed */
  }
}

#startBtn {
  font-size: 1.8rem !important;   /* Increase font size only */
  font-weight: 800 !important;    /* Ensures text looks bold and punchy */
  letter-spacing: 0.01em;
  line-height: 1.2;               /* Improves vertical centering */
}

@media (max-width: 950px) {
  /* StreakBox pinned left, compact */
  #streakBox {
    position: fixed !important;
    top: 13px !important;
    left: 5px !important;
    z-index: 21 !important;
    border-radius: 8px !important;
    padding: 3px 10px 3px 9px !important;
    font-size: 0.8em !important;
    box-shadow: 0 1px 4px #29416714;
    display: flex !important;
    align-items: center !important;
    height: 34px !important;
  }
  /* COMPACT HUD */
  

 #hud {
    position: fixed !important;
    top: 13px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 70vw !important;
    min-width: 155px !important;
    max-width: 370px !important;
    border-radius: 13px !important;
    z-index: 5000 !important;
    padding: 7px 10px !important; /* Remove left space for streak */
    font-size: 0.9em !important;
    box-shadow: 0 1px 9px #29416711 !important;
    background: #fff !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;     /* CENTER inner content! */
    justify-content: center !important;
    min-height: 34px !important;
    max-height: 60px !important;
    overflow: visible !important;
    margin: 0 auto !important;
  }
  #hud * {
    font-size: 0.97em !important;
    font-weight: 600 !important;
    line-height: 1.1;
    text-align: center !important;
  }
  
  /* HUD: Space for a single line of icons/numbers now! */
  #hud .hud-scorebar {
    width: 100% !important;
    margin: 0 auto !important;
    display: flex !important;
    justify-content: space-around !important;
    align-items: center !important;
    gap: 5px !important;
    font-size: 1em !important;
    padding: 4px 0 !important;
    background: #f4f6f9 !important;
    border-radius: 11px !important;
    min-height: 26px !important;
  }

  /* Responsive container for HUD+Streak on top */
  #container {
    margin-top: 60px !important;
  }
}


@media (max-width: 950px) {
  .hud-scorebar-row, #hud .hud-scorebar {
    width: 90% !important;
    margin: 0 auto !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 7px !important;
    font-size: 1em !important;
    padding: 4px 0 !important;
    background: #f4f6f9 !important;
    border-radius: 11px !important;
    min-height: 26px !important;
  }
}

@media (max-width: 950px) {
  .hud-top-row {
    font-size: 0.97em;
    margin-bottom: 2px;
    margin-left: 30px;
    
    text-align: center;
  }
  .hud-scorebar-row {
    font-size: 0.92em;
    border-radius: 9px;
        margin-left: 30px;

    padding: 4px 8px;
    gap: 8px;
    max-width: 40vw;
  }
  .hud-pill { font-size: 1em; }
}

@media (max-width: 950px) {
  #gameover {
    position: fixed !important;
    z-index: 10000 !important;
    width: 100vw !important;
    height: 100vh !important;
    left: 0 !important;
    top: 0 !important;
    background: #fff !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    overflow-y: auto !important;    /* <-- CRITICAL: Allow scroll if content overflows */
    overflow-x: hidden !important;
    padding-bottom: 36px !important;  /* space for last button */
  }

  .playerinfo {
    width: 97vw !important;
    max-width: 360px !important;
    min-width: 220px !important;
    margin: 0 auto 12px auto !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    overflow: visible !important;
  }
  #scoreCard {
    width: 95vw !important;
    max-width: 340px !important;
    min-width: 200px !important;
    height: auto !important;
    min-height: 250px !important;
    margin: 12px auto 0 auto !important;
    box-sizing: border-box !important;
    border-radius: 18px !important;
  }
  .scorecard-inner {
    width: 96% !important;
    height: auto !important;
    min-height: 200px !important;
    padding: 10px 6px !important;
    border-radius: 13px !important;
    box-sizing: border-box !important;
  }
  #restartBtn {
    margin: 18px auto 10px auto !important;
    display: block !important;
    width: 94vw !important;
    max-width: 330px !important;
    font-size: 1.1em !important;
    padding: 13px 0 !important;
    border-radius: 14px !important;
  }
  .gameover-actions.leaderboard-alone {
    margin: 15px 0 10px 0 !important;
    gap: 12px !important;
    flex-direction: column !important;
    width: 100% !important;
  }
}

@media (max-width: 950px) and (max-height: 500px) {
  #gameover {
    min-height: 120vh !important;
    height: auto !important;
  }
}


@media (max-width: 950px) {
  html, body, #container {
    overflow-x: hidden !important;
    overflow-y: visible !important;
    height: 100% !important;
    min-height: 100% !important;
    position: relative !important;
  }
  #gameover {
    overflow-y: auto !important;
    max-height: 100vh !important;
    min-height: 100vh !important;
    height: auto !important;
    padding-bottom: 50px !important;
    box-sizing: border-box !important;
    z-index: 50000 !important;
  }
  .gameover-actions {
    pointer-events: auto !important;
  }
  .playerinfo, #scoreCard, .scorecard-inner {
    pointer-events: auto !important;
  }
}


@media (max-width: 360px) {
  #scoreCard, .scorecard-inner {
    width: 98vw !important;
    max-width: 95vw !important;
    min-width: 0 !important;
    padding: 0 !important;
  }
}

@media (max-width: 950px) {
  #gameHeader {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    min-width: 100vw !important;
    max-width: 100vw !important;
    display: flex !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    background: none !important;
    z-index: 1000 !important;
    box-sizing: border-box !important;
    padding: 0 !important;
    margin: 0 !important;
    height: auto !important;
    pointer-events: none !important; /* So nothing inside is clickable, as you requested */
  }
  #hud {
    width: 70vw !important;
    max-width: 70vw !important;
    min-width: 0 !important;
    left: 0 !important;
    transform: none !important;
    border-radius: 0 0 15px 15px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    pointer-events: none !important;
  }
  #streakBox {
    position: fixed !important;
    top: 8px !important;
    left: 5px !important;
    z-index: 2000 !important;
    margin: 0 !important;
    border-radius: 8px !important;
    pointer-events: none !important;
  }
  #headerRight {
    position: absolute !important;
    right: 12px !important;
    top: 8px !important;
    z-index: 1101 !important;
    pointer-events: none !important;
  }
}

@media (max-width: 950px) {
  .playerinfo, #scoreCard, .scorecard-inner {
    width: 98vw !important;
    max-width: 350px !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
  }
}

html, body {
  overflow-x: hidden !important;
  width: 100vw !important;
  min-width: 0 !important;
  max-width: 100vw !important;
}

@media (max-width: 950px) {
  #canvas, #game, #gameover {
    border-radius: 0 !important;
    box-shadow: none !important;
  }
}

@media (max-width: 950px) {
  #hud {
    left: 0 !important;
    transform: none !important;
    width: 70vw !important;
    max-width: 70vw !important;
  }
  #streakBox {
    left: 5px !important;
    top: 8px !important;
  }
}


@media (max-width: 950px) {
  #gameHeader {
    /* No outline or debug border unless you want for dev */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: auto !important;
    z-index: 999 !important;
    display: flex !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    background: none !important;
    pointer-events: none !important;
  }
  #hud {
    position: fixed !important;
    top: 10px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 92vw !important; /* Not full width so StreakBox fits left */
    z-index: 5000 !important;
    border-radius: 0 0 15px 15px !important;
    margin: 0 !important;
    pointer-events: auto !important;
    box-sizing: border-box !important;
  }
  #streakBox {
    position: fixed !important;
    top: 10px !important;
    left: 5px !important;
    z-index: 10001 !important; /* Make this highest */
    min-height: 30px !important;
    box-shadow: 0 1px 4px #29416714;
    display: flex !important;
    align-items: center !important;
    pointer-events: auto !important;
  }
  /* If HUD needs to be 100vw, add left padding for StreakBox */
  /*
  #hud {
    width: 100vw !important;
    padding-left: 80px !important; // make sure streakBox isn't covered
  }
  */
}

@media (max-width: 950px) {
  #gameHeader {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 60px !important;
    z-index: 999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    background: none !important;
    pointer-events: none !important;
  }
  #streakBox {
    position: fixed !important;
    top: 10px !important;
    left: 8px !important;
    z-index: 10001 !important;
    pointer-events: auto !important;
    border-radius: 8px !important;
    min-height: 30px !important;
    box-shadow: 0 1px 4px #29416714;
    display: flex !important;
    align-items: center !important;
  }
  #hud {
    position: fixed !important;
    top: 5px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 54vw !important; /* 50-54% is sweet spot on mobile */
    min-width: 150px !important;
    max-width: 380px !important;
    z-index: 5000 !important;
    border-radius: 14px !important;
    margin: 0 !important;
    pointer-events: auto !important;
    background: #fff !important;
    box-sizing: border-box !important;
    text-align: center !important;
    padding: 8px 0 6px 0 !important;
    box-shadow: 0 1px 9px #29416711 !important;
  }
  #headerRight {
    position: fixed !important;
    top: 10px !important;
    right: 8px !important;
    z-index: 10001 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 10px !important;
    pointer-events: auto !important;
    background: none !important;
  }

}

@media (max-width: 950px) {
  #hearts {
    position: fixed !important;
    left: 50% !important;
    top: 75px !important;           /* Just under HUD, adjust as needed */
    transform: translateX(-50%) !important;
    font-size: 19px !important;
    letter-spacing: 1.5px !important;
    background: none !important;
    box-shadow: none !important;
    width: auto !important;
    padding: 0 !important;
    z-index: 10200 !important;
    text-align: center !important;
    height: 26px !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    pointer-events: none !important;  /* Not clickable, change to auto if needed */
  }
}


@media (max-width: 950px) {
  #streakBox {
    height: 26px !important;              /* Reduce height */
    min-height: 20px !important;
        max-width: 50vh !important;

    padding: 1px 8px !important;          /* Less vertical padding */
    border-radius: 7px !important;        /* Slightly more compact */
    font-size: 0.92em !important;
    display: flex !important;
    align-items: center !important;
  }
  #comboMeter, .comboTrack {
    height: 18px !important;              /* Smaller combo bar, if visible */
    min-height: 0 !important;
    padding: 0 !important;
  }
  #streakLabel {
    font-size: 1em !important;
    line-height: 1 !important;
    padding: 0 !important;
  }
}



/* --- Responsive for mobile --- */
@media (max-width: 600px) {
  .gameover-top-actions {
    gap: 4px !important;
    max-width: 99vw;
  }
  .gameover-top-actions .restart-btn {
    height: 34px !important;
    font-size: 0.99em !important;
    padding: 0 13px !important;
    border-radius: 7px;
  }
  .gameover-top-actions .leaderboard-link.small {
    height: 32px !important;
    font-size: 0.92em !important;
    padding: 0 8px !important;
    border-radius: 6px;
  }
  #leaderboardGameoverBtn {
    padding: 0 7px !important;
    min-width: 28px !important;
    max-width: 34px !important;
  }
}
/* Mobile/Responsive overrides */
@media (max-width: 600px) {
  .gameover-top-actions {
    gap: 4px;
    margin-bottom: 8px;
  }
  .restart-btn {
    font-size: 0.95em;
    height: 32px;
    min-width: 80px;
    padding: 0 9px;
    border-radius: 7px;
  }
  .leaderboard-link.small {
    font-size: 0.93em;
    height: 30px;
    padding: 0 6px;
    border-radius: 6px;
    min-width: 26px;
  }
}
@media (max-width: 950px) {
  /* Make gameover buttons row look compact and aligned */
  .gameover-top-actions {
    display: flex !important;
    flex-direction: row !important;
    justify-content: center !important;
    align-items: flex-start !important;
    gap: 8px !important;
    width: 100% !important;
    margin-top: 10px !important;
    margin-bottom: 12px !important;
    background: none !important;
  }
  /* Make all gameover buttons autosize, small padding */
  .gameover-top-actions button,
  #gameover .restart-btn,
  #gameover .leaderboard-link {
    min-width: 0 !important;
    width: auto !important;
    padding: 6px 12px !important;
    font-size: 1em !important;
    border-radius: 12px !important;
    font-weight: 700 !important;
    margin: 0 !important;
    box-shadow: 0 2px 8px #29416711 !important;
    white-space: nowrap !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 38px !important;
    line-height: 1 !important;
  }
  /* Make Restart more prominent */
  #gameover .restart-btn {
    background: #2266e3 !important;
    color: #fff !important;
    font-size: 1.07em !important;
    font-weight: 800 !important;
    border: none !important;
  }
  /* Reduce Share/Leaderboard prominence */
  #gameover .leaderboard-link {
    background: #202e4a !important;
    color: #fff !important;
    font-size: 0.97em !important;
    font-weight: 700 !important;
    border: none !important;
    padding: 6px 10px !important;
  }
  /* Shrink the scorecard */
  #scoreCard, .scorecard-inner {
    width: 70vw !important;
    max-width: 210px !important;
    min-width: 90px !important;
    padding: 6px 0 !important;
    margin: 8px auto 0 auto !important;
    border-radius: 13px !important;
    font-size: 0.92em !important;
  }
  .playerinfo {
    max-width: 99vw !important;
  }
  /* Tweak scorecard content for compactness */
  .scorecard-title, .scorecard-subtitle, .scorecard-playername,
  .scorecard-footer, .score-row, .score-box, .label {
    font-size: 0.97em !important;
    padding: 2px 0 !important;
  }
}

@media (max-width: 950px) {
  .intro-btn-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    width: 100% !important;
    margin-top: 10px !important;
    margin-bottom: 10px !important;
  }
  .intro-btn-row button {
    min-width: 0 !important;
    width: auto !important;
    padding: 7px 16px !important;
    font-size: 1.08em !important;
    font-weight: 800 !important;
    border-radius: 13px !important;
    margin: 0 !important;
    box-shadow: 0 2px 8px #29416711 !important;
    white-space: nowrap !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 40px !important;
    line-height: 1 !important;
  }
}
@media (max-width: 950px) {
  .gameover-top-actions {
    gap: 4vw;             /* Slightly wider gap for touch */

  }
  #restartBtn, .leaderboard-link.small {
    height: 41px;
    min-width: 82px;
    font-size: 1em;
    padding: 6px 7px;
    border-radius: 11px;
  }
}


@media (max-width: 950px) {
  #leaderboardIntroBtn {
    font-size: 1rem;
    padding: 8px 12px;
    border-radius: 11px;
  }
  #startBtn {
    font-size: 1.12rem;
    padding: 10px 19px;
    border-radius: 12px;
  }
}

@media (max-width: 950px) {
  #restartBtn {
    max-width: 120px !important;
    min-width: 80px !important;
    width: auto !important;
    padding: 5px 12px !important;
    font-size: 1.05em !important;
    border-radius: 12px !important;
    margin: 0 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    font-weight: 700 !important;
  }
}

@media (max-width: 950px) {
  #leaderboardIntroBtn {
    width: auto !important;
    max-width: 190px !important;
    min-width: 90px !important;
    padding: 8px 18px !important;
    font-size: 1.08em !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    margin: 0 auto !important;
    border-radius: 12px !important;
  }
}

@media (max-width: 950px) {
  .leaderboard-link {
    width: auto !important;
    max-width: 190px !important;
    min-width: 90px !important;
    padding: 8px 18px !important;
    font-size: 1.08em !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    margin: 0 auto !important;
    border-radius: 12px !important;
  }
}
@media (max-width: 950px) {
  .intro-btn-row {
    flex-direction: column !important;
    align-items: center !important;
    gap: 12px !important;
        margin-bottom: 4px;
    margin-top: 10px;
  }
}

.gameover-top-actions {
  margin-top: 8px !important;
}


@media (max-width: 950px) {
  #streakBox {
    background: none !important;
    box-shadow: none !important; /* Optional: remove subtle shadow too */
  }
}




@media (max-width: 950px) {
  #gameover, #intro {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    min-width: 100vw !important;
    min-height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #fff !important;
    border-radius: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
    z-index: 1200 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
  }
}

@media (max-width: 950px) {
  #intro {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    min-width: 100vw !important;
    min-height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    background: #fff !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important; /* <-- usually want logo/form higher */
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    border-radius: 0 !important;
  }
}



@media (max-width: 950px) {
 #intro, #gameover {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    min-height: 100vh !important;
    max-height: none !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    background: #fff !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important; /* start from top, scroll if needed */
  }

  /* Remove overflow: hidden from html/body when overlay is open */
  html, body {
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }
}


@media (max-width: 950px) {
  html, body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    min-height: 100vh !important;
    background: #000 !important;
    overflow: hidden !important;
    /* Critical for iPhone X+ notch */
    padding-bottom: env(safe-area-inset-bottom, 0);
    padding-top: env(safe-area-inset-top, 0);
  }

  #container {
    margin: 0 !important;
    padding: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    min-height: 100vh !important;
    background: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    overflow: hidden !important;
    position: relative !important;
  }

  canvas#game {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    position: absolute !important;
    top: 0; left: 0;
    width: 100% !important;
    height: 100% !important;
    z-index: 2 !important;
  }




#rotateDeviceOverlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(120deg, #f7e8ff 0%, #fef6e8 55%, #ffe180 100%);
  z-index: 2000;
  margin: 0;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}
.rotate-msg-box-modern {
  background: linear-gradient(132deg, #fffbe7 55%, #ffe180 100%);
  border-radius: 32px;
  box-shadow: 0 8px 32px #b9b9b9a1, 0 2px 8px #fff1;
  padding: 44px 28px 32px 28px;
  text-align: center;
  max-width: 92vw;
  min-width: 320px;
  font-family: 'Montserrat', Arial, sans-serif;
  color: #243059;
  animation: popUpFadeIn 0.7s cubic-bezier(.18,.68,.48,1.29);
}

@keyframes popUpFadeIn {
  from { transform: scale(0.95) translateY(40px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.rotate-msg-box-modern .emoji {
  font-size: 9vw;
  margin-bottom: 1.2em;
  display: block;
  filter: drop-shadow(0 2px 6px #ffc10744);
  animation: spinRotate 1.2s infinite linear alternate;
}

@keyframes spinRotate {
  0%   { transform: rotate(-8deg); }
  100% { transform: rotate(14deg); }
}

.rotate-msg-box-modern .headline {
  font-size: 2.5em;
  font-weight: 800;
  margin-bottom: 0.3em;
  letter-spacing: 0.02em;
  color: #1d2e56;
  text-shadow: 0 1px 8px #ffc10725;
}

.rotate-msg-box-modern .desc {
  font-size: 1.22em;
  color: #49516b;
  margin-bottom: 1em;
  font-weight: 500;
}

.rotate-msg-box-modern .desktop-msg {
  font-size: 1.12em;
  color: #c2881f;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin-top: 1em;
}

}


@media (max-width: 950px) {
  .country-flag-name {
    font-size: 0.92em !important;         /* Make it smaller on mobile */
    vertical-align: middle !important;    /* Align flag/text baseline */
    line-height: 1.2 !important;          /* Tweak for better centering */
    margin-left: 4px !important;          /* Keep a bit of space after flag */
    margin-right: 0 !important;
    display: inline-block !important;
    height: 1.25em !important;            /* Forces image (flag emoji or svg) to not be taller than text */
    position: relative !important;
    top: -1px !important;                  /* Adjust up/down if needed (try 0, 1, -1) */
  }
  /* If using emoji flags, add this tweak: */
  .country-flag-name::before, 
  .country-flag-name img {
    font-size: 1em !important;
    vertical-align: middle !important;
    height: 1em !important;
    width: auto !important;
    margin-right: 2px !important;
    display: inline-block !important;
    position: relative !important;
    top: -1px !important;
  }
}

