*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body{
    height:100%;
    font-family: var(--font_family-style);
    overflow-x: hidden;
    overflow-y: auto;
}

:root {
  --light_mode-background-color: #F8F8FF;
  --dark_mode-background-color: #222222;
  --header_light_mode-color: #222222;
  --header_dark_mode-color: rgb(120, 210, 249);
  --icon_stroke_lightmode-color: black;
  --icon_stroke_darkmode-color: #ccc;
  --icon_hover-color: rgb(120, 210, 249);
  --main_theme-color: rgb(249, 120, 205);
  --toggle_button_main_theme_shadow-color: rgba(230, 11, 168, 0.5);
  --regular_box-color: lightgrey;
  --correct_answer-color: lightgreen;
  --correct_answer_boxshadow-color: rgb(9, 255, 0);
  --variant_error-color: #DC143C;
  --variant_error_boxshadow-color: rgba(255, 0, 0, 0.5);
  --chosenLetter_error-color:rgb(236, 210, 61);
  --chosenLetter_error_boxshadow-color:rgb(236, 210, 61);
  --squaretable-color: lightgrey;
  --errorbox_message-color:black;
  --keyboard_rowbutton_lightmode-color: lightgrey;
  --keyboard_letters_lightmode-color: black;
  --statuspopup_box-color: rgba(0, 0, 0, 0.7);
  --statuspopup_message-color: white;
  --border_bottom-color: rgb(58, 58, 60);
  --font_family-style:Georgia, Times, serif;
  --win_modal-bg-lightmode: #F8F8FF;
  --share_score-border-color-lightmode: #ccc;
  --win_modal-bg-darkmode: #1c1c1c;
  --share_score-border-color-darkmode: #777;
  --close_button_share_score-color-lightmode:#555;
  --close_button_share_score-color-darkmode: #aaa;
  --side-width: 6.75rem;

  /* Main tile size (grid squares + error column row height) */
  --square-size: clamp(2rem, 10.5vw, 3.2rem);
  --square-font-size: clamp(1.1rem, 4vw, 1.8rem);

  /* Keyboard key sizes */
  --key-width: clamp(2.4rem, 7vw, 4rem);
  --key-height: clamp(2.4rem, 7vw, 3rem);
  --key-font-size: clamp(0.9rem, 2.7vw, 1rem);
}

@media (max-height: 650px) {
  :root {
    --square-size: clamp(1.6rem, 6vw, 2.4rem);
    --square-font-size: clamp(0.9rem, 2.4vw, 1.4rem);
    --key-height: clamp(2rem, 5vw, 2.4rem);
  }
}

#container {
    display: flex;
    background-color: var(--light_mode-background-color);
    height: 100vh;
    align-items: center;
    justify-content: space-between; /* maintains layout balance */
    flex-direction: column;
}


#game,
#rulesSection,
#settingsSection {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);  
  width: 100%;
  max-width: 30rem;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--light_mode-background-color);
  z-index: 1;
  
}

#game{
  overflow: hidden;
}

#rulesSection,
#settingsSection{
  overflow-y: auto;   /* allow vertical scroll */
  overflow-x: hidden; /* prevent horizontal scroll if desired */
}

/* Shared hidden layout-safe style */
.hide-section {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* Shared visible layout-safe style */
.show-section {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}


/* =============== Variants: Welcome + Ad Gate =============== */
/* Base panel layout to match #game/#rulesSection/#settingsSection */
/* Center the welcome screen content */
#welcomeSection {
  /* display: grid;
  place-items: center;
  padding: 1.5rem 1rem; */
  /* min-height: 100dvh;        
  margin: 0 auto;            
  width: 100%;
  justify-items: center; */
  position: absolute;
  padding: 5rem 1rem;
  top: 0;
  left: 50%;
  transform: translateX(-50%);   
  width: 100%;
  max-width: 30rem;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--light_mode-background-color);
  z-index: 1;
}

/* The vertical stack */
.welcome-hero {
  width: 100%;
  max-width: 28rem;
  text-align: center;
  display: grid;
  gap: 1rem;
}
.welcomeToIntroMsg{
  font-size: 1rem;
  line-height: 1.1;
  letter-spacing: 0.2px;
  font-weight: lighter;
  font-style: italic;
  text-transform: uppercase;
  color: var(--header_light_mode-color);
}

/* Title styled to match your header palette */
.brand-title {
  font-size: 2.5rem;
  line-height: 1.1;
  letter-spacing: 0.2px;
  font-family: var(--font_family-style);
  font-style: italic;
  font-weight: normal;
  text-transform: uppercase;
  color: var(--header_light_mode-color);
}

.aDailyWordGame{
  font-size: 0.8rem;
  line-height: 1.1;
  letter-spacing: 0.2px;
  font-weight: lighter;
  font-style: italic;
  color: var(--header_light_mode-color);
}

body.dark-mode .brand-title,
body.dark-mode .welcomeToIntroMsg,
body.dark-mode .aDailyWordGame,
body[data-theme="dark"] :is(.brand-title, .welcomeToIntroMsg, .aDailyWordGame) {
  color: var(--header_dark_mode-color);
}

