:root{
  --bg:#eaf4ff;
  --bg-soft:#f4f9ff;
  --card:#ffffff;
  --card-tint:#f7fbff;
  --ink:#16324f;
  --muted:#5f7996;
  --line:#cfe0f2;
  --line-strong:#b7d0ea;
  --accent:#5aa9e6;
  --accent-deep:#3f8fd1;
  --accent-soft:#dff0ff;
  --radius:18px;
  --shadow:0 12px 30px rgba(63,143,209,0.10);
}

*{box-sizing:border-box}

body{
  margin:0;
  background:
    radial-gradient(circle at top, #f7fbff 0%, #eef6ff 34%, var(--bg) 100%);
  color:var(--ink);
  font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto;
}

/* HEADER */

.siteHeader{
  position:sticky;
  top:0;
  z-index:2000;

  background:rgba(255,255,255,0.88);
  backdrop-filter:blur(10px);
  border-bottom:1px solid var(--line);

  padding:14px 16px 10px;
}


.siteHeaderInner{
  max-width:820px;
  margin:0 auto;
  text-align:center;
  position:relative;
}

#mobileStatsBtn{
  display:none;
}

#helpBtn{
  display:none;
  align-items:center;
  justify-content:center;

  position:absolute;
  top:50%;
  transform:translateY(-50%);

  width:42px;
  height:42px;

  padding:0;
  border-radius:999px;
  border:1px solid var(--line);

  background:#ffffff;
  color:var(--accent-deep);

  box-shadow:0 4px 12px rgba(63,143,209,0.10);
}

#helpBtn svg{
  width:20px;
  height:20px;
  fill:currentColor;
}

#helpBtn:hover{
  background:var(--bg-soft);
  border-color:var(--line-strong);
}

#helpMenu{
  position:absolute;

  top:58px;
  right:-290px;

  width:230px;

  display:none;
  flex-direction:column;
  gap:6px;

  padding:10px;

  background:#ffffff;
  border:1px solid var(--line);
  border-radius:18px;

  box-shadow:0 18px 40px rgba(63,143,209,0.16);

  z-index:3000;
}

#helpMenu.open{
  display:flex;
}

.helpMenuItem{
  width:100%;

  text-align:left;

  padding:12px 14px;

  background:#ffffff;
  border:none;
  border-radius:12px;

  color:var(--ink);

  font-size:15px;
}

.helpMenuItem:hover{
  background:var(--bg-soft);
}

#helpPanel{
  position:absolute;
  top:58px;
  right:-290px;
  width:300px;
  display:none;
  padding:18px;
  background:#ffffff;
  border:1px solid var(--line);
  border-radius:18px;
  box-shadow:0 18px 40px rgba(63,143,209,0.16);
  z-index:3000;
  text-align:left;
}

#helpPanel.open{
  display:block;
}

#helpPanelClose{
  position:absolute;
  top:10px;
  right:12px;
  background:none;
  border:none;
  color:var(--accent-deep);
  font-size:24px;
  line-height:1;
  padding:0;
}

#helpPanel h3{
  margin:0 24px 10px 0;
  color:var(--accent-deep);
  font-size:17px;
}

#helpPanelText{
  color:var(--muted);
  font-size:14px;
  line-height:1.45;
}

#helpPanelText p{
  margin:0 0 10px;
}

#resetPuzzleBtn{
  position:absolute;
  top:20px;
  left:140px;

  z-index:50;

  width:auto;
  margin:0;

  display:none;
}

/* Desktop */
@media (min-width:769px){

  #helpBtn{ 
    right:-250px;
  }

}

/* Mobile */

@media (max-width:760px){

  #tutorialBox{
    transform:none;
  }

}
@media (max-width:768px){

  #helpBtn{
    left:6px;
    z-index:5000;
  }

  #helpMenu{
    left:10px;
    right:auto;
    top:58px;
    z-index:5001;
  }

  #helpPanel{
    left:10px;
    right:auto;
    width:min(320px, calc(100vw - 20px));
    top:58px;
    z-index:5001;
  }

}

@media (max-width:768px){

  #mobileStatsBtn{
    display:flex;
    align-items:center;
    justify-content:center;

    position:absolute;
    right:6px;
    top:50%;
    transform:translateY(-50%);

    width:42px;
    height:42px;

    padding:0;
    border-radius:999px;
    border:1px solid var(--line);

    background:#ffffff;
    color:var(--accent-deep);

    box-shadow:0 4px 12px rgba(63,143,209,0.10);
  }

  #mobileStatsBtn svg{
    width:20px;
    height:20px;
    fill:currentColor;
  }

  #mobileStatsBtn:hover{
    background:var(--bg-soft);
    border-color:var(--line-strong);
  }

}

