:root{
  --bg:#0b0b0d;
  --panel:#101014;
  --text:#f3f3f5;
  --muted:#b8b8c2;
  --line:#252531;
  --gold:#d4af37;
  --gold2:#f2d27a;
  --shadow:0 16px 40px rgba(0,0,0,.45);
  --radius:18px;
}

*{box-sizing:border-box}
html,body{height:100%}

body{
  margin:0;
  background:
    radial-gradient(900px 480px at 20% 10%, rgba(212,175,55,.13), transparent 60%),
    radial-gradient(900px 480px at 80% 20%, rgba(242,210,122,.08), transparent 60%),
    var(--bg);
  color:var(--text);
  font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Arial,"Helvetica Neue",Helvetica;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}

/* ===== LAUNCH ===== */

.launchScreen{
  position:fixed;
  inset:0;
  background:radial-gradient(circle at center, #1a1a1a 0%, #000 72%);
  display:flex;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  z-index:99999;
}

.launchLogo{
  width:160px;
  height:160px;
  object-fit:cover;
  border-radius:30px;
  box-shadow:0 0 32px rgba(212,175,55,.24);
  margin-bottom:22px;
}

.launchTitle{
  color:#d4af37;
  font-size:26px;
  font-weight:700;
  margin:0;
}

.launchCopy{
  color:#aaa;
  font-size:13px;
  margin-top:8px;
  text-align:center;
  max-width:520px;
  padding:0 20px;
}

/* ===== PAGE WRAP ===== */

.wrap{
  max-width:1280px;
  margin:0 auto;
  padding:26px 22px 56px;
}

.top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 2px 14px;
  flex-wrap:wrap;
}

.challengeBanner{
  text-align:center;
  font-weight:600;
  letter-spacing:.05em;
  padding:12px 16px;
  margin:8px 0 22px;
  border-radius:14px;
  border:1px solid rgba(255,215,0,.35);
  background:linear-gradient(90deg,#1a1a1a,#111);
  color:#f5d27a;
  font-size:15px;
  width:100%;
}

.heroTop{
  width:100%;
  text-align:center;
  margin:18px 0 26px;
}

.heroTitle{
  margin:0;
  font-size:clamp(56px, 7vw, 92px);
  line-height:1.02;
  letter-spacing:-0.03em;
  text-shadow:0 0 28px rgba(212,175,55,.18);
}

.heroSub{
  margin:12px 0 0;
  color:rgba(255,255,255,.86);
  font-size:18px;
  letter-spacing:.02em;
}

.tm{
  font-size:.26em;
  vertical-align:super;
  margin-left:2px;
  opacity:.9;
}

/* ===== MAIN LAYOUT ===== */

.main{
  display:grid;
  grid-template-columns:minmax(0, 1.18fr) minmax(340px, .82fr);
  gap:22px;
  align-items:start;
}

.main > *{
  align-self:start;
  min-height:0;
}

.panel{
  background:
    radial-gradient(1200px 500px at 20% -10%, rgba(212,175,55,.06), transparent 40%),
    linear-gradient(180deg, rgba(255,255,255,.025), transparent 34%),
    var(--panel);
  border:1px solid var(--line);
  border-radius:22px;
  box-shadow:
    0 20px 60px rgba(0,0,0,.52),
    inset 0 1px 0 rgba(255,255,255,.03);
  padding:22px;
  overflow:hidden;
  min-height:auto;
  height:auto;
}

.panelHead{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  padding-bottom:14px;
  border-bottom:1px solid rgba(255,255,255,.06);
  margin-bottom:16px;
}

.panelTitle{
  font-size:42px;
  font-weight:700;
  line-height:1.05;
}

.panelMeta{
  display:flex;
  align-items:center;
  gap:12px;
  color:var(--muted);
  font-size:14px;
  flex-wrap:wrap;
}

.meta{
  padding:8px 12px;
  border-radius:999px;
  background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.06);
  font-size:14px;
}

.demoContextLine,
.subtext{
  font-size:17px;
  line-height:1.5;
}

/* ===== PUZZLE GRID ===== */

.gridShell{
  width:100%;
  display:flex;
  justify-content:center;
  align-items:flex-start;
  padding:16px 0 14px;
}