/* Logo sizing */
.brand-logo {
  width: min(220px, 60vw);
  height: auto;
  margin: 0 auto 0.25rem;
  display: block;
}

/* Tighten layout on small devices */
@media (max-width: 380px) {
  .welcomeToIntroMsg{font-size: 0.5rem;}
  .brand-title { font-size: 2rem; }
  .aDailyWordGame{font-size: 0.3rem;}
  .brand-logo { width: min(180px, 65vw); }
}

/* One-line instructions */
.tagline {
  font-size: 1rem;
  color: #444;
}
body.dark-mode .tagline,
body[data-theme="dark"] .tagline {
  color: #b9b9b9;
}


/* Back button (ghost style)
#backToWelcomeFromAd {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: none;
  background: transparent;
  color: var(--icon_stroke_lightmode-color);
  font: inherit;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
}

#backToWelcomeFromAd .arrow-icon {
  stroke: currentColor;
}

#backToWelcomeFromAd:hover {
  color: var(--icon_hover-color);
}

body.dark-mode #backToWelcomeFromAd,
body[data-theme="dark"] #backToWelcomeFromAd {
  color: var(--icon_stroke_darkmode-color);
} */

/* Welcome body */
#welcomeSub {
  font-size: 0.95rem;
  color: #555;
  margin-left: auto;
  margin-right: 1rem;
}

body.dark-mode #welcomeSub,
body[data-theme="dark"] #welcomeSub {
  color: #aaa;
}

#welcomeCta {
  display: grid;
  place-items: center;
  padding: 2rem 1rem 1rem;
  gap: 1rem;
}

#welcomeMeta {
  margin-top: auto;
  padding: 0 1rem 1.25rem;
}



/* CTA button, matches theme */
#startOrResumeButton {
  appearance: none;
  border: none;
  border-radius: 0.75rem;
  padding: 0.9rem 1.25rem;
  background: var(--main_theme-color);
  color: #111;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  box-shadow: 0 6px 18px var(--toggle_button_main_theme_shadow-color);
  transition: transform 0.08s ease, filter 0.12s ease;
}




#adSection {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 30rem;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--light_mode-background-color);
  z-index: 2;
}



/* Dark mode surface */
body.dark-mode #welcomeSection,
body.dark-mode #adSection,
body[data-theme="dark"] #welcomeSection,
body[data-theme="dark"] #adSection {
  background-color: var(--dark_mode-background-color);
}

/* Headers aligned with your .header-container vibe */
#adHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border_bottom-color);
  padding: 0.5rem 1rem;
}


#adHeading {
  font-size: 1.25rem;
  line-height: 1.2;
  color: var(--header_light_mode-color);
}

body.dark-mode #welcomeHeading,
body.dark-mode #adHeading,
body[data-theme="dark"] #welcomeHeading,
body[data-theme="dark"] #adHeading {
  color: var(--header_dark_mode-color);
}

/* Ad body */
#adBody {
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  padding: 1rem;
}

#adSlot {
  width: 100%;
  min-height: 220px;
  max-height: 60dvh;
  border: 1px solid var(--share_score-border-color-lightmode);
  border-radius: 0.75rem;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(0,0,0,0.02);
}

body.dark-mode #adSlot,
body[data-theme="dark"] #adSlot {
  border-color: var(--share_score-border-color-darkmode);
  background: rgba(255,255,255,0.04);
}

/* Ad controls pinned to bottom */
#adControls {
  border-top: 1px solid var(--border_bottom-color);
  padding: 0.875rem 1rem 1.25rem;
  display: flex;
  justify-content: center;
}

#skipAdButton {
  appearance: none;
  border: 1px solid var(--share_score-border-color-lightmode);
  border-radius: 999px;
  padding: 0.6rem 1.1rem;
  background: transparent;
  color: #222;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.08s ease;
}

#skipAdButton:hover:not([disabled]) {
  background: rgba(0,0,0,0.05);
}

#skipAdButton:active:not([disabled]) {
  transform: translateY(1px);
}

#skipAdButton[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

body.dark-mode #skipAdButton,
body[data-theme="dark"] #skipAdButton {
  border-color: var(--share_score-border-color-darkmode);
  color: #ddd;
}

body.dark-mode #skipAdButton:hover:not([disabled]),
body[data-theme="dark"] #skipAdButton:hover:not([disabled]) {
  background: rgba(255,255,255,0.08);
}

/* Microcopy */
.smallprint {
  font-size: 0.8rem;
  color: #666;
}

body.dark-mode .smallprint,
body[data-theme="dark"] .smallprint {
  color: #9aa0a6;
}

/* Spacing tweaks on very small screens */
@media (max-width: 380px) {
  #welcomeHeader, #adHeader { padding: 0.5rem 0.75rem; }
  #welcomeCta { padding-top: 1.5rem; }
}

/* Respect your existing .hide-section/.show-section transitions */
#welcomeSection.hide-section,
#adSection.hide-section { transition: opacity 0.25s ease; }

#welcomeSection.show-section,
#adSection.show-section { transition: opacity 0.25s ease; }

/* Disable page scrolling whenever welcome OR ad gate is shown */
/* body:has(#welcomeSection.show-section),
body:has(#adSection.show-section) {
  overflow: hidden;
} */



