/* =====================================================
            RESPONSIVE REWRITE USING clamp()
   ===================================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Segoe UI", Arial, sans-serif;
}

body {
  min-height: 100dvh;
  width: 100%;
  background: linear-gradient(to bottom right, #fafafa, #ececec);
  color: #444;
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
}
body {
  background: linear-gradient(130deg, #ff9a9e, #fad0c4 30%, #a1c4fd 70%, #c2e9fb);
}


/* ===================== */
/*     HOME CONTAINER    */
/* ===================== */
.home-container {
  width: min(92vw, 420px);
  padding: clamp(24px, 6vw, 40px) clamp(20px, 5vw, 30px);
  background: #fff;
  border-radius: clamp(14px, 4vw, 18px);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 3vw, 18px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}
.home-container {
  background: linear-gradient(145deg,#ffffff,#f3f3f7);
  border: 1px solid rgba(129, 129, 129, 0.6);
  box-shadow: 
    0 20px 40px rgba(0,0,0,0.08),
    inset 0 0 0 1px rgba(255,255,255,0.4);
  backdrop-filter: blur(12px);
}

.Greeter {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;              /* space between Welcome + name */
  margin: 6px 0 16px 0;
}

.Greeter h3 {
  font-size: 16px;       /* smaller */
  font-weight: 600;
  margin: 0;
}

#nickname {
  font-size: 16px;       /* same size as Welcome */
  font-weight: 700;
  color: #6478e4;        /* highlight name */
  display: inline;       /* stays on the same line */
}

.title {
  font-size: clamp(28px, 7vw, 38px);
  font-weight: 700;
  color: #f7df2d;
  text-shadow:
    0 2px 4px rgba(0, 0, 0, 0.35),
    0 0 8px rgba(255, 235, 90, 0.5);
}

/* ===================== */
/*        BUTTONS        */
/* ===================== */
.button-group {
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 3vw, 15px);
}

.button-group button {
  padding: clamp(10px, 3vw, 14px) clamp(14px, 4vw, 18px);
  font-size: clamp(15px, 3.5vw, 17px);
  background: #f7f7f7;
  border: 2px solid #ddd;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.18s ease;
}

.button-group button:hover {
  background: #eaeaea;
  transform: translateY(-2px);
}

#playBtn {
  background: #1092dd;
  color: #fff;
  border: none;
}
#playBtn:hover {
  background: #1d55d8;
}
#logoutBtn:hover {
  background: #d81d1d;
  color: white;
}
#loginBtn:hover {
  background: #1da3d8;
  color: white;
}
#leaderboardBtn:hover {
  background: #eed231;
  color: rgb(0, 12, 29);
}
#dictionaryBtn:hover {
  background: #685ae6;
  color: white;
}
/* ===================== */
/*        MODALS         */
/* ===================== */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px) brightness(0.85);
  z-index: 100;
}

.modal.show {
  display: flex;
}

.modal-content {
  width: min(90vw, 360px);
  padding: clamp(20px, 5vw, 30px);
  background: #fff;
  border-radius: clamp(12px, 4vw, 16px);
  text-align: center;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
  animation: popIn 0.22s ease-out;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-content h2 {
  font-size: clamp(22px, 5vw, 26px);
  margin-bottom: 16px;
}

.modal-content input {
  width: 100%;
  padding: clamp(10px, 3vw, 12px);
  margin-bottom: 10px;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: clamp(14px, 3.5vw, 15px);
}

.modal-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
}

.modal-buttons button {
  padding: clamp(8px, 3vw, 10px) clamp(14px, 4vw, 18px);
  font-size: clamp(14px, 3.5vw, 15px);
  border-radius: 8px;
  border: none;
  background: #2667ff;
  color: #fff;
  cursor: pointer;
}
.signup-text{
  margin-top: 10px;
}
#closeModal,
#closeSignup {
  background: #aaa;
}

/* ===================== */
/*     GAME LAYOUT       */
/* ===================== */

#content {
  min-height: 100dvh;
  width: 100%;
  padding: clamp(16px, 5vw, 40px);
  display: flex;
  justify-content: center;
  align-items: center;
}

#backBtn {
  position: fixed;
  top: clamp(12px, 3vw, 20px);
  left: clamp(12px, 3vw, 20px);
  padding: clamp(8px, 2.5vw, 12px) clamp(12px, 4vw, 18px);
  font-size: clamp(14px, 3.5vw, 15px);
  border-radius: 10px;
  border: none;
  background: #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

#backBtn:hover {
  cursor: pointer;
  transform: translateY(-2px);
  background: #f3f3f3;
}

.game-container {
  width: min(92vw, 460px);
  padding: clamp(18px, 5vw, 28px);
  background: #fff;
  border-radius: clamp(14px, 4vw, 18px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 3vw, 16px);
}

#current_level {
  font-size: clamp(22px, 5vw, 32px);
}

.images {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(6px, 2vw, 12px);
  width: 100%;
}

.images img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: clamp(10px, 2.5vw, 12px);
  background: #ddd;
}

.answer-boxes {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(6px, 2vw, 10px);
  flex-wrap: wrap;
}

@media (max-width: 600px) {
  #answerBoxes {
    display: flex;
    flex-wrap: nowrap;     /* force one row */
    overflow-x: auto;      /* scroll instead of shrink */
    overflow-y: hidden;    
    justify-content: flex-start;   /* ← important */
  }

  /* important: don't let boxes disappear */
  #answerBoxes .answer-box {
    flex-shrink: 1;
  }
  #answerBoxes {
    justify-content: center;
  }

  #answerBoxes.long-word {
    justify-content: flex-start;
  }

}

