
:root{
  --bg1:#b5ffd9;
  --bg2:#a5d8ff;
  --bg3:#fbd1ff;

  --card:#ffffffcc;
  --card2:#ffffff;
  --stroke:rgba(0,0,0,.08);

  --text:#0f172a;
  --muted:#4b5563;

  --p:#14b8a6;
  --p2:#0ea5e9;
  --danger:#ef4444;
  --warn:#f59e0b;
  --good:#22c55e;

  --shadow: 0 22px 55px rgba(15,23,42,.18);
  --shadow2: 0 12px 28px rgba(15,23,42,.12);

  --radius: 26px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family:"Poppins",system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  color:var(--text);
  background: radial-gradient(circle at 20% 10%, var(--bg1), transparent 55%),
              radial-gradient(circle at 80% 20%, var(--bg2), transparent 55%),
              radial-gradient(circle at 40% 90%, var(--bg3), transparent 55%),
              linear-gradient(135deg, #ffffff, #f7f7ff);
  overflow-x:hidden;
}

#confetti{
  position:fixed;
  inset:0;
  width:100%;
  height:100%;
  pointer-events:none;
  z-index:5;
}

/* Ambient orbs */
.bg-orb{
  position:fixed;
  width:420px;
  height:420px;
  border-radius:50%;
  filter: blur(50px);
  opacity:.35;
  z-index:0;
  animation: floaty 16s ease-in-out infinite;
}
.o1{ left:-120px; top:-110px; background: var(--bg1); }
.o2{ right:-140px; top:120px; background: var(--bg2); animation-delay: -6s; }
.o3{ left:20%; bottom:-200px; background: var(--bg3); animation-delay: -10s; }

@keyframes floaty{
  0%,100%{ transform: translateY(0) translateX(0) scale(1); }
  50%{ transform: translateY(25px) translateX(18px) scale(1.06); }
}

.wrap{
  position:relative;
  z-index:1;
  width:min(1100px, 92vw);
  margin: 18px auto 30px;
}

.hero{
  display:grid;
  grid-template-columns: 1.2fr .9fr;
  gap: 18px;
  align-items:stretch;
}

.hero-left{
  background: linear-gradient(180deg, #ffffffcc, #ffffffaa);
  border:1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow2);
  padding: 18px 18px 16px;
  overflow:hidden;
  position:relative;
}

.brand{
  display:flex;
  gap:12px;
  align-items:center;
  margin-bottom:10px;
}
.logo{
  width:44px; height:44px;
  border-radius:14px;
  display:grid; place-items:center;
  font-weight:800;
  background: linear-gradient(135deg, var(--p), var(--p2));
  color:#fff;
  box-shadow: 0 12px 20px rgba(14,165,233,.25);
}
.brand-text .t1{ font-weight:800; letter-spacing:.3px; }
.brand-text .t2{ font-size:12px; color:var(--muted); margin-top:-2px; }

.hero-left h1{
  margin:6px 0 6px;
  font-size: clamp(26px, 3vw, 38px);
  line-height:1.05;
}
.chip{
  display:inline-block;
  font-size:12px;
  padding:6px 10px;
  border-radius:999px;
  background: linear-gradient(135deg, rgba(20,184,166,.18), rgba(14,165,233,.14));
  border:1px solid rgba(14,165,233,.22);
  vertical-align:middle;
  margin-left:8px;
}
.subtitle{
  margin:0 0 10px;
  color:var(--muted);
  font-size: 14px;
}
.hero-badges{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}
.badge{
  font-size:12px;
  padding:7px 10px;
  border-radius:999px;
  border:1px solid var(--stroke);
  background:#fff;
}

.hero-right{ display:flex; }
.scorecard{
  width:100%;
  background: linear-gradient(180deg, #ffffffcc, #ffffffaa);
  border:1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow2);
  padding: 16px;
  display:flex;
  flex-direction:column;
  gap:12px;
}

.sc-top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.sc-title{ font-weight:800; }
.sc-tools{ display:flex; gap:10px; flex-wrap:wrap; }

.sc-grid{
  display:grid;
  grid-template-columns: repeat(4,1fr);
  gap:10px;
}
.metric{
  background:#fff;
  border:1px solid var(--stroke);
  border-radius:18px;
  padding:10px 10px 9px;
}
.m-label{ font-size:11px; color:var(--muted); }
.m-value{ font-weight:800; margin-top:2px; }

