/* --- GLOBAL STYLES & ACCESSIBILITY --- */
body {
  background: linear-gradient(135deg, #1b0a00 0%, #3d120a 50%, #5a1d05 100%);
  color: #f5f5f5;
  font-family: "Poppins", sans-serif;
  margin: 0;
  display: flex;
  flex-direction: column; 
  min-height: 100vh;      
  min-height: 100dvh; /* Progressive enhancement for mobile viewports */
}

/* Bulletproof skip-link (No horizontal scroll leak) */
.skip-link {
  clip: rect(0 0 0 0); clip-path: inset(50%); width: 1px; height: 1px; 
  overflow: hidden; position: absolute; white-space: nowrap;
}
.skip-link:focus {
  position: fixed; top: 10px; left: 10px; width: auto; height: auto;
  background: #ffb400; color: #000; padding: 10px; z-index: 9999; 
  border-radius: 5px; clip: auto; clip-path: none; font-weight: 700; text-decoration: none;
}

/* --- HEADER --- */
.site-header {
  position: -webkit-sticky; /* iOS fallback */
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  padding: 12px 40px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  box-sizing: border-box;
  z-index: 10;
  background: rgba(27, 10, 0, 0.9);
  -webkit-backdrop-filter: blur(5px); /* iOS fallback */
  backdrop-filter: blur(5px);
  min-height: 70px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap; 
}

.back-btn {
  color: #fff;
  font-size: 1.2rem;
  text-decoration: none;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  border-radius: 4px;
  background: none;
  border: none;
  cursor: pointer;
}

.back-btn:hover { color: #ffb400; }
.back-btn:focus-visible { outline: 2px solid #ffb400; outline-offset: 2px; }

.brand-logo {
  height: 40px;
  width: auto;
  object-fit: contain;
  transition: transform 0.2s ease;
}

.game-beta-badge {
  background: #ffb400;
  color: #000;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
}

#headerActions { margin-left: auto; }

/* Proper Auth Skeleton class used globally */
.auth-skeleton {
  width: 90px;
  height: 35px;
  background: #333;
  border-radius: 50px;
  animation: pulseBg 1.5s infinite;
}
@keyframes pulseBg { 0% { opacity: 0.5; } 50% { opacity: 1; } 100% { opacity: 0.5; } }

/* --- MAIN CONTAINER --- */
.container {
  flex: 1; 
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 2rem 7.5%; /* More predictable scaling than width: 85% */
  max-width: 1400px;
  margin: 0 auto; 
  gap: 60px;
  box-sizing: border-box;
}

.text-section { flex: 1; max-width: 50%; }

h1 {
  font-size: 2.8rem;
  color: #ffb400; /* Fallback for browsers that fail gradients */
  background: linear-gradient(90deg, #ffb400, #ff5722);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
}

/* Accessibility: Forced Colors / Windows High Contrast Mode */
@media (forced-colors: active) {
  h1 { -webkit-text-fill-color: initial; color: CanvasText; }
}

.text-section p { font-size: 1rem; color: #ccc; margin-bottom: 1rem; line-height: 1.6; }

.game-metadata {
  font-size: 0.85rem;
  color: #ffb400;
  margin-top: 0.5rem;
  margin-bottom: 2rem;
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  row-gap: 8px; /* Proper vertical wrap spacing */
}

.buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 380px; /* Constrains cleanly */
}

.btn {
  padding: 14px 22px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(90deg, #ff7b00, #ff3300);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  font-size: 1rem;
  font-family: inherit;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn:focus-visible { outline: 3px solid #ffb400; outline-offset: 3px; }

/* Adjusted for darker contrast on the deep background */
.btn-secondary { background: #1c1c1c; border: 1px solid #555; }
.btn-secondary:hover { background: #2a2a2a; border-color: #777; }

.rules-btn { background: transparent; color: #ffb400; border: 2px solid #ffb400; }
.rules-btn:hover { background: rgba(255, 180, 0, 0.1); border-color: #ff9900; color: #ff9900; }

.lock-icon { opacity: 0.5; font-size: 0.8rem; flex-shrink: 0; }

.image-section { flex: 1; display: flex; justify-content: center; align-items: center; }

.image-section img {
  width: 60%;
  max-width: 500px;
  border-radius: 20px;
  box-shadow: 0 0 20px rgba(255, 102, 0, 0.3);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* --- HOVER & ACTIVE STATES --- */
/* Fix: Prevents hover effects from getting "stuck" on touch devices */
@media (hover: hover) and (pointer: fine) {
  .brand-logo:hover { transform: scale(1.05); }
  .image-section img:hover { transform: scale(1.02); box-shadow: 0 0 30px rgba(255, 102, 0, 0.5); }
  .btn:hover { transform: translateY(-2px); box-shadow: 0 6px 15px rgba(255, 78, 0, 0.4); }
}

/* Tactile feedback for touch and click */
.btn:active { transform: scale(0.97); filter: brightness(0.95); }


/* --- MODALS --- */
.rules-modal-overlay {
  display: none; 
  position: fixed;
  z-index: 999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  align-items: center;
  justify-content: center;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.rules-modal-box {
  background: #1c1c1c;
  padding: 2rem;
  border-radius: 15px;
  width: 90%;
  max-width: 500px;
  max-height: 85vh; /* Prevents overflow if rules text grows */
  overflow-y: auto;
  color: #fff;
  position: relative;
  text-align: left;
  box-sizing: border-box;
}

.rules-modal-box.center-text { text-align: center; }
.rules-modal-box h2 { color: #ffb400; margin-bottom: 1rem; margin-top: 0; }
.rules-modal-box p { margin-bottom: 0.8rem; line-height: 1.5; }
.modal-subtitle { color: #ccc; font-size: 0.9rem; margin-bottom: 20px; }

.rules-close-btn {
  position: absolute;
  top: 10px;
  right: 15px;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #aaa;
  transition: color 0.2s;
  padding: 5px;
}
.rules-close-btn:hover { color: #ff7b00; }
.rules-close-btn:focus-visible { outline: 2px solid #ffb400; outline-offset: 2px; border-radius: 3px; }

.join-input {
  width: 100%;
  padding: 15px;
  border-radius: 10px;
  border: 2px solid #444;
  background: #111;
  color: #fff;
  font-size: 1.2rem;
  text-align: center;
  text-transform: uppercase;
  margin-bottom: 20px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.join-input:focus { border-color: #ffb400; }

/* --- TOAST NOTIFICATION --- */
.toast {
  position: fixed;
  bottom: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: #28a745;
  color: white;
  padding: 12px 28px;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  transition: bottom 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.show { bottom: 40px; }

/* --- PREFERS REDUCED MOTION --- */
@media (prefers-reduced-motion: reduce) {
  .brand-logo:hover, .image-section img:hover, .btn:hover { transform: none; }
  .auth-skeleton { animation: none; }
}

/* --- RESPONSIVE DESIGN --- */
@media (max-width: 1024px) {
  .container { gap: 30px; } /* Intermediate gap for iPads */
}

@media (max-width: 768px) {
  .container { flex-direction: column; text-align: center; gap: 2rem; }
  .text-section { max-width: 100%; }
  .game-metadata { justify-content: center; }
  .buttons { width: 100%; align-items: center; }
  .image-section img { width: 80%; max-width: 300px; margin-top: 10px; }
}

@media (max-width: 480px) {
  .rules-modal-box { padding: 1.5rem; }
}

/* Hide the tilt hint explicitly on desktop devices */
@media (pointer: fine) {
  .mobile-tilt-hint { display: none !important; }
}