.answer-box {
  width: clamp(36px, 8vw, 48px);
  aspect-ratio: 1 / 1;
  background: #d1d1d1;
  border-radius: 10px;
  font-size: clamp(16px, 4vw, 22px);
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#answerBoxes.shrink-word .answer-box {
  flex-shrink: 1;
  width: clamp(20px, 8vw, 48px);
  min-width: 38px; /* default for <= 9 if you want */
  font-size: clamp(14px, 3vw, 20px);
}

#answerBoxes.very-long .answer-box {
  min-width: 30px; /* 👉 only when length > 9 */
}


.letter-bank {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(6px, 2vw, 10px);
  width: 100%;
}

.letter-tile {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;

  background: #d1d1d1;
  border-radius: clamp(10px, 2.5vw, 14px);

  font-size: clamp(16px, 4vw, 20px);
  font-weight: bold;

  cursor: pointer;
  user-select: none;
}

.letter-tile:active {
  transform: scale(0.95);
}

.letter-tile:hover {
  background: #c7c7c7;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(6px, 2vw, 10px);
}

.btn-group button {
  flex: 1 1 min(45%, 160px);
  padding: clamp(10px, 3vw, 14px);
  font-size: clamp(14px, 3.5vw, 16px);
  border-radius: 10px;
  border: none;
  background: #b3c5ff;
  color: #1d1d1d;
  cursor: pointer;
}

#nextBtn {
  background: #acffc0;
}

#resetLvls {
  width: 100%;
  padding: clamp(10px, 3vw, 14px);
  background: #7c2020;
  color: #ffffff;
  border-radius: 14px;
  cursor: pointer;
  border-style: none;
}

/* === CUSTOM ALERT (CLAMP VERSION) === */
.custom-alert {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(6px);
  z-index: 999;
}

.alert-box {
  background: #fff;
  padding: clamp(18px, 4vw, 30px);
  border-radius: clamp(12px, 3vw, 16px);
  width: min(90vw, 320px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
  text-align: center;
  animation: pop 0.2s ease;
}

.alert-box p {
  font-size: clamp(14px, 3.5vw, 16px);
  color: #333;
}

@keyframes pop {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

#alertOk {
  margin-top: clamp(14px, 3vw, 20px);
  width: 100%;
  padding: clamp(8px, 2.5vw, 12px);
  background: #1a73e8;
  color: #fff;
  border-radius: clamp(8px, 2.5vw, 10px);
  border: none;
  cursor: pointer;
  font-size: clamp(14px, 3.5vw, 16px);
  transition: background 0.2s ease;
}

#alertOk:hover {
  background: #1669c2;
}

.level-header {
  display: block;
}

.points-ui {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 20px;
  font-weight: bold;
}

@media (max-width: 400px) {
  .level-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .points-ui {
    position: static; /* disables absolute */
    margin-bottom: 0;
    font-size: 16px;
  }
}
@media (max-width: 350px) {
  .points-ui {
    font-size: 14px;
  }
}

.popup {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.popup.hidden {
  display: none;
}

.popup-card {
  background: #ffffff;
  color: #222;
  padding: 26px 22px;
  border-radius: 18px;
  width: 90%;
  max-width: 330px;
  text-align: center;
  box-shadow: 0 20px 45px rgba(0,0,0,0.28);
  animation: popIn 0.3s ease;
  border-top: 6px solid #2e85e9;
}

.popup-card i {
  font-size: 38px;
  margin-bottom: 8px;
  color: #2ce94c;
}

.popup-card h2 {
  margin: 6px 0;
  font-size: 22px;
  font-weight: 700;
}

.popup-card p {
  font-size: 14px;
  color: #555;
  line-height: 1.5;
  margin-bottom: 18px;
}

.popup-card button {
  border: none;
  background: #222;
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  transition: 0.2s ease;
}

.popup-card button:hover {
  background: #000;
  transform: translateY(-1px);
}

@keyframes popIn {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.popup {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;

  /* 🔒 disable background interaction */
  pointer-events: all;
}

.popup.hidden {
  display: none;
}

.popup-card {
  position: relative;
  background: #fff;
  color: #222;
  padding: 30px 24px;
  border-radius: 18px;
  width: 90%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
  animation: popIn 0.35s ease;
}

.popup-card i {
  font-size: 42px;
  color: #f4b400;
  margin-bottom: 10px;
}

.popup-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.popup-actions button {
  flex: 1;
  border: none;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: bold;
}

.popup-actions button.secondary {
  background: #eee;
  color: #333;
}

.popup-actions button:not(.secondary) {
  background: #222;
  color: white;
}

/* 🎊 Confetti canvas */
#confettiCanvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

#levelConfetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
}

.danger-btn {
  background-color: #7c2020;
  color: white;
}

.answer-box.space {
  visibility: hidden;
  width: 20px;
  margin: 0;
  padding: 0;
}

.level-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.level-meta span {
  padding: 4px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: bold;
  gap: 4px;              /* space between emoji and text */
  line-height: 1;        /* prevents tall pill look */
}

/* Difficulty colors */
#difficultyTag.easy { background:#c8ffc8; }
#difficultyTag.medium { background:#fff4b8; }
#difficultyTag.hard { background:#ffb8b8; }

/* Community generic style */
#communityTag {
  background:#dbe6ff;
}

@media (max-width: 480px) {
  .level-header {
    display: flex;
    justify-content: space-between;  /* level left, points right */
    width: 100%;
  }

  .level-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    width: 100%;          /* full width under header */
  }
}

.points-ui {
  padding: 6px 12px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 14px;
  background: #fff;
  border: 2px solid #ffd966;
  box-shadow: 0 3px 0 #e6c157;
}

.button-group button {
  background: linear-gradient(#ffffff, #e9e9e9);
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.button-group button:hover {
  box-shadow: 0 6px 14px rgba(0,0,0,0.18);
}