.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border_bottom-color);
  padding: 0.05rem 1rem;
  width: 100%;
}

/* Let side containers size to contents; no arbitrary 4rem choke points */
.header-left,
.icon-container {
  display: flex;
  align-items: center;
  flex: 0 0 auto;          /* don't grow, don't shrink */
  /* remove width: 4rem; */
  /* remove weird 0.01rem margins */
}

.header-left-inner,
.icon-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;             /* spacing now handled here */
}

/* Normalize all header buttons/controls */
.stopwatchDisplay,
.lb-button,
.info-button,
.settings-button {
  background: transparent;
  color: var(--icon_stroke_lightmode-color);
  border: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0rem 0.4rem;               /* kill per-item margins that were blowing layout */
  cursor: pointer;
  color: inherit;
}


/* .stopwatchDisplay {
  width: 4rem; 
  text-align: left;
  font-size: 1rem;
  font-family: var(--font_family-style);
  margin-left: 0.01rem;  
} */


.stopwatchDisplay svg,
.lb-button svg,
.info-button svg,
.settings-button svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 1.8;
  transition: stroke 0.2s ease;
}

.info-button:hover svg,
.settings-button:hover svg,
.lb-button:hover svg {
  stroke: var(--icon_hover-color); /* your theme highlight */
}

.title-group {
  /* flex-grow: 1; */
  flex: 1 1 auto;          /* expand to fill between left/right clusters */
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0.3rem 0;
}

.title {
  flex-grow: 1;
  text-align: center;
  font-family: var(--font_family-style);
  font-style: italic;
  font-weight: normal;
  font-size: 1.40rem;
  margin: 0.4rem 0;
  text-transform: uppercase;
  color: var(--header_light_mode-color);
}

.subtitle {
  font-size: 0.65rem;
  font-family: var(--font_family-style);
  font-style: italic;
  font-weight: normal;
  margin-top: -0.1rem; /* slight nudge up if needed */
  color: grey;
}


.puzzle-caption {
  text-align: center;
  font-family: var(--font_family-style);
  font-style: italic;
  font-size: 0.9rem;
  color: grey;
  /* margin-top: 0.15rem; */
  margin-top: 0.3rem;
  margin-bottom: 0.5rem;
  /* margin-bottom: clamp(0.1rem, 0.6vh, 0.3rem); */
}

/* Whole playable area (original word + gametable + keyboard) */
/* #game-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 0 0 1.5rem;
  gap: clamp(0.4rem, 1.4vh, 0.75rem);  
  padding-top: clamp(0.25rem, 1vh, 0.5rem);
  padding-bottom: clamp(0.75rem, 2vh, 1.25rem);
} */

/* #game-Layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding-top: 0.25rem;
  padding-bottom: 0.75rem;
} */

#gameLayout {
  flex: 1;                             /* fills everything below header */
  display: flex;
  flex-direction: column;
  justify-content: space-between;       /* top-section at top, keyboard at bottom */
  min-height: 0;                        /* allows shrinking on small screens */
  box-sizing: border-box;
}


#originalWord{
    color: var(--main_theme-color);
    font-family: var(--font_family-style);
    font-style: bold;
    font-size: 2.75rem;
    margin-top: .25rem;
    /* margin-top: clamp(0.1rem, 0.8vh, 0.3rem); */
    margin-bottom: 0rem;
    text-align: center;
    text-transform: uppercase;
}

.greyed-out {
  color: grey;
  opacity: 0.5;
}


#play-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  transform-origin: top center; /* for the JS scaling */

 /* NEW: reserve space so content never sits under the fixed keyboard */
  padding-bottom: 9rem;
  box-sizing: border-box;

}




#table-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  box-sizing: border-box;
  padding-top: 0.05rem;
  overflow: visible;   /* let the page scroll, don't clip inside here */
  
  /* NEW: center this block between original word and bottom of play-area */
  margin-top: auto;
  margin-bottom: auto;

}

@media (max-width: 900px) {
  /* Let the layout size itself naturally; no hard vh height */
  #game-layout {
    height: auto;
    min-height: auto;
  }

  /* Slightly extra padding so play area always clears the keyboard */
  #play-area {
    padding-bottom: 9.5rem;  /* tiny extra safety margin for very small screens */
  }

  #table-wrapper {
    overflow-y: visible;  /* keep as you had, just explicit */
  }
}



/* Responsive table container */
#table-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  flex-grow: 1;
  padding: 1rem; /* reduced from 4rem */
  box-sizing: border-box;
  transform-origin: top center;
  transform: scale(1);

}

#originalWordColumn,
#gameTable {
  display: grid;
  gap: 0.5rem;
  padding: 0.5rem;
}

#originalWordColumn {
  grid-template-columns: repeat(1, 1fr);
}

/* #originalWordColumn {
  display: grid;
  grid-template-columns: max-content; 
  gap: 0.5rem;
  padding: 0.5rem;
} */