.masthead{
  font-size:28px;
  font-weight:800;
  letter-spacing:.2px;
  color:var(--accent-deep);
}

.tagline{
  font-size:14px;
  color:var(--muted);
  margin-top:2px;
}

.headerMeta{
  font-size:12px;
  color:#7f9ab7;
  margin-top:2px;
  letter-spacing:.08em;
  text-transform:uppercase;
}

/* WRAP */

.wrap{
  max-width:820px;
  margin:0 auto;
  padding:30px 16px 120px;
}

#entryBar{
  display:none;
}

/* GAME CARD */

.game-card{
  position:relative;

  background:linear-gradient(180deg, var(--card) 0%, var(--card-tint) 100%);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  border:1px solid var(--line);
  padding:20px;
}

/* TOP BAR */

#topBar{
  display:flex;
  justify-content:flex-end;
  align-items:center;
  margin-bottom:10px;
}

#statusMessage{
  max-width:820px;
  margin:0 auto 8px;

  font-size:14px;
  text-align:left;

  min-height:20px;
}

#timer{
  font-weight:700;
  color:var(--accent-deep);
}

#timer.completePulse{
  animation: timerCompletePulse 520ms ease-out both;
}

@keyframes timerCompletePulse{
  0%{
    transform:scale(1);
    text-shadow:none;
  }

  45%{
    transform:scale(1.28);
    text-shadow:0 0 18px rgba(63,143,209,0.45);
  }

  100%{
    transform:scale(1);
    text-shadow:none;
  }
}

/* CANVAS */

.canvasShell{
  display:flex;
  justify-content:center;
  overflow:visible;
}

#stage{
  width:100%;
  max-width:100%;
  height:auto;
  display:block;
  background:transparent;
}

/* ENTRY BAR */

#entryBar{
  position:fixed;
  bottom:0;
  left:0;
  right:0;

  background:rgba(255,255,255,0.96);
  backdrop-filter:blur(10px);
  border-top:1px solid var(--line);

  padding:14px 18px calc(14px + env(safe-area-inset-bottom));
  z-index:1500;
}

#entryBar .entryControls,
#entryBar #entryLabel{
  max-width:820px;
  margin:0 auto;
}

#entryLabel{
  font-size:13px;
  font-weight:700;
  color:var(--muted);
}

.entryControls{
  display:flex;
  gap:8px;
  margin-top:6px;
}

#wordInput{
  flex:1;
  padding:10px 12px;
  border-radius:999px;
  border:1px solid var(--line);
  background:#ffffff;
  color:var(--ink);
  font:inherit;
}

#wordInput:focus{
  outline:none;
  border-color:var(--accent);
  box-shadow:0 0 0 4px rgba(90,169,230,0.16);
}

button{
  font:inherit;
  cursor:pointer;
  transition:background .18s ease,border-color .18s ease,color .18s ease,transform .12s ease,box-shadow .18s ease;
}

button:hover{
  transform:translateY(-1px);
}

.primary{
  background:linear-gradient(180deg, var(--accent) 0%, var(--accent-deep) 100%);
  color:#fff;
  border:none;
  padding:10px 18px;
  border-radius:999px;
  box-shadow:0 8px 18px rgba(63,143,209,0.18);
}

.primary:hover{
  box-shadow:0 10px 22px rgba(63,143,209,0.22);
}

.secondary{
  background:#ffffff;
  color:var(--ink);
  border:1px solid var(--line);
  padding:10px 18px;
  border-radius:999px;
}

.secondary:hover{
  background:var(--bg-soft);
  border-color:var(--line-strong);
}

/* HINT */

.hint{
  text-align:center;
  font-size:13px;
  color:var(--muted);
  margin-top:12px;
  display:none;
}

/* SIDE PANELS */

