*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    overflow-x: hidden;
    height: 100%;
    -webkit-text-size-adjust: 100%; /* Prevents Chrome from auto-scaling text on rotation */
}

body {
    background-color: #121213 !important;
    color: #ffffff !important;
    width: 100vw;
    max-width: 100%;
    min-height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
}

:root {
  color-scheme: dark;
  --default: #121213;
  --empty: #3a3a3c;
  --wrong: #b59f3b;
  --correct: #538d4e;
}

/* --- Authentication Pages (Login/Register) --- */
.auth-container {
    width: calc(100% - 2.5rem); 
    max-width: 380px; 
    margin: 3rem auto; 
    padding: 1.5rem; 
    background: #1a1a1b;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    text-align: center;
    display: block;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden; 
}

.auth-container h2 {
  color: white;
  font-size: 2rem;
  margin-bottom: 1.5rem;
}

.auth-container p {
  color: #d7dadc;
  font-size: 0.95rem;
  margin-top: 1.5rem;
}

.auth-container a {
  color: #6aaa64; /* Using Wordle Green for links */
  text-decoration: none;
  font-weight: 600;
}

.auth-container a:hover {
  text-decoration: underline;
}

/* Form Layout */
.auth-container form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    margin: 0;
    padding: 0;
}

/* Input Styling */
.auth-container input {
    width: 100%;
    max-width: 100%;
    padding: 14px;
    background: #121213;
    border: 2px solid var(--empty);
    border-radius: 8px;
    color: white;
    font-size: 16px;
    transition: border-color 0.2s ease;
}

.auth-container input:focus {
  outline: none;
  border-color: var(--correct);
}

/* Force Auth buttons to span full width */
.auth-container .action-btn {
  width: 100%;
  height: 56px;
  font-size: 1.2rem;
  margin-top: 1rem;
  border-radius: 12px;
  cursor: pointer;
  border: none;
}

/* Error Message styling */
.error {
  background: rgba(211, 47, 47, 0.2);
  color: #ff5252;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #d32f2f;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

/* --- Game Pages / Functionality --- */

#game {
  display: grid;
  justify-content: center;
  align-items: start;
  margin-top: 1rem;
  width: 100%;
}

.grid {
  display: grid;
  grid-template-rows: repeat(6, auto);
  grid-template-columns: repeat(5, auto);
}

.box {
  width: 12vw; 
  height: 12vw;
  max-width: 60px; /* Caps size for desktop */
  max-height: 60px;
  border: 2px solid var(--empty);
  margin: 3px;
  color: white;
  text-transform: uppercase;
  display: grid;
  place-items: center;
  font-family: 'Clear Sans', 'Helvetica Neue', Arial, sans-serif;
  font-size: 2rem;
  font-weight: bold;
}

.box.empty {
  background: var(--empty);
}

.box.wrong {
  background: var(--wrong);
}

.box.correct {
  background: var(--correct);
}

.animated {
  animation: flip 0.5s ease;
}

@keyframes flip {
  0% {
    transform: scaleY(1);
  }
  50% {
    transform: scaleY(0);
  }
  100% {
    transform: scaleY(1);
  }
}

/* adjust font size for mobile */
@media (max-width: 360px) {
    .key {
        font-size: 0.9rem;
    }
    .key.large {
        font-size: 0.65rem;
        min-width: 45px !important;
    }
    .keyboard-row {
        gap: 4px;
    }
}

.title {
  color: white;
  text-align: center;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 3rem;
  margin-bottom: 0;
  position: relative;
}

.title-word-clone {
  position: absolute;
  left: calc(50% + 75px);
  transform: rotate(25deg);
  color: yellow;
  font-size: 1.2rem;
}

hr {
  border-style: solid;
  border-color: var(--empty);
  border-width: 1px;
}

.footer {
  display: flex;
  justify-content: center;
  color: white;
  text-align: center;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.v-separator {
  margin-left: 1rem;
  margin-right: 1rem;
}

.social-media-link {
  display: flex;
  fill: white;
  width: 25px;
  height: 25px;
  margin-right: 0.75rem;
}

/* When share mode is enabled, hide letters but keep colored boxes */
.share-mode .box {
  color: transparent;      /* hides text */
  text-shadow: none;
}

/* Optional: prevents selecting “invisible” letters */
.share-mode .box::selection {
  background: transparent;
}

#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding: 10px;
  box-sizing: border-box;
}

#shareToggleBtn {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 0.75rem 1.5rem;
  margin-top: 1.25rem;

  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.03em;

  cursor: pointer;
  background: linear-gradient(135deg, #4caf50, #2e7d32); /* green gradient */
  color: #ffffff;

  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);

  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

/* Hover state */
#shareToggleBtn:hover {
  background: linear-gradient(135deg, #66bb6a, #388e3c);
  box-shadow:
    0 6px 14px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

/* Active (pressed) state */
#shareToggleBtn:active {
  transform: translateY(0);
  box-shadow:
    0 3px 8px rgba(0, 0, 0, 0.3),
    inset 0 2px 4px rgba(0, 0, 0, 0.25);
}