#gameTable {
  display: grid;
  /* grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(5, 3.2rem); */
  grid-template-columns: repeat(4, var(--square-size));
  grid-template-rows: repeat(5, var(--square-size));
  /* grid-template-rows: repeat(5, clamp(2.4rem, 7vw, 3.2rem)); clamp */
  gap: 0.5rem;
  padding: 0.5rem;
  max-width: 100vw;
  max-height: 80vh;
  box-sizing: border-box;
  transform-origin: top center;
}


.squareOW,
.squareTable {
  width: var(--square-size);
  height: var(--square-size);
  font-size: var(--square-font-size);
  /* min-width: 3.2rem;
  min-height: 3.2rem;
  font-size: 1.8rem; */
  font-weight: bold;
  text-transform: uppercase;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
}

.squareOW {
  border: 1px solid lightgrey;
  color: var(--main_theme-color);

}

.squareTable {
  border: 2px solid var(--squaretable-color)
}

#gameTableWithErrors {
  display: flex;
}

#errorTable {
  display: grid;
  grid-template-rows: repeat(5, var(--square-size)); 
  /* grid-template-rows: repeat(5, 3.2rem);  ⬅️ Match row height */
  /* grid-template-rows: repeat(5, clamp(2.4rem, 7vw, 3.2rem)); ⬅️ Match row height */
  gap: 0.5rem;
  padding: 0.5rem;
  margin-left: 0.02rem;
  max-width: 100vw;
  max-height: 80vh;
  box-sizing: border-box;
  transform-origin: top center;
}

.error-box {
  width: 100%;
  max-width: 18rem;
  height: 100%; /* ⬅️ Fills the grid row */
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 0.5rem 0.7rem;
  border: 2px solid transparent;
  font-size: 0.7rem;
  font-style: italic;
  line-height: 1.2;
  color: var(--errorbox_message-color);
  text-align: left;
  word-break: break-word;
  overflow-wrap: break-word;
  box-sizing: border-box;
  margin: 0; /* ⬅️ remove auto margin that misaligns */
}

#keyboard-container {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;

  width: 100%;
  padding: 0.75rem 0rem 1rem;
  box-sizing: border-box;

  background-color: var(--background-color); /* same as page background */
  z-index: 10;
}

/* rows + keys from earlier */
.keyboard-row {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
}

.keyboard-row:last-child {
  margin-bottom: 0;
}

.keyboard-row button {
  flex: 1 1 0;
  height: 3rem;
  background-color: var(--keyboard_rowbutton_lightmode-color); 
  color: var(--keyboard_letters_lightmode-color);
  border-radius: 0.25rem;
  border: none;
  text-transform: uppercase;
  font-weight: bold;
  font-size: 1rem;
  cursor: pointer;
  touch-action: manipulation;
}

.keyboard-row button.wide-button {
  flex: 1.4 1 0;
}


/* Optional: small-screen tweak so it doesn’t feel cramped */
@media (max-width: 480px) {
  .keyboard-row button {
    height: 2.6rem;
    font-size: 0.9rem;
  }
}


/* Status Popup */
#statusPopup {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 1rem;
  background-color: var(--statuspopup_box-color);
  color: var(--statuspopup_message-color);
  border-radius: 0.5rem;
  font-size: 1rem;
  text-align: center;
}

