/**
 * Brave Dash — Public CSS (cleaned & organized)
 * - Preserves your original design and values
 * - Removes exact duplicate rules and consolidates media queries
 * - Fixes header overlap on mobile by making header layout flow
 */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* ------------------------------------------------------------
   Variables / Base
   ------------------------------------------------------------ */
:root{
  --brand-purple: #66338f;
  --brand-dark: #3c2654;
  --accent-yellow: #f2d43d;
  --bg-mobile: url("../assets/images/background-mobile.svg");
  --bg-desktop: url("../assets/images/background.svg");
  --font-game: 'Press Start 2P', cursive;
}

/* Reset-ish for elements used by plugin */
#brave-dash-game-container, #gameCanvas, .overlay-screen, .auth-modal-content {
  box-sizing: border-box;
}

/* ------------------------------------------------------------
   Mobile Header (top area shown only on mobile)
   ------------------------------------------------------------ */
#mobile-header {
  display: none; /* shown via media query on mobile */
  position: relative;
  width: 100%;
  background: #a1adff;
  padding: 10px;
  box-sizing: border-box;
  z-index: 1000;
}

/* Logo within mobile header */
#mobile-header .logo {
  text-align: center;
  margin: 8px 0;
}
#mobile-header .logo img {
  max-width: 120px;
  height: auto;
}

/* Score container inside mobile header */
#mobile-header .score-container {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 6px;
}
#mobile-header #high-score,
#mobile-header #current-score {
  background: rgba(102,51,143,0.9);
  padding: 5px 10px;
  border-radius: 5px;
  border: 1px solid var(--brand-dark);
  font-size: 0.9rem;
  color: white;
  text-align: center;
  font-family: var(--font-game);
}
#mobile-header #high-score .value,
#mobile-header #current-score .value {
  color: var(--accent-yellow);
  margin-left: 5px;
}

/* ------------------------------------------------------------
   Auth Buttons (desktop header area)
   Note: your HTML uses #auth-buttons-container (present twice).
         We keep that id selector for compatibility, but make it
         robust via flex layout so duplicate placement won't break.
   ------------------------------------------------------------ */
#auth-buttons-container {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  gap: 10px;
  align-items: center;
  box-sizing: border-box;
}

/* Generic button color rule applied across many elements */
#auth-buttons-container .auth-button,
.start-button,
#coupon-area button,
#restart-button,
.auth-modal-content form button,
.auth-tab-link {
  background: var(--brand-purple) !important;
  color: #ffffff !important;
  border-color: var(--brand-dark) !important;
}

/* Individual auth button (desktop) */
#auth-buttons-container .auth-button {
  font-size: 1rem;
  background: var(--brand-purple);
  color: #fff;
  border: 3px solid var(--brand-dark);
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-game);
  transition: all 0.12s;
}
#auth-buttons-container .auth-button:hover {
  background: #7e4fb0;
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--brand-dark);
}

/* Logout button: same visual treatment as .auth-button */
#auth-buttons-container .auth-button-logout {
  font-size: 0.8rem;
  background: var(--brand-purple);
  color: #fff;
  border: 3px solid var(--brand-dark);
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-game);
  transition: all 0.12s;
}
#auth-buttons-container .auth-button-logout:hover {
  background: #7e4fb0;
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--brand-dark);
}

/* Welcome user badge — make it inline-flex so it flows, doesn't overlap */
.welcome-user {
  font-family: var(--font-game);
  color: white;
  font-size: 1rem;
  text-shadow: 2px 2px 4px #000;
  background: rgba(108, 70, 146, 0.85);
  padding: 8px 12px;
  border-radius: 8px;
  border: 2px solid var(--brand-dark);
  display: inline-flex !important;
  align-items: center;
}

/* ------------------------------------------------------------
   Game container and canvas
   ------------------------------------------------------------ */
#brave-dash-game-container {
  position: relative;
  width: 90vw;
  max-width: 1100px;
  margin: 20px auto;
  border: 3px solid #333;
  border-radius: 10px;
  overflow: hidden;
  font-family: 'Arial', sans-serif;
  box-shadow: 0 10px 20px rgba(0,0,0,0.2);
  -webkit-tap-highlight-color: transparent;
  background: transparent;
}

/* Canvas base — keeps your original background choices */
#gameCanvas {
  display: block;
  width: 100%;
  height: 100vh; /* original: you set this; retained */
  background-image: var(--bg-desktop);
  background-size: 100% 100%; /* preserve original behavior */
  background-repeat: no-repeat;
  background-position: center bottom;
}

/* ------------------------------------------------------------
   Overlays (start / gameover / misc)
   ------------------------------------------------------------ */