/* Optional: focus accessibility */
#shareToggleBtn:focus-visible {
  outline: 3px solid rgba(76, 175, 80, 0.5);
  outline-offset: 3px;
}

#leaderboardBtn {
    background: linear-gradient(135deg, #c9b458, #9f8f3a);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

#helpBtn {
    background: linear-gradient(180deg, #4aa3ff, #1877d3);
    color: #ffffff;
    box-shadow: 0 8px 22px rgba(24, 119, 211, 0.22);
}

/* Overlay */
.game-message {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1000;
}

.game-message.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Popup box */
.game-message__content {
  background: #1a1a1b;
  color: #ffffff;
  padding: 1.5rem 2rem;
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  min-width: 260px;
  max-width: 360px;
  text-align: center;
}

/* Text */
#game-message-text {
  margin: 0 0 1rem 0;
  font-size: 1rem;
}

/* Close button – reuse style similar to your other buttons */
#game-message-close {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 0.5rem 1.25rem;

  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.03em;

  cursor: pointer;
  background: linear-gradient(135deg, #6aaa64, #4e8a52); /* green */
  color: #ffffff;

  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);

  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

#game-message-close:hover {
  background: linear-gradient(135deg, #7bbf74, #5f9d63);
  box-shadow:
    0 6px 14px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

#game-message-close:active {
  transform: translateY(0);
  box-shadow:
    0 3px 8px rgba(0, 0, 0, 0.35),
    inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

#game-message-close:focus-visible {
  outline: 3px solid rgba(106, 170, 100, 0.6);
  outline-offset: 3px;
}

#game-message-text strong {
  font-size: 1.25rem;
  color: #6aaa64; /* Wordle green */
  letter-spacing: 0.1em;
}

/* Top nav container */
.top-nav {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin-bottom: 1.25rem;
  width: 100%;
  max-width: 350px; /* Limits how wide the button row can get */
}

/* Shared action button appearance */
.action-btn {
    flex: 1;             /* Forces them to be equal width */
    height: 48px;        /* Fixed height for consistency */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none !important;
    border: none;
    box-sizing: border-box; /* Crucial for consistent sizing */
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
}

.action-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.action-btn,
.action-btn:hover,
.action-btn:focus,
.action-btn:active {
  text-decoration: none !important;  /* 🔑 */
}