.fadeIn {
  animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Responsive Design */
@media (max-width: 600px) {
  .title {
    font-size: 1.16rem; /* Slightly smaller for tighter screens */
    text-align: center;
  }


  /* .stopwatchDisplay{
    margin-left: 0.6rem;
    font-size: 1rem;
    transform: scale(0.9); 

  }

  .icon-container{
    transform: scale(0.72); 
    transform-origin: right;
  } */

  .icon-inner,
  .header-left-inner {
    gap: 0.25rem; /* Slightly tighter spacing between icons */
  }

   /* MOBILE UNIFORM BUTTON BOX: stopwatch + lb + info + settings */
  .stopwatchDisplay,
  .lb-button,
  .info-button,
  .settings-button {
    width: 32px;
    height: 32px;
    margin: 0 0.25rem;   /* symmetric, small */
    padding: 0;
  }

  /* MOBILE UNIFORM GLYPH SIZE (affects all header icons equally) */
  .stopwatchDisplay svg,
  .lb-button svg,
  .info-button svg,
  .settings-button svg {
    width: 18px;
    height: 18px;
  }

  /* #originalWord {
    font-size: 2.25rem;
    margin: 1.25rem 0 0.5rem;
  } */

  #table-container {
    margin: 1rem 0;
    padding: 1rem;
    /* transform: scale(0.85); */
  }
  
  #gameTable .squareTable,
  #originalWordColumn .squareOW  {
    /* min-width: 3.2rem;
    min-height: 3.2rem;
    font-size: 1.4rem; */
    width: var(--square-size);
    height: var(--square-size);
    font-size: var(--square-font-size);
  }

  /* .error-box {
    font-size: 0.68rem;   
    min-width: 2.6rem;
    min-height: 2.6rem;
    line-height: 1.1;
    padding: 0 0rem;
    margin: 0rem 0;
    width: 150%;
    height: 3.2rem;
    text-overflow: ellipsis;
    overflow: hidden;
    justify-content: flex-start;
    align-items: center;
    text-align: left;
  } */

  #errorTable .error-box {
    height: 100%;              /* match the grid row height */
    width: 100%;               /* stay within its column, no 150% nonsense */
    max-width: 100%;           /* don't overflow on tiny screens */

    font-size: 0.65rem;
    line-height: 1.1;
    padding: 0 0.25rem;
    margin: 0;

    display: flex;
    justify-content: flex-start;
    align-items: center;
    text-align: left;
    word-break: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
    /* text-overflow: ellipsis;
    overflow: hidden; */
    /* white-space: nowrap;       optional: single line with ellipsis */
  }

  /* Optional: give keyboard container more breathing room */
  #keyboard-container {
    /* margin: 1rem 0; */
    margin:0;
    margin-left: 0rem;
    width: 100%;
    /* transform: scale(1); make it less gigantic on small screens */

  }

  .keyboard-row button {
    height: 3rem;
    font-size: 1rem;
  }

  #settingsFooter {
    font-size: 0.7rem;
    padding-bottom: 0.75rem;
  }
  

  #solution_image {
    margin-left: 0;
  }

  #solution_image_darkmode{
    margin-left: 0;
  }

}



  .varianterror-highlighted-border {
    border: 2px solid var(--variant_error-color);
    box-shadow: 0 0 5px 2px var(--variant_error_boxshadow-color);
  }

  .chosenletter-error-highlighted-border {
    border: 2px solid var(--chosenLetter_error-color);
    box-shadow: 0 0 5px 2px var(--chosenLetter_error_boxshadow-color);
  }

  .green-highlighted-border {
    border: 2px solid var(--correct_answer-color);
    box-shadow: 0 0 5px 2px var(--correct_answer_boxshadow-color);
  }

  .regular-border {
    border: 2px solid var(--regular_box-color);
    box-shadow: none;
  }


  #rulesHeader {
    display: flex;
    align-items: center;
    justify-content: start;
    padding: 10px 10px;
    width: 100%;
    border-bottom: 1px solid var(--border_bottom-color);
    position: relative;
  }
  
  #backtoGamefromRulesButton {
    border: none;
    background-color: transparent;
    color: var(--header_light_mode-color);
    font-size: 14px; /* reduced font size */
    font-weight: normal;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 4px 6px; /* smaller padding to bring it closer */
    margin-left: 0.25rem; /* fine-tune proximity to left edge */
  }
  
  #howToPlayHeading {
    color: var(--header_light_mode-color);
    font-family: var(--font_family-style);
    font-style: italic;
    font-weight: normal;
    font-size: 1.5rem;
    text-align: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
  }
  
#objective{
  font-family: var(--font_family-style);  
  font-style: italic;
  font-weight: bold;
  font-size: .8rem;
  color: black;
  padding: 0.6rem 3rem;
  margin-top:0.2rem;
  align-items: center; 
  background-color: #eaeaea;
  border-radius: 0.5rem;
}


#instructions_section {
  margin: 1rem;
  padding: 0.5rem 0.5rem;
}

#instructions_title {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  
}

#sub_instructions {
  list-style-type: disc;
  padding-left: 1.5rem;
  font-size: 0.75rem;
  line-height: 1.6;
}

#sub_instructions li::marker {
  color: #333; 
} 
 

#solution_and_cl_wrapper {
  display: flex;
  align-items: center; /* center content vertically */
  gap: 1.5rem;
  margin-top: 1.5rem;
  flex-wrap: wrap; /* allows stacking on smaller screens */
}


#example_image {
  margin-top: 10px;
  max-width: 100%;
  height: auto;
}

#solution_image {
  margin-top: 15px;
  margin-left: 35px;
  max-width: 8rem;
  width: 100%;
  height: auto;
}

#example_image_darkmode{
  margin-top: 10px;
  max-width: 100%;
  height: auto;
}

#solution_image_darkmode{
  margin-top: 15px;
  margin-left: 35px;
  max-width: 8rem;
  width: 100%;
  height: auto;
} 


/* Light mode images by default */
.example_images_light-mode {
  display: block;
}
.example_images_dark-mode {
  display: none;
}


#cl_definition_section {
  flex: 1;
  min-width: 12.5rem; /* 200px */
  padding: 0.75rem 1rem;
  background-color: #eaeaea;
  border-radius: 0.5rem;
  max-width: 100%;
}

#cl_title {
  font-family: var(--font_family-style);
  font-weight: 600;
  font-size: 0.85rem;
  color: black;
  margin: 0 0 0.5rem 0;
}

#cl_description {
  list-style-type: disc;
  padding-left: 1.25rem;
  font-family: var(--font_family-style);
  font-size: 0.7rem;
  color: #333;
  line-height: 1.5;
  margin: 0;
}

#cl_description li::marker {
  color: #333;
}

#Note_Section{
  margin: 1rem;
  padding: 0.5rem 0.5rem;
}

#Note_title{
  font-size: 1rem;
  font-family: var(--font_family-style);
  margin-bottom: 0.75rem;

}
#sub_notes{
  font-family: var(--font_family-style);
  list-style-type: disc;
  padding-left: 1.5rem;
  font-size: 0.75rem;
  line-height: 1.6;
} 

#sub_notes li::marker {
  color: #333;
}