.overlay-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: white;
  text-align: center;
  padding: 0 20px;
  box-sizing: border-box;
}
#start-screen { background: transparent; }
#game-over-screen { background-color: rgba(0,0,0,0.5); }

/* Start button */
.start-button {
  background-color: var(--brand-purple);
  padding: 2vw 4vw;
  border-radius: 15px;
  border: 3px solid var(--brand-dark);
  box-shadow: 0 8px 0 var(--brand-dark);
  font-family: var(--font-game);
  cursor: pointer;
  transition: all 0.12s ease-in-out;
  width: 80%;
  max-width: 700px;
  color: #fff;
  text-decoration: none;
  display: inline-block;
}
.start-button:hover {
  transform: translateY(2px);
  box-shadow: 0 6px 0 var(--brand-dark);
  background: #7e4fb0;
}
.start-button h1 {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  color: var(--accent-yellow);
  text-shadow: 3px 3px 0px var(--brand-dark);
  margin: 0;
}
.start-button p {
  font-size: clamp(0.8rem, 2vw, 1rem);
  margin: 20px 0 0 0;
  color: #ffffff;
  text-shadow: 2px 2px 0px var(--brand-dark);
}

/* Game over text */
#game-over-screen h2 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin: 0;
  text-shadow: 2px 2px 4px #000;
}
#game-over-screen p {
  font-size: clamp(1rem, 3vw, 1.5rem);
  text-shadow: 2px 2px 4px #000;
}

/* Coupon area text & buttons */
#coupon-area p {
  font-size: 1rem;
  margin-top: 15px;
  padding: 10px;
  border-radius: 5px;
  font-family: Arial, sans-serif;
  text-shadow: none;
}
.success-message { color: #155724; background-color: #d4edda; border: 1px solid #c3e6cb; padding: 8px; border-radius: 4px; }
.error-message { color: #721c24; background-color: #f8d7da; border: 1px solid #f5c6cb; padding: 8px; border-radius: 4px; }

/* Coupon / restart buttons */
#coupon-area button, #restart-button {
  padding: 12px 25px;
  font-size: 1.1rem;
  color: white;
  background: var(--brand-purple);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 20px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.2);
  transition: all 0.16s ease-in-out;
  text-decoration: none;
  display: inline-block;
}
#coupon-area button:hover, #restart-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 8px rgba(0,0,0,0.3);
  background: #7e4fb0;
}

/* Loading spinner */
#coupon-area .loading-spinner {
  display: inline-block;
  width: 25px;
  height: 25px;
  border: 4px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 1s ease-in-out infinite;
  margin: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------
   Modals
   ------------------------------------------------------------ */
#coupon-modal, #custom-auth-modal {
  display: none;
  position: fixed;
  z-index: 99999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.6);
}

.modal-content, .auth-modal-content {
  background-color: #fefefe;
  margin: 10% auto;
  padding: 20px;
  border: 1px solid #888;
  width: 90%;
  max-width: 400px;
  text-align: center;
  border-radius: 10px;
  position: relative;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  box-sizing: border-box;
}
.close-button {
  color: #aaa;
  position: absolute;
  top: 10px;
  right: 20px;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
}

/* Modal coupon visuals */
#modal-qr-code { max-width: 200px; margin: 15px auto; display: block; border: 1px solid #ddd; border-radius: 5px; padding: 5px; background: white; }
#modal-coupon-code { font-size: 1.5rem; font-weight: bold; background-color: var(--accent-yellow); color: var(--brand-dark); padding: 10px; border-radius: 5px; letter-spacing: 2px; word-break: break-all; margin: 15px 0; }

