/* ====== style.css ====== */

/* 1) Reset & full‐screen flex setup */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}
body {
  display: flex;
  flex-direction: column;
  background: #fff;
  color: #333;
  font-family: 'Segoe UI', sans-serif;
  text-align: center;
}

/* Game container stacks vertically */
.game-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between; /* This is key! */
  align-items: center;
  padding: 0 10px env(safe-area-inset-bottom);
  overflow-y: auto;
}

/* ---- Header ---- */
h1 {
  font-size: 2.5rem;
  margin: 0 0 10px;
}
.plus { color: #4CAF50; }
#round {
  font-size: 1.3rem;
  margin: 0 0 10px;
}
#hint {
  font-style: italic;
  font-size: 1.2rem;
  margin: 0 0 20px;
}

/* ---- Word slots ---- */
#word {
  display: flex;
  justify-content: center;
  gap: 0.3em;
  font-family: 'Inter', sans-serif;
  font-size: 2rem;
  white-space: nowrap;
}
.letter-slot {
  display: inline-flex;
  justify-content: center;
  align-items: flex-end;
  width: 1.2ch;
  height: 1.2em;
  font-size: inherit;
  font-family: inherit;
  line-height: 1.2em;
  text-align: center;
  box-sizing: border-box;
}
.letter-slot:not(.filled) {
  border-bottom: 3px solid currentColor;
}
.letter-slot.filled {
  border-bottom: none;
}

/* ---- Hangman container ---- */
.hangman-container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-grow: 1;
  padding: 1rem 0;
  max-height: 30vh; /* Limit height to prevent crowding keyboard */
  box-sizing: border-box;
}

#hangman {
  width: 100%;
  max-width: 300px;
  height: auto;
  max-height: 130%;
}


.gallow {
  stroke: #444;
  stroke-width: 4;
}
.part {
  stroke: #000;
  stroke-width: 4;
  fill: none;
  display: none;
}

#status:empty {
  margin: 0;
}

#status {
  font-size: 1.3rem;
  margin: 20px 0 0;
}

#letters {
  position: flex;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #fff;
  padding: env(safe-area-inset-bottom) 10px 10px;
  box-shadow: none;
  box-sizing: border-box;
  overflow-x: hidden;
}
.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin: 4px 0;
}
.letter-button {
  flex: 1;
  min-width: 0; /* allow shrinking */
  max-width: 35px;
  height: 48px;
  border: none;
  border-radius: 4px;
  background: #ddd;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
  text-decoration: none;
  color: #333;
  box-sizing: border-box;
}

.letter-button:hover {
  transform: scale(1.05);
  background: #bbb;
}
.letter-button:disabled {
  background: #aaa;
  color: #666;
  cursor: not-allowed;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.hidden { display: none; }
.modal {
  position: relative;
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  width: 90%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  box-shadow: 0 8px 16px rgba(0,0,0,0.1);
  text-align: center;
}
.modal::-webkit-scrollbar {
  display: none;
}
.modal h2 {
  margin-bottom: 16px;
  font-size: 1.5rem;
}
.modal button {
  padding: 15px 15px;
  font-size: 1.8rem;
  border: none;
  border-radius: 4px;
  background: #4CAF50;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}

.reset-info {
  font-size: 0.9rem;
  color: #777;
  margin: 8px 0 16px;
}

.desc {
  font-size: 14px;
  color: #555;
  margin: 0 0 12px;
}
.rule-section {
  text-align: left;
}
.rule-section h3 {
  margin: 10px 0 4px;
  font-size: 1.1rem;
}
.rule-section p {
  margin: 0 0 10px;
  line-height: 1.4;
}
.rules {
  list-style: none;
  padding: 0;
  margin: 0 0 10px;
}
.rules li {
  margin-bottom: 4px;
  padding-left: 1em;
  text-indent: -1em;
}
.rules li::before {
  content: "•";
  padding-right: 8px;
  color: #777;
}
.demo {
  background: #f7f9fa;
  border-radius: 4px;
  padding: 7px 9px;
  margin: 8px 0 8px;
  color: #444;
  text-align: center;
}
.demo img {
  max-width: 100%;
  border-radius: 6px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.08);
  margin: 6px 0 4px;
}
.modal .modal-close {
  background: none;
  color: #666;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font-size: 36px;       /* same size as sidebar X */
  line-height: 1;
  color: #666;           /* gray color */
  cursor: pointer;
}

.modal-close:hover {
  color: #000;           /* darken on hover */
}


.modal-logo {
  font-size: 2.5rem;
  margin: 0 0 4px;
  line-height: 1;
}
.correct {
  background-color: #4CAF50 !important;
  color: white !important;
}
.incorrect {
  background-color: #aaa !important;
  color: #666 !important;
}
@keyframes shake {
  0% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
  100% { transform: translateX(0); }
}
.hangman-container.shake {
  animation: shake 0.4s ease;
}
.share-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}
#share-button {
  background-color: #4CAF50;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  margin: 8px;
  font-size: 1rem;
  cursor: pointer;
}
#close-button {
  background-color: #e0e0e0;
  color: #333;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  margin: 8px;
  font-size: 1rem;
  cursor: pointer;
}
#close-button:hover {
  background-color: #ccc;
}
.transparent-modal {
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0,0,0,0.1);
}
.overlay.persistent {
  z-index: 2000;
}
#streak-display {
  font-size: 1.1rem;
  margin-bottom: 10px;
  color: #555;
}