#settingsHeader {
  display: flex;
  align-items: center;
  justify-content: start;
  padding: 10px 10px;
  width: 100%;
  border-bottom: 1px solid var(--border_bottom-color);
  position: relative;
}

#backtoGamefromSettingsButton {
  border: none;
  background-color: transparent;
  color: var(--header_light_mode-color);
  font-size: 14px; /* reduced font size */
  font-weight: normal;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 4px 6px; /* smaller padding */
  margin-left: 0.25rem; /* move closer to the left edge */
}

#settingsHeading {
  color: var(--header_light_mode-color);
  font-family: var(--font_family-style);
  font-style: italic;
  font-weight: normal;
  font-size: 1.5rem;
  text-align: center;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}

#hints{
  margin-top: 50px;
  align-items: center;
  margin-left: 5px;
  justify-content: space-between; /* Space between elements: title on left, toggle on right */
  border-bottom:0.5px solid var(--border_bottom-color);
}

#lightOrDarkMode{
  margin-top: 50px;
  align-items: center;
  margin-left: 5px;
  justify-content: space-between; /* Space between elements: title on left, toggle on right */
  border-bottom:0.5px solid var(--border_bottom-color);

}
#dark_mode_title{
  font-size: 18px;
  margin-right: 80%;
}
#sub-title_darkmode{
  font-size: 12px;
  margin-top: 1px;
  color: grey;
}
/* Toggle container */
.toggle {
  display: inline-flex;
  cursor: pointer;
  user-select: none;
  margin-left: 80%;
  transform: translateY(-120%); /* Correctly center the title horizontally */

}

/* Hidden checkbox */
.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* Track (background) */
.toggle .track {
  width: 32px;
  height: 16px;
  border-radius: 8px;
  background: #bbb;
  transition: background 0.25s ease-in-out;
  position: relative;
}

/* Thumb (the circle) */
.toggle .thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 1px;
  left: 1px;
  transition: transform 0.25s ease-in-out;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Checked state */
.toggle input:checked + .track {
  background: var(--main_theme-color);
}

.toggle input:checked + .track .thumb {
  transform: translateX(16px);
}

/* Focus ring for accessibility */
.toggle input:focus + .track {
  box-shadow: 0 0 0 2px var( --toggle_button_main_theme_shadow-color);
}

/* Send Feedback button */
#feedback_settings_option {
  margin-top: 5rem;
  text-align: center; /* or center if you prefer */
}

#openFeedbackBtn {
  font-family: var(--font_family-style);
  font-size: 1rem;
  padding: 0.5rem 1.2rem;
  border: none;
  border-radius: 0.4rem;
  background-color: rgba(249, 120, 205, 0.8);
  color: #222222;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

#openFeedbackBtn:hover {
  background-color: rgba(0, 0, 0, 0.1); /* slightly lighter on hover */
  color: var(--main_theme-color);
  border: 0.1rem solid var(--main_theme-color);
  background-color: white;
}


/* Feedback Modal Styling */
#feedbackModal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6); /* semi-transparent backdrop */
}

#feedbackModalContent {
  background-color: rgb(255,255,255);
  margin: 5% auto;
  padding: 1rem;
  border-radius: 0.5rem;
  width: 90%;
  max-width: 40rem;
  height: 80%;
  position: relative;
}

#feedbackModalContent iframe {
  border: none;
  width: 100%;
  height: 100%;
}

#closeFeedbackModal {
  position: absolute;
  top: 0.5rem;
  right: 1rem;
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
}

.privacy-policy {
  margin-top: 1.5rem;
  text-align: center;
}

.privacy-legal-link {
  font-size: 0.85rem;
  color: #666;
  text-decoration: underline;
}

body.dark-mode .privacy-legal-link,
body[data-theme="dark"] .privacy-legal-link {
  color: #aaa;
}



#settingsFooter {
  position: absolute;
  bottom: 1rem; /* leaves breathing room from bottom edge */
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: #888;
  text-align: center;
  width: 100%;
  max-width: 500px; /* match settings section max width */
  padding: 0 1rem;
  box-sizing: border-box;
}

#footerMessage{
  font-size: 1.5rem;
  bottom: 100%;
  text-align: center;
}


body.dark-mode {
  background-color: var(--dark_mode-background-color);
}
/* You can also override individual components: */
body.dark-mode .header-container {
  background-color: var(--dark_mode-background-color);
  border-color: #ccc;
}

body.dark-mode .squareTable {
  background-color: var(--dark_mode-background-color);
  color: #ccc;
}

body.dark-mode #container {
  background-color: var(--dark_mode-background-color);
  color: #ccc;
}

body.dark-mode .error-box {
  color: #ccc;
}
body.dark-mode #game{
  background-color: var(--dark_mode-background-color);
}

body.dark-mode #rulesSection{
  background-color: var(--dark_mode-background-color);
  color: #ccc;
}

body.dark-mode #objective{
  background-color: rgb(120, 210, 249, 0.25);
  color: #ccc;
}
body.dark-mode #instructions_title{
  color: #ccc; 
} 

body.dark-mode #sub_instructions{
  color: #ccc; 
}

body.dark-mode #sub_instructions li::marker {
  color: #ccc; 
}