/* Gold (leaderboard) — matches the leaderboard style you liked */
.action-btn.gold {
  background: linear-gradient(180deg,#ffd86b,#e6ac00);
  color: #111;
  box-shadow: 0 8px 22px rgba(230,172,0,0.22);
}

/* Blue (help) — nice complementary color */
.action-btn.blue {
  background: linear-gradient(180deg,#4aa3ff,#1877d3);
  color: #fff;
  box-shadow: 0 8px 22px rgba(24,119,211,0.22);
}

.action-btn:hover {
  transform: translateY(-2px);
  opacity: 0.98;
}

.action-btn:focus-visible {
  outline: 3px solid rgba(255,255,255,0.4);
  outline-offset: 2px;
}

/* On-screen (non-clickable) keyboard */
.keyboard {
  margin-top: 25px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  user-select: none;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0 6px;
}
.keyboard-row {
  display: flex;
  gap: 5px;
  justify-content: center;
  width: 100%;
  touch-action: manipulation;
}
.key {
    font-family: 'Clear Sans', 'Helvetica Neue', Arial, sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    background: #121213;
    border: 1px solid #3a3a3c;
    color: #ffffff;
    
    flex: 1;
    width: 9vw;
    max-width: 44px;
    min-width: 24px; 
    
    height: 58px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    cursor: pointer;
    box-sizing: border-box;
    
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.1s ease;
}
/* Hide keyboard during share mode */
.keyboard.hidden {
  display: none !important;
}
@media (hover: hover) {
    .key:hover {
        background: #3a3a3c;
    }
    .key[data-key="ENTER"]:hover {
        background-color: #5ea358 !important;
    }
}
.key.large {
    flex: 1.8 !important;   
    width: auto !important; 
    min-width: 55px !important; 
    font-size: 0.75rem;
    background: #565758;
}
.key[data-key="ENTER"] {
    background-color: #538d4e !important;
    border-color: #538d4e;
}
/* Optional: Adjust backspace icon size */
.key[data-key="BACK"] {
    font-size: 1.2rem;
}

/* Match your tile colors */
.key.correct { background: #6aaa64; border-color: #6aaa64; color: #fff; }
.key.wrong   { background: #c9b458; border-color: #c9b458; color: #111; }
.key.empty   { background: #3a3a3c; border-color: #3a3a3c; color: #fff; }


/* --- Help Page Styling --- */
#help-page {
  padding: 2rem 1rem;
  color: #ffffff; 
  font-family: 'Clear Sans', 'Helvetica Neue', Arial, sans-serif;
  display: flex;
  justify-content: center;
}

.help-wrap {
  max-width: 500px;
  width: 100%;
  text-align: center;
}

.help-wrap h1 {
  margin-top: 0;
  font-size: 2.2rem;
  color: #ffffff;
}

.help-wrap .lead {
  font-size: 1.1rem;
  line-height: 1.5;

  color: #d7dadc; 
  margin-bottom: 2rem;
}

.help-wrap .lead strong {
  color: #ffffff;
}


.examples {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  margin: 2rem 0;
  flex-wrap: wrap;
}

.example {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  flex: 1;
  min-width: 100px;
}

.example .box {
  width: 70px;
  height: 70px;
  font-size: 2rem;
  border-radius: 8px;
  cursor: default;
  margin: 0;
}

.example .label {
  font-size: 0.95rem;
  line-height: 1.4;
  color: #ffffff;
}

.example .label strong {
  display: block;
  margin-bottom: 2px;
  color: #ffffff;
}

/* Rules Section */
.rules {
  text-align: left;
  margin: 2rem 0;

  background: #1a1a1b; 
  padding: 1.5rem;
  border-radius: 12px;
  font-size: 1rem;
  line-height: 1.6;
  border: 1px solid #3a3a3c;
  color: #ffffff;
}

.rules strong {
    color: var(--correct);
}

.rules ul {
  margin: 1rem 0 0 0;
  padding-left: 1.2rem;
  color: #ffffff;
}

.rules li {
  margin-bottom: 0.85rem;
  color: #d7dadc;
}

.back-row {
  margin-top: 2rem;
  padding-bottom: 3rem;
}

@media (max-width: 400px) {
    .examples { gap: 0.8rem; }
    .example .box { width: 64px; height: 64px; }
    .help-wrap h1 { font-size: 1.8rem; }
}

/* --- Leaderboard UI Refinements --- */
.leaderboard-container { 
    max-width: 800px; 
    margin: 0 auto; 
    padding: 20px; 
    color: #ffffff; /* Explicit base color */
    font-family: 'Clear Sans', 'Helvetica Neue', Arial, sans-serif;
}

/* Page Heading */
.leaderboard-container h1 {
    color: #ffffff;
    text-align: center;
    font-size: 2.2rem;
    margin-bottom: 2rem;
}

.leaderboard-container h2 {
    color: #ffffff;
    margin-top: 40px;
    border-left: 5px solid var(--correct);
    padding-left: 15px;
    font-size: 1.5rem;
}

/* Metrics Section */
.metrics { 
    display: flex; 
    gap: 12px; 
    margin-bottom: 30px; 
    flex-wrap: wrap; 
}

.metric { 
    flex: 1; 
    min-width: 140px; 
    background: #1a1a1b; 
    padding: 15px; 
    border-radius: 12px; 
    text-align: center; 
    border: 1px solid #3a3a3c; 
    box-sizing: border-box; 
}

/* High-Contrast Accents */
.metric:nth-child(1) { border-left: 5px solid var(--correct) !important; }
.metric:nth-child(2) { border-left: 5px solid var(--wrong) !important; }
.metric:nth-child(3) { border-left: 5px solid #4aa3ff !important; }

.metric__label { 
    font-size: 0.85rem; 
    color: #b0b0b1; /* Brighter gray for mobile visibility */
    text-transform: uppercase; 
    letter-spacing: 0.05em; 
    font-weight: 600;
}

.metric__value { 
    font-size: 1.8rem; 
    font-weight: 800; 
    margin-top: 5px; 
    color: #ffffff !important; /* Forces pure white */
}

/* Tables - Mobile Optimized */
.table-responsive {
    width: 100%;
    overflow-x: auto; /* Allows horizontal swipe on very narrow screens */
    border-radius: 12px;
    background: #1a1a1b;
}

table { 
    width: 100%; 
    border-collapse: separate; 
    border-spacing: 0; 
    background: #1a1a1b; 
    border: 1px solid #3a3a3c;
    color: #ffffff;
}

th { 
    background: #3a3a3c; 
    padding: 16px 12px; 
    text-align: left; 
    font-size: 0.95rem; 
    color: #ffffff; /* High contrast headers */
    font-weight: 700;
}

td { 
    padding: 14px 12px; 
    border-bottom: 1px solid #2a2a2b; 
    color: #ffffff !important; 
    font-size: 1rem;
}

/* Highlight "Me" Row */
tr.me { 
    background: rgba(83, 141, 78, 0.25) !important; 
}

tr.me td {
    color: #ffffff !important;
    font-weight: 600;
}

tr.me td:first-child {
    border-left: 5px solid var(--correct);
    padding-left: 7px; 
}

/* Mobile-Specific scaling */
@media (max-width: 480px) {
    .leaderboard-container { padding: 10px; }
    .metric__value { font-size: 1.5rem; }
    th, td { padding: 10px 8px; font-size: 0.9rem; }
    .rank { width: 45px; }
    .leaderboard-container h1 { font-size: 1.8rem; }
}

#shareButtonsContainer {
    display: flex;
    justify-content: center;
    width: 100%;
    margin: 1.5rem 0;
}

#copyResultsBtn {
    /* Ensuring a beefy, clickable size for mobile */
    height: 54px; 
    font-size: 1.1rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}