/* Auth modal styles */
.auth-modal-content { background-color: #ffffff; border: 3px solid var(--brand-dark); }
.auth-logo { margin-bottom: 20px; text-align: center; }
.auth-logo img { max-width: 150px; height: auto; }
.auth-tabs { display: flex; margin-bottom: 20px; gap: 6px; }
.auth-tab-link {
  flex: 1;
  padding: 10px;
  background: var(--brand-purple);
  color: white;
  border: none;
  cursor: pointer;
  font-family: var(--font-game);
  font-size: 1rem;
  opacity: 0.9;
  border-radius: 6px;
}
.auth-tab-link.active { background: var(--brand-dark); opacity: 1; }
.auth-tab-content { display: none; }
.auth-tab-content.active { display: block; }

/* Auth modal form controls */
.auth-modal-content form input {
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  border: 2px solid var(--brand-dark);
  border-radius: 5px;
  box-sizing: border-box;
  font-family: Arial, sans-serif;
  font-size: 16px; /* Prevents zoom on iOS */
}
.auth-modal-content form button {
  width: 100%;
  padding: 12px;
  background: var(--brand-purple);
  color: white;
  border: none;
  border-radius: 5px;
  font-family: var(--font-game);
  cursor: pointer;
  font-size: 1rem;
}
.auth-modal-content .forgot-password {
  display: block;
  margin-bottom: 10px;
  font-size: 0.8rem;
  color: var(--brand-dark);
  text-decoration: none;
}

/* Auth message styles */
.auth-message { font-size: 0.9rem; padding: 10px; margin-bottom: 10px; border-radius: 5px; display: none; }
.auth-message.success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.auth-message.error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* Modal text appearance */
.modal-content h3 { color: var(--brand-dark); margin-bottom: 15px; font-size: 1.5rem; }
.modal-content p { color: #333; margin-bottom: 15px; font-size: 1rem; }

/* ------------------------------------------------------------
   Utility / Accessibility
   ------------------------------------------------------------ */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* Prevent scrolling when game active */
body.game-active { overflow: hidden; position: fixed; width: 100%; height: 100%; }

/* Focus states */
#auth-buttons-container .auth-button:focus,
.start-button:focus,
#coupon-area button:focus,
.auth-modal-content form button:focus,
.auth-tab-link:focus {
  outline: 3px solid rgba(102,51,143,0.25);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(102,51,143,0.12);
}

/* ------------------------------------------------------------
   Responsive: desktop / tablet / mobile
   ------------------------------------------------------------ */

/* Desktop large screens */
@media screen and (min-width: 1200px) {
  #brave-dash-game-container { max-width: 1100px; }
  #gameCanvas {
    height: 600px;
    background-size: cover;
    background-position: center bottom;
  }
}

/* Tablet */
@media screen and (min-width: 769px) and (max-width: 1199px) {
  #brave-dash-game-container { width: 95vw; max-width: 900px; height: auto; }
  #gameCanvas { height: 50vh; background-size: cover; background-position: center bottom; }
  .start-button h1 { font-size: 2rem; }
  .start-button p { font-size: 1.1rem; }
}

/* Mobile: show mobile header and adapt layout */
@media screen and (max-width: 768px) {
  /* Show mobile header */
  #mobile-header { display: block; }

  /* Hide desktop auth buttons (they are absolute positioned in container) */
  #auth-buttons-container { display: none; }

  /* Mobile header auth area: make a dedicated flex container to avoid overlap */
  #mobile-header #auth-buttons-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 6px 0 8px 0;
    align-items: center;
    box-sizing: border-box;
	  position:static;
  }

  /* Make welcome-user flow within header (no absolute positioning) */
  #mobile-header .welcome-user {
    font-size: 0.7rem;
    padding: 8px 10px;
    position: static;
    margin: 0;
	  max-width:70%;
  }

  /* Container fixed size on mobile (keeps your prior layout behavior) */
  #brave-dash-game-container {
    width: 100vw;
    height: 500px;
    max-width: 100%;
    margin: 0 auto;
    border: none;
    border-radius: 0;
    position: relative;
    overflow: hidden;
  }

  /* mobile canvas overrides and mobile background usage */
  #gameCanvas {
    height: 500px !important;
    width: 100% !important;
    object-fit: cover;
    background-size: auto 100% !important;
    background-position: 0 0 !important;
    background-repeat: repeat-x !important;
    background-image: var(--bg-mobile);
  }

  .overlay-screen { padding: 10px; }

  .start-button { padding: 12px 16px; width: 90%; max-width: none; }
  .start-button h1 { font-size: 1.2rem; }
  .start-button p { font-size: 0.9rem; }

  #game-over-screen h2 { font-size: 1.5rem; }
  #game-over-screen p { font-size: 1rem; }

  #coupon-area button, #restart-button { padding: 10px 16px; font-size: 1rem; }

  .modal-content, .auth-modal-content { width: 95%; margin: 8% auto; padding: 15px; }
  .auth-tab-link { font-size: 0.8rem; padding: 8px; }
  #modal-coupon-code { font-size: 1.2rem; padding: 8px; }

  /* Ensure form inputs remain readable on iOS (prevents zoom) */
  .auth-modal-content form input { font-size: 16px; }
}

/* Extra small devices */
@media screen and (max-width: 420px) {
  #mobile-header .logo img { max-width: 200px; }
  #mobile-header #auth-buttons-container .auth-button { padding: 6px 10px; font-size: 0.7rem; }
  #mobile-header #high-score, #mobile-header #current-score { font-size: 0.8rem; padding: 4px 8px; }
  .start-button { width: 95%; }
  .start-button h1 { font-size: 1rem; }
}