body.dark-mode #cl_definition_section{
  background-color: rgb(120, 210, 249, 0.25);
}

body.dark-mode #cl_title{
  color: #ccc; 
} 

body.dark-mode #cl_description{
  color: #ccc; 
}

body.dark-mode #cl_description li::marker {
  color: #ccc; 
} 

body.dark-mode #sub_notes li::marker {
  color: #ccc; 
}

body.dark-mode #settingsSection{
  background-color: var(--dark_mode-background-color);
  color: #ccc;
}

body.dark-mode .settings-button{
  background-color: transparent;
  color: #ccc;
}

body.dark-mode .info-button{
  background-color: transparent;
  color: #ccc;
}

body.dark-mode #rulesHeader {
  border-color: #ccc;
}

body.dark-mode #settingsHeader {
  border-color: #ccc;
}

body.dark-mode #howToPlayHeading {
  color: var(--header_dark_mode-color);
}

body.dark-mode #backtoGamefromRulesButton{
  color: var(--header_dark_mode-color);
}

body.dark-mode #settingsHeading {
  color: var(--header_dark_mode-color);
}

body.dark-mode #backtoGamefromSettingsButton {
  color: var(--header_dark_mode-color);
}




body.dark-mode #hints{
  border-color: #ccc;
}

body.dark-mode #lightOrDarkMode{
  border-color: #ccc;
}

body.dark-mode #objective{
  color:#ccc;
}

body.dark-mode #footerMessage{
  color:#ccc;
}

body.dark-mode .title{
  color: var(--header_dark_mode-color);
}

body.dark-mode .subtitle{
  color: #ccc;

}

body.dark-mode .puzzle-caption{
  color: #ccc;

}

body.dark-mode .keyboard-row button{
  background-color: #818384;
  color: white;
}

/* When dark mode is active (your game toggles body.dark-mode) */
body.dark-mode .example_images_light-mode{
  display: none;
}
body.dark-mode .example_images_dark-mode  {
  display: block;
}

body.dark-mode #openFeedbackBtn{
  color: white;
}

body.dark-mode #openFeedbackBtn:hover{
  background-color: #222;
}

/* Base modal styling */
.modal {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  padding: 1.5em;
  width: 300px;
  background-color: var(--win_modal-bg-lightmode);
  border: 1px solid var(--share_score-border-color-lightmode);
  border-radius: 12px;
  box-shadow: 0 0 10px rgba(0,0,0,0.25);
  text-align: center;
  z-index: 1000;
}

.hidden {
  display: none;
}

#share-button {
  margin-top: 1em;
  padding: 0.6em 1.2em;
  font-size: 1em;
  border-radius: 8px;
  border: none;
  background-color: var(--header_light_mode-color);
  color: white;
  cursor: pointer;
}

/* Close "X" button */
.close-button {
  position: absolute;
  top: 8px;
  right: 10px;
  background: transparent;
  border: none;
  font-size: 1.2rem;
  color: var(--close_button_share_score-color-lightmode);
  font-weight: normal;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

/* Hover effect: slightly more visible */
.close-button:hover {
  opacity: 1;
}

#join-communities-text{
  margin-top: 2rem; /* 20px equivalent */
}

/* Styling the social media links container */
#socialMediaLinks {
  margin-top: 0.5rem; /* 20px equivalent */
  display: flex;
  justify-content: center;
  gap: 1rem; /* 16px equivalent, adjust spacing between logos */
}

/* Styling for each logo */
.socialLogo {
  width: 4rem;  /* 40px equivalent */
  height: auto;
  transition: transform 0.3s ease;
  background-color: transparent;
}

/* Hover effect for the logos */
.socialLogo:hover {
  transform: scale(1.1); /* Slight zoom effect on hover */
}

/*LEADERBOARD*/
#leaderboard-button {
  margin-top: 1em;
  padding: 0.6em 1.2em;
  font-size: 1em;
  border-radius: 8px;
  border: none;
  /* background-color: var(--header_light_mode-color);
  color: white; */
  background-color: var(--header_dark_mode-color);
  color: black;
  cursor: pointer;
}
#leaderboard-button:hover {
  opacity: 0.9;
}

/* Leaderboard Modal container & backdrop */
/* .lb-modal[aria-hidden="true"] { display: none; }
.lb-modal { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; } */
/* Modal root */
.lb-modal {
  position: fixed;
  inset: 0;
  display: grid;               /* restored when opened */
  place-items: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;        /* don't eat clicks by default */
  transition: opacity .15s ease;
}

/* Fully remove from stacking/context when closed */
.lb-modal[aria-hidden="true"] {
  display: none;
  opacity: 0;
  pointer-events: none;
}

/* Only interactive when open */
.lb-modal[aria-hidden="false"] {
  display: grid;               /* bring it back from display:none */
  opacity: 1;
  pointer-events: auto;
}

/* Backdrop sits under the panel and only catches clicks when open */
.lb-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(2px);
  z-index: 10;
  pointer-events: none;        /* default: ignore clicks */
}
.lb-modal[aria-hidden="false"] .lb-backdrop {
  pointer-events: auto;        /* clickable only when open */
}