.sidePanel{
  position:fixed;
  top:160px;
  width:200px;
  background:linear-gradient(180deg, #ffffff 0%, var(--card-tint) 100%);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:14px;
}

.leftPanel{
  left:20px;
}

.rightPanel{
  right:20px;
}

.sidePanel h3{
  margin:0 0 10px;
  font-size:16px;
  color:var(--accent-deep);
}

.stat{
  display:flex;
  justify-content:space-between;
  margin-bottom:6px;
  font-size:14px;
}

.label{
  color:var(--muted);
}

.value{
  font-weight:700;
  color:var(--ink);
}

/* START OVERLAY */

#startOverlay{
  position:fixed;
  top:120px;
  left:0;
  right:0;
  bottom:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background:transparent;
  z-index:900;
  pointer-events:auto;
}

#startBox{
  width:min(420px, calc(100% - 32px));
  background:rgba(255,255,255,0.97);
  border:1px solid var(--line);
  border-radius:24px;
  box-shadow:0 20px 55px rgba(63,143,209,0.14);
  text-align:center;
  padding:32px 28px 26px;
}

#startBox h2{
  margin:0 0 10px;
  font-size:40px;
  line-height:1;
  font-weight:800;
  color:var(--accent-deep);
}

#startBox p{
  margin:0;
  font-size:19px;
  line-height:1.4;
  color:var(--muted);
}

.startButtons{
  margin-top:22px;
  display:flex;
  justify-content:center;
  gap:12px;
  flex-wrap:wrap;
}

.startButtons .primary,
.startButtons .secondary{
  min-width:120px;
}

/* COMPLETE OVERLAY */


#completeClose{
  position:absolute;
  top:12px;
  right:14px;

  padding:0;
  margin:0;

  background:none;
  border:none;
  box-shadow:none;

  color:var(--accent-deep);

  font-size:34px;
  line-height:1;
  font-weight:300;

  cursor:pointer;
}

#completeClose:hover{
  transform:translateY(-1px);
}

#completeBadge{
  width:56px;
  height:56px;
  margin:0 auto 14px;

  display:flex;
  align-items:center;
  justify-content:center;

  border-radius:50%;
  background:linear-gradient(180deg, var(--accent-soft), #ffffff);
  border:1px solid var(--line);
  color:var(--accent-deep);

  font-size:30px;
  font-weight:900;
  box-shadow:0 8px 20px rgba(63,143,209,0.12);
}

#completeBox h2{
  margin:0;
  font-size:26px;
  line-height:1.1;
  color:var(--ink);
}

#completeSubtitle{
  margin:8px 0 18px;
  color:var(--muted);
  font-size:15px;
}

#completeTime{
  margin:0 0 22px;
  font-size:36px;
  line-height:1;
  font-weight:900;
  letter-spacing:-2px;
  color:var(--accent-deep);
}

#completeTime.copiedMessage{
  font-size:20px;
  line-height:1.4;
  letter-spacing:0;
  font-weight:700;
  color:var(--muted);
}

#shareResults{
  background:linear-gradient(
    180deg,
    var(--accent) 0%,
    var(--accent-deep) 100%
  );

  color:white;
  border:none;

  box-shadow:0 10px 24px rgba(63,143,209,0.22);
}

#shareResults:hover{
  transform:translateY(-1px);
  box-shadow:0 14px 28px rgba(63,143,209,0.28);
}

#shareResults{
  width:100%;
  margin:0;
}

#completeOverlay.show{
  animation: completeFadeIn 220ms ease-out both;
}

#completeOverlay.show #completeBox{
  animation: completePopIn 260ms ease-out both;
}

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

@keyframes completePopIn{
  from{
    opacity:0;
    transform:translateY(12px) scale(0.96);
  }
  to{
    opacity:1;
    transform:translateY(0) scale(1);
  }
}

#completeOverlay{
  position:fixed;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  background:rgba(36,83,130,0.28);
}

#completeBox{
  position:relative;

  width:min(340px, calc(100% - 32px));
  max-width:320px;

  padding:26px 24px 22px;
  border-radius:28px;

  background:linear-gradient(180deg, #ffffff 0%, var(--card-tint) 100%);
  text-align:center;
  border:1px solid var(--line);
  box-shadow:0 18px 45px rgba(63,143,209,0.16);
}

/* TUTORIAL */

#tutorialOverlay{
  position:fixed;
  inset:0;
  display:none;

  align-items:flex-start;
  justify-content:center;

  padding-top:110px;

  background:rgba(36,83,130,0.12);
  z-index:1000;
}

#tutorialBox{
  width:min(460px, calc(100% - 32px));
  background:linear-gradient(180deg, #ffffff 0%, var(--card-tint) 100%);
  border:1px solid var(--line);
  border-radius:24px;
  box-shadow:0 24px 70px rgba(63,143,209,0.16);
  padding:28px 28px 22px;
  transform:translateX(-480px);
}