.sc-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.lives{ display:flex; gap:6px; flex-wrap:wrap; }
.life{
  width:22px; height:22px;
  border-radius:7px;
  background: #fff;
  border:1px solid var(--stroke);
  display:grid; place-items:center;
  font-size:13px;
  transition: transform .15s ease, opacity .15s ease;
}
.life.dead{ opacity:.35; transform: scale(.92); }

.timer{
  background:#fff;
  border:1px solid var(--stroke);
  border-radius:18px;
  padding:10px 12px;
  min-width:120px;
  display:flex; align-items:baseline; justify-content:space-between;
  gap:10px;
}
.timer-label{ font-size:11px; color:var(--muted); }
.timer-value{ font-weight:900; }

.sc-actions{
  display:flex;
  gap:10px;
}
button{
  font-family: inherit;
  border:none;
  border-radius:16px;
  padding:10px 14px;
  cursor:pointer;
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
}
button:active{ transform: translateY(1px) scale(.99); }
.primary{
  background: linear-gradient(135deg, var(--p), var(--p2));
  color:#fff;
  box-shadow: 0 16px 24px rgba(20,184,166,.25);
}
.danger{
  background: linear-gradient(135deg, #ff5f6d, var(--danger));
  color:#fff;
  box-shadow: 0 16px 24px rgba(239,68,68,.22);
}
.ghost{
  background:#fff;
  border:1px solid var(--stroke);
  color:var(--text);
}
.big{ padding:12px 18px; border-radius:18px; }
button:disabled{ opacity:.45; cursor:not-allowed; transform:none; }

.achievements{
  background:#fff;
  border:1px solid var(--stroke);
  border-radius:18px;
  padding:10px 10px 12px;
}
.ach-title{ font-weight:900; font-size:12px; }
.ach-list{
  margin-top:8px;
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}
.ach{
  font-size:12px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--stroke);
  background: linear-gradient(135deg, rgba(245,158,11,.12), rgba(34,197,94,.10));
}