/* LEADERBOARD Panel */
/* Base: good for most phones */
.lb-panel {
  position: relative;
  width: min(92vw, 34rem);
  max-height: 86vh;
  overflow: hidden;
  border-radius: 1rem;
  border: 1px solid rgba(0,0,0,.08);
  background: #fff;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: .5rem;
  z-index: 20;                     /* ensure panel is above backdrop */
  pointer-events: auto;            /* just in case you disabled this elsewhere */
}

/* Leaderboard name input */
#lbName {
  font-size: 16px;         /* stops Safari zoom */
  line-height: 1.4;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  width: 100%;
  box-sizing: border-box;
}

.lb-header { display:flex; align-items:center; justify-content:space-between; padding: 1rem 1.25rem; }
.lb-header h2 { margin: 0; font-size: 1.1rem; }
.lb-close { background: none; border: 0; font-size: 1.1rem; cursor: pointer; padding: .25rem .5rem; }

.lb-meta { display:flex; justify-content:space-between; align-items:center; padding: 0 .75rem .5rem 1.25rem; }
.lb-your-rank { font-weight: 700; }
.lb-date { opacity: .8; }

.lb-loading { padding: 1rem 1.25rem; opacity: .8; }

.lb-list { list-style:none; margin:0; padding: .25rem .25rem 1rem; overflow:auto; }
.lb-list li {
  display:grid; grid-template-columns: 3ch 1fr auto; gap:.75rem; align-items:center;
  padding: .5rem .75rem; border-bottom: 1px solid rgba(255,255,255,.08);
}
.lb-pos { text-align:right; opacity:.7; font-variant-numeric: tabular-nums; }
.lb-name { font-weight: 700; overflow:hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-stat { opacity:.9; font-variant-numeric: tabular-nums; }

.lb-footer { padding: .75rem 1.25rem 1rem; opacity:.7; font-size:.9rem; }

.lb-name-row {
  display:flex; gap:.5rem; align-items:center; padding: .5rem 1.25rem 1rem;
  border-top: 1px solid rgba(0,0,0,.08);
}
.lb-name-row label { font-size:.9rem; opacity:.8; }
.lb-name-row input {
  flex: 1; min-width: 10rem; padding:.4rem .6rem; border:1px solid #ddd; border-radius:.5rem;
}
.lb-name-row .btn {
  padding:.4rem .75rem; border:1px solid #ccc; background:#fff; border-radius:.5rem; cursor:pointer;
}


@media (prefers-reduced-motion: no-preference) {
  .lb-panel { animation: lbIn .18s ease-out; }
  @keyframes lbIn { from { transform: translateY(10px); opacity:.75; } to { transform:none; opacity:1; } }
}
/* Ultra-small devices (≤ 360px width) — give more breathing room */
@media (max-width: 360px) {
  .lb-panel {
    width: 94vw;                /* hug the viewport with tiny margins */
    border-radius: .75rem;
  }
  .lb-header h2 { font-size: 1rem; }
}

/* Landscape phones / small tablets (≥ 480px) — can expand a bit */
@media (min-width: 480px) {
  .lb-panel {
    width: min(92vw, 36rem);    /* ~576px max */
  }
}

/* Tablets in portrait (≥ 768px) — a little wider is fine */
@media (min-width: 768px) {
  .lb-panel {
    width: min(90vw, 38rem);    /* ~608px max */
  }
}

/* Laptops / desktops (≥ 1024px) — cap width for readability */
@media (min-width: 1024px) {
  .lb-panel {
    width: min(80vw, 40rem);    /* cap ~640px; plenty of room for rows */
  }
}

/* Optional: very large desktop screens (≥ 1440px) — nudge wider if desired */
@media (min-width: 1440px) {
  .lb-panel {
    width: min(70vw, 42rem);    /* ~672px absolute cap */
  }
}


/* Theme variables - assumes game adds these classes to <body> */
body.dark-mode .modal{
  background-color: #222222;
  border: 1px solid var(--share_score-border-color-darkmode);
}

body.dark-mode .close-button{
  filter: var(--close_button_share_score-color-darkmode);
}

body.dark-mode #share-button{
  background-color: var(--main_theme-color);
  color: white;
}

body.dark-mode #leaderboard-button{
  background-color: white;
  color: black;
}

/*TOOLTIPS for leaderboard icon and how to play icon (info icon)*/
/* Container so fixed tooltips layer above everything */
.onboarding-tooltip {
  position: fixed;
  z-index: 9999;
  font-size: 0.9rem;
  line-height: 1.2;
  background: #111;
  color: #fff;
  padding: 8px 10px;
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.25);
  opacity: 0;
  transform: translateY(4px); /* start slightly down for a nicer entrance */
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none; /* never block clicks */
  max-width: 220px;
  text-align: center;
}

/* arrow on TOP when tooltip is below the icon */
.onboarding-tooltip::after {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 0 6px 6px 6px;
  border-style: solid;
  border-color: transparent transparent #111 transparent;
}

.onboarding-tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .onboarding-tooltip { transition: none; }
}


.dark-mode .onboarding-tooltip {
  background: #ccc;
  color: #000;
}

.dark-mode .onboarding-tooltip::after {
  border-color: transparent transparent #ccc transparent;
}