#tutorialContent h3{
  margin:0 0 12px;
  font-size:18px;
  line-height:1.2;
  font-weight:800;
  color:var(--accent-deep);
}

#tutorialContent p{
  margin:0;
  font-size:16px;
  line-height:1.45;
  color:var(--muted);
}

#tutorialDots{
  margin:18px 0 20px;
  display:flex;
  justify-content:center;
  gap:8px;
}

.dot{
  width:9px;
  height:9px;
  border-radius:50%;
  background:#c8daee;
}

.dot.active{
  background:var(--accent-deep);
}

.tutorialButtons{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.tutorialNavButtons{
  display:flex;
  gap:10px;
}

#tutorialExit,
#tutorialBack{
  background:#ffffff;
  border:1px solid var(--line);
  color:var(--ink);
  padding:10px 16px;
  border-radius:999px;
  font:inherit;
  cursor:pointer;
}

#tutorialExit:hover,
#tutorialBack:hover{
  background:var(--bg-soft);
  border-color:var(--line-strong);
}

#tutorialNext{
  min-width:96px;
}

@media (max-width:760px){
  #tutorialOverlay{
    padding-top:90px;
    align-items:flex-start;
  }

  #tutorialBox{
    padding:22px 20px 18px;
    transform:none;
  }

  .tutorialButtons{
    flex-direction:column;
    align-items:stretch;
  }

  .tutorialNavButtons{
    width:100%;
  }

  .tutorialNavButtons button{
    flex:1;
  }

  #tutorialExit{
    width:100%;
  }
}

#tutorialDots{
  margin-top:10px;
  display:flex;
  justify-content:center;
  gap:6px;
}

.dot{
  width:8px;
  height:8px;
  border-radius:50%;
  background:#c8daee;
}

.dot.active{
  background:var(--accent-deep);
}

#shareSavedResult{
  position:absolute;
  top:20px;
  left:20px;
  z-index:50;
  width:auto;
  margin:0;
  display:none;
}



/* MOBILE STATS PANEL */

#mobileStatsOverlay{
  position:fixed;
  inset:0;
  display:none;
  align-items:flex-end;
  justify-content:center;
  background:rgba(36,83,130,0.28);
  z-index:1000;
}

#mobileStatsOverlay.open{
  display:flex;
}

#mobileStatsSheet{
  width:100%;
  max-width:520px;
  background:linear-gradient(180deg, #ffffff 0%, var(--card-tint) 100%);
  border-radius:20px 20px 0 0;
  padding:20px;
  border-top:1px solid var(--line);
  box-shadow:0 -10px 30px rgba(63,143,209,0.12);
}

.mobileStatsHeader{
  display:flex;
  justify-content:space-between;
  margin-bottom:10px;
}

.mobileStatsSection{
  margin-top:10px;
}

.mobileStatsHeader h3,
.mobileStatsSection h3{
  color:var(--accent-deep);
}

/* MOBILE */

@media (max-width:760px){

  #startOverlay{
  top:290px;
  bottom:auto;
  align-items:flex-start;
  padding-top:110px;
}

#tutorialOverlay{
  top:0;
  bottom:0;
  align-items:flex-start;
  justify-content:center;
  padding-top:420px;
}

#startBox{
  width:min(92vw, 420px);
  padding:28px 22px 24px;
}

  .sidePanel{
    display:none;
  }

  .wrap{
    padding:16px 10px 24px;
  }

  #submitWordBtn{
  display:none;
}

  .game-card{
  padding:10px;
  display:flex;
  flex-direction:column;
}

  #entryBar{
    position:static;
    order:-1;
    display:none;
    margin-bottom:12px;
    padding:0;
    background:transparent;
    backdrop-filter:none;
    border-top:none;
    z-index:auto;
  }

  #statusMessage{
    margin:0 0 8px;
  }

  .entryControls{
    flex-direction:column;
    gap:8px;
    margin-top:0;
  }

  .primary{
    width:100%;
  }

  .hint{
    margin-top:8px;
    font-size:12px;
  }

}

#entryStatus{
  max-width:820px;
  margin:0 auto 8px;
  font-size:14px;
  min-height:20px;
  color:var(--muted);
}

#entryMessage{
  max-width:820px;
  margin:0 auto 6px;

  font-size:14px;
  text-align:left;

  min-height:20px;

  color:#b74a4a;
}