.grid{
  width:min(100%, 620px);
  aspect-ratio:1 / 1;
  display:grid;
  grid-template-columns:repeat(9, 1fr);
  gap:10px;
  margin:0 auto;
  touch-action:none;
  user-select:none;
  -webkit-user-select:none;
  box-shadow:
    0 0 0 1px rgba(212,175,55,.15),
    0 12px 40px rgba(0,0,0,.6),
    0 0 40px rgba(212,175,55,.12);
}

.cell{
  border-radius:14px;
  border:1px solid rgba(255,255,255,.08);
  background:rgba(255,255,255,.03);
  display:grid;
  place-items:center;
  font-weight:800;
  letter-spacing:.06em;
  text-transform:uppercase;
  font-size:clamp(18px, 2vw, 26px);
  color:rgba(243,243,245,.92);
  aspect-ratio:1 / 1;
  width:100%;
  line-height:1;
  transition:transform .12s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
  cursor:pointer;
  appearance:none;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.03);
}

.cell:hover{
  transform:scale(1.05);
}

.cell.found{
  border-color:rgba(212,175,55,.55);
  background:linear-gradient(180deg, rgba(212,175,55,.22), rgba(212,175,55,.08));
  color:var(--gold2);
  box-shadow:
    0 0 0 1px rgba(201,162,58,.18) inset,
    0 0 12px rgba(201,162,58,.18);
}

.cell.preview{
  background:rgba(255, 215, 0, 0.35) !important;
  border:2px solid #f5d06f !important;
  box-shadow:0 0 10px rgba(245, 208, 111, 0.45) !important;
}

.cell.anchor{
  background:rgba(255, 215, 0, 0.55) !important;
  border:2px solid #ffd86b !important;
  box-shadow:0 0 16px rgba(255, 216, 107, 0.75) !important;
  transform:scale(1.04);
}

/* ===== HINTS / STATUS ===== */

.hint{
  display:flex;
  align-items:flex-start;
  gap:10px;
  color:var(--muted);
  font-size:14px;
}

.hintDot{
  width:10px;
  height:10px;
  border-radius:99px;
  background:rgba(212,175,55,.8);
  margin-top:4px;
  box-shadow:0 0 0 4px rgba(212,175,55,.12);
}

.tap-hint{
  margin-top:10px;
  font-size:14px;
  color:#f5d06f;
  opacity:0;
  transition:opacity .25s ease;
}

.tap-hint.show{
  opacity:1;
}

.dailyBest{
  margin:10px 0 12px 0;
  color:#f5d27a;
  font-size:16px;
}

.leaderboardTitle{
  margin-top:18px;
  margin-bottom:12px;
  font-size:14px;
  font-weight:600;
  letter-spacing:.14em;
  text-transform:uppercase;
  color:#d4af37;
}

#puzzleLeaderboard{
  min-height:92px;
  font-size:16px;
  line-height:1.6;
  color:rgba(255,255,255,.9);
}

.progressWrap{
  margin:16px 0 18px;
  font-size:17px;
  color:rgba(255,255,255,.88);
}

.words{
  display:flex;
  flex-wrap:wrap;
  gap:14px;
  margin-top:14px;
}

.wordChip{
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:56px;
  padding:14px 18px;
  border-radius:18px;
  background:rgba(255,215,0,.06);
  border:1px solid rgba(255,215,0,.35);
  color:#f5d06f;
  font-size:18px;
  font-weight:700;
  letter-spacing:.04em;
  box-shadow:0 0 0 1px rgba(255,215,0,.05) inset;
}

.wordChip.found{
  background:linear-gradient(135deg, #d4af37, #f5d06f);
  color:#111;
  border-color:#f5d06f;
  box-shadow:0 0 14px rgba(245, 208, 111, 0.45);
}

/* ===== BUTTONS ===== */

.ctaRow{
  display:flex;
  gap:12px;
  margin-top:20px;
  flex-wrap:wrap;
}

.btn{
  appearance:none;
  border:none;
  border-radius:16px;
  padding:13px 18px;
  min-height:48px;
  font-size:15px;
  font-weight:600;
  color:var(--text);
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.10);
  cursor:pointer;
  text-decoration:none;
}