.main{ margin-top:18px; }
.panel{
  background: linear-gradient(180deg, #ffffffcc, #ffffffaa);
  border:1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel-head{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:14px;
  margin-bottom:12px;
}
.panel-title{ font-weight:900; font-size:18px; }
.panel-sub{ color:var(--muted); font-size:13px; }

.form-grid{
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap:12px;
}
.field{
  background:#fff;
  border:1px solid var(--stroke);
  border-radius:18px;
  padding:10px;
}
.field label{
  font-size:11px;
  color:var(--muted);
  display:block;
  margin-bottom:6px;
}
input, select{
  width:100%;
  border:1px solid rgba(0,0,0,.06);
  border-radius:14px;
  padding:10px 12px;
  outline:none;
  font-size:14px;
}
input:focus, select:focus{
  border-color: rgba(14,165,233,.35);
  box-shadow: 0 0 0 4px rgba(14,165,233,.12);
}

.start-actions{
  display:flex;
  gap:10px;
  justify-content:center;
  margin-top:12px;
  flex-wrap:wrap;
}
.spark{ margin-right:6px; }

.note{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:center;
  margin-top:12px;
  color:var(--muted);
  font-size:13px;
}
.dot{
  width:10px; height:10px;
  border-radius:50%;
  background: linear-gradient(135deg, var(--p), var(--p2));
}

.game-grid{
  display:grid;
  grid-template-columns: 1.2fr .8fr;
  gap:14px;
  align-items:stretch;
}

.stage{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.stage-top{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:12px;
}

.hint-box{
  background:#fff;
  border:1px solid var(--stroke);
  border-radius:22px;
  padding:12px;
  min-height:170px;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
}
.hint-title{ font-weight:900; }
.hint-text{ color:var(--muted); font-size:14px; margin-top:6px; line-height:1.3; }

.stickman{
  background:#fff;
  border:1px solid var(--stroke);
  border-radius:22px;
  padding:10px 10px 8px;
  position:relative;
  overflow:hidden;
}
.stage-label{
  margin-top:6px;
  font-size:12px;
  color:var(--muted);
  font-weight:600;
}

/* Stickman animations */
.stickman.shake{ animation: shake .35s ease; }
.stickman.jump{ animation: jump 0.6s ease; }
@keyframes shake{
  0%,100%{ transform: translateX(0); }
  20%{ transform: translateX(-6px) rotate(-1deg); }
  60%{ transform: translateX(6px) rotate(1deg); }
}
@keyframes jump{
  0%{ transform: translateY(0); }
  40%{ transform: translateY(-10px); }
  100%{ transform: translateY(0); }
}

.gallow{
  fill:none;
  stroke: rgba(15,23,42,.5);
  stroke-width:6;
  stroke-linecap:round;
  stroke-linejoin:round;
}
.part{
  fill:none;
  stroke: rgba(239,68,68,.75);
  stroke-width:6;
  stroke-linecap:round;
  stroke-linejoin:round;
  opacity:0;
  transform-origin:center;
  transform: scale(.9);
  transition: opacity .2s ease, transform .2s ease;
}
.part.on{
  opacity:1;
  transform: scale(1);
}
#p7,#p8,#p9{ stroke-width:4; }

.word-box{
  background:#fff;
  border:1px solid var(--stroke);
  border-radius:22px;
  padding: 14px;
  transition: box-shadow .15s ease, transform .15s ease;
}
.word-box.panic{
  box-shadow: 0 0 0 6px rgba(239,68,68,.12), 0 20px 40px rgba(239,68,68,.12);
  animation: panic .6s ease-in-out infinite;
}
@keyframes panic{
  0%,100%{ transform: translateX(0); }
  50%{ transform: translateX(2px); }
}

.word{
  font-size: clamp(22px, 3.3vw, 34px);
  letter-spacing: .28em;
  font-weight:900;
  text-align:center;
  margin: 2px 0 10px;
}
/* Reveal animation: per-letter spans */
.word .slot{
  display:inline-block;
  min-width: 18px;
  transform: translateY(0);
}
.word .reveal{
  animation: reveal .22s ease;
}
@keyframes reveal{
  from{ transform: translateY(6px) scale(.92); opacity:.3; }
  to{ transform: translateY(0) scale(1); opacity:1; }
}

.sub-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
}
.tries{ color:var(--muted); font-size:13px; }
.actions-mini{ display:flex; gap:10px; flex-wrap:wrap; }

.rightcol{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.keyboard-box{
  background:#fff;
  border:1px solid var(--stroke);
  border-radius:22px;
  padding: 14px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.kb-head{ display:flex; align-items:baseline; justify-content:space-between; gap:10px; }
.kb-title{ font-weight:900; }
.kb-sub{ color:var(--muted); font-size:12px; text-align:right; }

.letters.qwerty{
  display:grid;
  gap:8px;
}
.row{
  display:grid;
  grid-template-columns: repeat(10, 1fr);
  gap:8px;
}
.row.r2{ grid-template-columns: 0.5fr repeat(9,1fr) 0.5fr; }
.row.r3{ grid-template-columns: 1fr repeat(7,1fr) 1fr; }

.key{
  padding:10px 0;
  border-radius:16px;
  border:1px solid var(--stroke);
  background: linear-gradient(180deg, #ffffff, #fafafa);
  font-weight:800;
  letter-spacing:.6px;
  box-shadow: 0 10px 18px rgba(15,23,42,.06);
}
.key.hit{
  background: linear-gradient(135deg, rgba(34,197,94,.16), rgba(20,184,166,.10));
  border-color: rgba(34,197,94,.25);
}
.key.miss{
  background: linear-gradient(135deg, rgba(239,68,68,.14), rgba(245,158,11,.10));
  border-color: rgba(239,68,68,.22);
}
.key:disabled{ box-shadow:none; }

/* Leaderboard */
.leaderboard{
  background:#fff;
  border:1px solid var(--stroke);
  border-radius:22px;
  padding: 12px;
}
.lb-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:8px;
}
.lb-title{ font-weight:900; }
.lb-list{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.lb-item{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border-radius:18px;
  border:1px solid var(--stroke);
  background: linear-gradient(180deg, #ffffff, #fbfbff);
}
.lb-item strong{ font-weight:900; }
.lb-rank{
  width:26px; height:26px;
  border-radius:10px;
  display:grid; place-items:center;
  background: linear-gradient(135deg, rgba(14,165,233,.14), rgba(20,184,166,.12));
  border:1px solid rgba(14,165,233,.18);
  font-weight:900;
}
.lb-note{
  margin-top:8px;
  color:var(--muted);
  font-size:12px;
}

.footer{
  margin-top:14px;
  display:flex;
  justify-content:space-between;
  gap:10px;
  color:var(--muted);
  font-size:12px;
  padding: 0 6px;
}
.footer strong{ color:var(--text); }

/* Modal */
.modal{
  position:fixed;
  inset:0;
  display:none;
  place-items:center;
  background: rgba(2,6,23,.35);
  z-index:20;
  padding: 18px;
}
.modal.show{ display:grid; }
.modal-card{
  width:min(520px, 95vw);
  background:#fff;
  border-radius:24px;
  box-shadow: var(--shadow);
  border:1px solid rgba(255,255,255,.4);
  padding: 14px;
}
.modal-top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding: 6px 6px 2px;
}
.modal-title{ font-weight:900; }
.x{
  background:#fff;
  border:1px solid var(--stroke);
  border-radius:14px;
  padding:8px 10px;
}
.how{
  margin: 10px 12px 12px;
  color:var(--muted);
  line-height:1.45;
}
.modal-actions{
  display:flex;
  justify-content:flex-end;
  padding: 0 6px 8px;
}

/* Toast */
.toast{
  position:fixed;
  left:50%;
  bottom:18px;
  transform: translateX(-50%);
  background:#fff;
  border:1px solid var(--stroke);
  border-radius:18px;
  box-shadow: var(--shadow2);
  padding: 10px 14px;
  z-index:30;
  opacity:0;
  pointer-events:none;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show{
  opacity:1;
  transform: translateX(-50%) translateY(-6px);
}

/* Responsive */
@media (max-width: 980px){
  .hero{ grid-template-columns: 1fr; }
  .sc-grid{ grid-template-columns: repeat(2,1fr); }
  .form-grid{ grid-template-columns: repeat(2, 1fr); }
  .game-grid{ grid-template-columns: 1fr; }
  .stage-top{ grid-template-columns: 1fr; }
  .row{ grid-template-columns: repeat(10,1fr); }
}
@media (max-width: 520px){
  .wrap{ width: 94vw; }
  .timer{ min-width: 110px; }
  .word{ letter-spacing: .22em; }
  .row{ gap:6px; }
  .key{ padding:10px 0; border-radius:14px; }
}




/* Big teasing popup (wrong guess) */
.tease-pop{
  position:fixed;
  inset:0;
  display:grid;
  place-items:center;
  background: rgba(2,6,23,.30);
  opacity:0;
  pointer-events:none;
  transition: opacity .18s ease;
  z-index:50;
}
.tease-pop.show{
  opacity:1;
}
.tease-inner{
  text-align:center;
  transform: translateY(8px) scale(.92);
  transition: transform .18s ease;
}
.tease-pop.show .tease-inner{
  transform: translateY(0) scale(1);
}
.tease-face{
  font-size: clamp(72px, 10vw, 120px);
  filter: drop-shadow(0 18px 35px rgba(0,0,0,.35));
  animation: teaseShake .55s ease;
}
.tease-text{
  margin-top: 10px;
  font-weight: 900;
  font-size: clamp(22px, 3.4vw, 34px);
  color: #fff;
  text-shadow: 0 10px 22px rgba(0,0,0,.35);
}
@keyframes teaseShake{
  0%,100%{ transform: translateX(0) rotate(0deg); }
  20%{ transform: translateX(-10px) rotate(-2deg); }
  60%{ transform: translateX(10px) rotate(2deg); }
}

/* Hide scorecard before game starts */
.hero-right.hidden{ display:none; }

/* ================= BIG TEASING POPUP ================= */

.tease-pop{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(0,0,0,0.35);
  backdrop-filter: blur(6px);
  opacity:0;
  pointer-events:none;
  transition:opacity .25s ease;
  z-index:9999;
}

.tease-pop.show{
  opacity:1;
}

.tease-inner{
  text-align:center;
  animation:teaseBounce .6s ease;
}

.tease-face{
  font-size:120px;
  line-height:1;
  animation:faceShake .7s ease;
  filter: drop-shadow(0 20px 35px rgba(0,0,0,.35));
}

.tease-text{
  margin-top:12px;
  font-weight:800;
  font-size:28px;
  color:#fff;
  text-shadow:0 6px 18px rgba(0,0,0,.45);
}

/* bounce in */
@keyframes teaseBounce{
  0%{transform:scale(.3) rotate(-10deg); opacity:0;}
  60%{transform:scale(1.15) rotate(4deg);}
  100%{transform:scale(1) rotate(0);}
}

/* face shaking */
@keyframes faceShake{
  0%,100%{transform:translateX(0)}
  20%{transform:translateX(-8px)}
  40%{transform:translateX(8px)}
  60%{transform:translateX(-6px)}
  80%{transform:translateX(6px)}
}

.hidden{display:none!important;}