/* === Sidebar Menu === */
#sidebar {
  position: fixed;
  top: 0;
  left: -400px;
  width: 220px;
  height: 100vh;
  background: #fff;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
  transition: left 0.3s ease-in-out;
  z-index: 3000;
  text-align: left;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
  box-sizing: border-box;
}

/* Show sidebar when open */
#sidebar.open {
  left: 0;
}

/* Close button at top right of sidebar */
#sidebar button#closeSidebar {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  font-size: 22px;
  color: #666;
  cursor: pointer;
  z-index: 1;
}

/* Scrollable area for content */
.sidebar-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px;
  margin-top: 60px;
}

/* Navigation links */
#sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

#sidebar ul li {
  margin: 20px 0;
}

#sidebar ul li a {
  text-decoration: none;
  font-size: 1rem;
  color: #333;
  transition: color 0.2s ease;
}

#sidebar ul li a:hover {
  color: #4CAF50;
}

/* Footer sticks to bottom */
.sidebar-footer {
  font-size: 0.8rem;
  color: #666;
  border-top: 1px solid #eee;
  padding: 12px 20px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 20px));
  text-align: left;
  background: #fff;
}

.sidebar-footer a {
  color: #4CAF50;
  text-decoration: none;
  display: block;
  margin-top: 4px;
}

.sidebar-footer a:hover {
  text-decoration: underline;
}

.menu-toggle {
  position: fixed;
  top: 16px;
  left: 16px;
  background-color: #4CAF50;
  color: #fff;
  border: none;
  padding: 8px 14px;
  font-size: 18px;
  cursor: pointer;
  border-radius: 4px;
  z-index: 3100;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
#howToPlayOverlay {
  z-index: 4000 !important;
}

#openSidebar {
  z-index: 3000;
}

#openSidebar {
  z-index: 3200; /* must be higher than #share-overlay and #share-card */
}

/* Hide menu button when modal is open */
body.modal-open .menu-toggle {
  display: none;
}

#share-card {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.95); /* ← white fade */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2999;
}

#share-card.hidden {
  display: none !important;
}


#share-overlay {
  display: none; /* ⬅️ Also hide this initially */
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 100vw;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(3px);
  z-index: 2999;
}

#share-card .modal {
  background: #fff;            /* pure white panel */
  border-radius: 8px;
  padding: 24px;
  width: 90%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 16px rgba(0,0,0,0.2);
  text-align: center;
}


#share-overlay {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 100vw;
  background: rgba(0, 0, 0, 0.6);  /* ✅ darker dimming */
  backdrop-filter: blur(3px);
  z-index: 9998;  /* Behind the share card */
}


.share-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0; /* Remove extra padding */
}
#share-header {
  font-size: 1.4rem;
  font-weight: 700;
  color: #222;
  text-align: center;
  margin-bottom: 10px;
}

#share-header h2 {
  margin: 0 0 10px;
  font-size: 1.5rem;
  font-weight: 700;
}

#share-header p {
  font-size: 1rem;
  margin: 0 0 10px;
}

.share-actions {
  margin-top: 16px;
}

#share-result p {
  margin: 4px 0;
  font-size: 0.95rem;
  color: #444;
}

#share-button {
  margin-top: 15px;
  padding: 10px 18px;
  background-color: #4CAF50;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.3s ease;
}
#share-button:hover {
  background-color: #43a047;
}

#close-button {
  display: inline-block;
  margin-top: 12px;
  font-size: 0.85rem;
  color: #888;
  text-decoration: underline;
  cursor: pointer;
}

@keyframes blurFadeIn {
  from {
    opacity: 0;
    filter: blur(10px);
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    filter: blur(0);
    transform: scale(1);
  }
}

#share-card {
  animation: blurFadeIn 1.5s ease-out;
}

#share-card p,
#share-card h2,
#share-result p {
  margin: 6px 0;
  line-height: 1.3;
}

html {
  touch-action: manipulation;
}

/* === Streak Milestones Section === */
#streak-milestones {
  text-align: center;
  margin: 1.5rem 0;
}
.badges-container {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.badge-icon {
  width: 70px;    /* smaller badge size */
  height: 70px;
  object-fit: contain;
}

/* === Toast from Top === */
#toast-container {
  position: fixed;
  bottom: auto;    /* disable bottom positioning */
  top: 20px;       /* pin to top */
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 5000;
}
.toast {
  display: inline-block;
  margin-top: 8px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 0.95rem;
  
  /* start hidden above, then slide down, then fade out */
  opacity: 0;
  transform: translateY(-20px);
  animation: toast-in-top 0.5s forwards ease-out,
             toast-out    2.5s forwards ease-in 2.5s;
}

/* slide down into view */
@keyframes toast-in-top {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* fade/slide away (keep your existing toast-out definition) */
/* @keyframes toast-out {
  to { opacity: 0; transform: translateY(20px); }
} */