.btn.gold{
  background:linear-gradient(180deg, rgba(242,210,122,.34), rgba(212,175,55,.22));
  border-color:rgba(212,175,55,.45);
  color:#fff;
  box-shadow:0 10px 24px rgba(212,175,55,.14);
}

.foot{
  margin-top:14px;
  color:rgba(184,184,194,.9);
}

.fineprint{
  font-size:13px;
  line-height:1.4;
  opacity:.88;
}

/* ===== POPUP ===== */

.popup.hidden{
  display:none;
}

.popup{
  position:fixed;
  inset:0;
  z-index:9999;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:30px;
}

.popupBackdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 4, 10, 0.65);
  backdrop-filter: blur(10px);
}

.celebrationCard{
  animation: rewardPop .45s ease-out;
}

@keyframes rewardPop{
  0%{
    transform: scale(.92);
    opacity:0;
  }
  60%{
    transform: scale(1.03);
  }
  100%{
    transform: scale(1);
    opacity:1;
  }
}

.popupBadge{
  font-size:12px;
  padding:9px 15px;
  margin-bottom:16px;
}

.popupTitle{
  font-size:clamp(34px, 4vw, 48px);
  margin-bottom:10px;
}

.popupHeadline{
  font-size:20px;
  margin-bottom:16px;
}

.popupFinishText{
  font-size:17px;
  max-width:480px;
  margin:0 auto 22px;
}

.popupStats{
  gap:14px;
  margin-bottom:20px;
}

.statCard{
  padding:16px;
  border-radius:20px;
}

.statValue{
  font-size:28px;
}

.popupCrowdLine{
  font-size:16px;
  margin-bottom:24px;
}

.popupActions{
  gap:14px;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 1100px){
  .main{
    grid-template-columns:1fr;
  }

  .panel{
    min-height:auto;
    height:auto;
  }

  .grid{
    width:min(100%, 560px);
  }
}

@media (max-width: 640px){
  .wrap{
    padding:14px 10px 34px;
  }

  .heroTitle{
    font-size:clamp(34px, 10vw, 54px);
  }

  .heroSub{
    font-size:15px;
  }

  .challengeBanner{
    font-size:14px;
    padding:10px 12px;
  }

  .panel{
    padding:14px;
    border-radius:18px;
  }

  .panelTitle{
    font-size:30px;
  }

  .panelHead{
    gap:8px;
  }

  .grid{
    width:min(100%, 430px);
    gap:6px;
  }

  .cell{
    font-size:clamp(13px, 4vw, 18px);
    border-radius:10px;
  }

  .wordChip{
    min-height:46px;
    font-size:15px;
    padding:10px 12px;
  }

  .celebrationCard{
    padding:26px 18px 20px;
  }

  .popupStats{
    grid-template-columns:1fr;
  }
}

#puzzleCompletePopup.hidden {
  display: none;
}

.popupCard,
.celebrationCard {
  position: relative;
  z-index: 2;
  width: min(92vw, 520px);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(20,22,30,.98), rgba(8,10,18,.98));
  border: 1px solid rgba(212,175,55,.35);
  box-shadow:
    0 30px 80px rgba(0,0,0,.65),
    0 0 0 1px rgba(255,215,90,.08) inset;
  padding: 28px;
}

.reward-footer-cta {
  color: #d4af37;
  font-weight: 700;
  display: inline-block;
  animation: rewardPulse 1.6s ease-in-out infinite;
}

@keyframes rewardPulse {
  0% {
    transform: scale(1);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.05);
    opacity: 1;
    text-shadow: 0 0 12px rgba(212,175,55,0.6);
  }
  100% {
    transform: scale(1);
    opacity: 0.85;
  }
}

.player-name-wrap {
  margin: 12px 0 16px;
}

#playerName {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(212,175,55,0.5);
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 16px;
  outline: none;
}

#playerName::placeholder {
  color: rgba(255,255,255,0.5);
}

.entryMicroCopy{
  margin:10px 0 0;
  font-size:14px;
  line-height:1.4;
  color:rgba(255,255,255,.72);
}