:root{
  --cream:#fdf9f3;
  --mint:#dcefff;
  --mint-dark:#a9d4f5;
  --pink:#ffd6e8;
  --pink-dark:#f5a8c8;
  --lavender:#e3d9f7;
  --lavender-dark:#c3aef0;
  --peach:#ffe4d6;
  --peach-dark:#f5b896;
  --text:#4a4458;
  --white:#ffffff;
  --green:#7bc99b;
  --green-dark:#4e9c6f;
  --red:#e58a8a;
  --red-dark:#c85c5c;
  --shadow: 0 4px 14px rgba(74,68,88,0.12);
}
*{box-sizing:border-box;}
body{
  margin:0;
  min-height:100vh;
  font-family:'Trebuchet MS','Segoe UI',sans-serif;
  background:linear-gradient(160deg, var(--lavender) 0%, var(--cream) 45%, var(--mint) 100%);
  color:var(--text);
  display:flex;
  justify-content:center;
  padding:24px 12px 60px;
}
.wrap{
  width:100%;
  max-width:760px;
}
.site-header{
  text-align:center;
  margin-bottom:22px;
}
.site-header h1{
  font-size:2rem;
  margin:0 0 4px;
  color:#6b5f9e;
  text-shadow:1px 1px 0 #fff;
}
.site-header .subtitle{
  font-size:0.9rem;
  color:#8a7fa0;
  margin:0;
}
.nav-back{
  display:inline-block;
  margin-bottom:16px;
  font-size:0.8rem;
  color:#6b5f9e;
  text-decoration:none;
  background:var(--white);
  padding:6px 14px;
  border-radius:999px;
  box-shadow:var(--shadow);
}
.nav-back:hover{
  background:var(--lavender);
}
.card-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(200px, 1fr));
  gap:16px;
  margin-bottom:24px;
}
.puzzle-card{
  background:var(--white);
  border-radius:20px;
  box-shadow:var(--shadow);
  padding:20px 16px;
  text-align:center;
  text-decoration:none;
  color:var(--text);
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:6px;
  transition:transform .15s ease, box-shadow .15s ease;
}
.puzzle-card:hover{
  transform:translateY(-4px);
  box-shadow:0 8px 20px rgba(74,68,88,0.18);
}
.puzzle-card .icon{
  font-size:2.6rem;
}
.puzzle-card h2{
  margin:2px 0 0;
  font-size:1.1rem;
  color:#6b5f9e;
}
.puzzle-card p{
  margin:0;
  font-size:0.82rem;
  color:#8a7fa0;
}
.puzzle-card .best{
  margin-top:8px;
  font-size:0.75rem;
  font-weight:bold;
  color:var(--green-dark);
  background:#e6f7ec;
  padding:4px 10px;
  border-radius:999px;
}
.puzzle-card .play-btn{
  margin-top:10px;
  background:var(--lavender-dark);
  color:#3f2f5a;
  font-weight:bold;
  font-size:0.8rem;
  padding:7px 18px;
  border-radius:999px;
}
.panel{
  background:var(--white);
  border-radius:20px;
  box-shadow:var(--shadow);
  padding:20px;
  margin-bottom:18px;
}
.panel h2{
  margin:0 0 10px;
  font-size:1.1rem;
  color:#6b5f9e;
  text-align:center;
}
.stats{
  display:flex;
  justify-content:center;
  gap:14px;
  flex-wrap:wrap;
  margin-bottom:18px;
}
.stat-pill{
  background:var(--white);
  border-radius:999px;
  padding:8px 18px;
  box-shadow:var(--shadow);
  font-weight:bold;
  font-size:0.9rem;
}
.btn{
  border:none;
  border-radius:999px;
  padding:10px 22px;
  font-weight:bold;
  font-size:0.9rem;
  cursor:pointer;
  transition:transform .12s ease;
}
.btn:hover{ transform:translateY(-1px); }
.btn:disabled{ opacity:0.4; cursor:not-allowed; transform:none; }
.btn-primary{ background:var(--pink-dark); color:#5a2f42; }
.btn-secondary{ background:var(--lavender-dark); color:#3f2f5a; }
.btn-mint{ background:var(--mint-dark); color:#204a6b; }
.btn-row{
  display:flex;
  justify-content:center;
  gap:10px;
  flex-wrap:wrap;
  margin-top:14px;
}
.progress-bar-outer{
  width:100%;
  height:10px;
  background:var(--lavender);
  border-radius:999px;
  overflow:hidden;
  margin-bottom:16px;
}
.progress-bar-inner{
  height:100%;
  background:var(--lavender-dark);
  width:0%;
  transition:width .3s ease;
}
.feedback{
  text-align:center;
  font-size:0.9rem;
  font-weight:bold;
  min-height:1.4em;
  margin-top:10px;
}
.feedback.correct{ color:var(--green-dark); }
.feedback.incorrect{ color:var(--red-dark); }
.center-text{ text-align:center; }
.footer-note{
  text-align:center;
  font-size:0.75rem;
  color:#9a8fb0;
  margin-top:8px;
}

/* ---- shared level-select + multi-game additions ---- */
.level-grid{
  display:grid;
  grid-template-columns:repeat(5, 1fr);
  gap:10px;
  margin-bottom:8px;
}
.level-btn{
  background:var(--white);
  border:2px solid var(--lavender);
  border-radius:14px;
  padding:12px 4px;
  cursor:pointer;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:4px;
  box-shadow:var(--shadow);
  color:var(--text);
}
.level-btn:hover{ border-color:var(--lavender-dark); transform:translateY(-2px); }
.level-num{ font-size:1.1rem; font-weight:bold; }
.level-stars{ font-size:0.65rem; letter-spacing:1px; }
.game-header-row{
  display:flex;
  justify-content:center;
  align-items:center;
  gap:10px;
  margin-bottom:14px;
  flex-wrap:wrap;
}
.level-badge{
  background:var(--white);
  border-radius:999px;
  padding:6px 16px;
  font-weight:bold;
  font-size:0.85rem;
  box-shadow:var(--shadow);
}
.stars-badge{
  margin-top:8px;
  font-size:0.75rem;
  font-weight:bold;
  color:var(--green-dark);
  background:#e6f7ec;
  padding:4px 10px;
  border-radius:999px;
}
.number-pad{
  display:flex;
  justify-content:center;
  gap:8px;
  flex-wrap:wrap;
  margin:14px 0;
}
.pad-btn{
  width:44px;
  height:44px;
  border-radius:10px;
  border:none;
  background:var(--lavender);
  font-size:1.1rem;
  font-weight:bold;
  cursor:pointer;
  color:var(--text);
}
.pad-btn:hover{ background:var(--lavender-dark); }
.pad-btn.erase{ background:var(--peach); font-size:0.9rem; }
.sudoku-grid{
  display:grid;
  gap:2px;
  background:var(--lavender-dark);
  border:3px solid var(--lavender-dark);
  border-radius:10px;
  margin:0 auto 8px;
  width:fit-content;
  overflow:hidden;
}
.sudoku-cell{
  width:44px;
  height:44px;
  background:var(--white);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:1.2rem;
  font-weight:bold;
  cursor:pointer;
  color:var(--text);
}
.sudoku-cell.given{ background:#f2eefc; color:#6b5f9e; cursor:default; }
.sudoku-cell.selected{ background:var(--pink); }
.sudoku-cell.wrong{ background:#fbe9e9; color:var(--red-dark); }
.maze-wrap{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:14px;
}
.maze-grid{
  display:grid;
  gap:0;
  border:3px solid var(--text);
}
.maze-cell{
  width:26px;
  height:26px;
  background:var(--white);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:0.9rem;
  box-sizing:border-box;
}
.maze-cell.wall-top{ border-top:3px solid var(--text); }
.maze-cell.wall-right{ border-right:3px solid var(--text); }
.maze-cell.wall-bottom{ border-bottom:3px solid var(--text); }
.maze-cell.wall-left{ border-left:3px solid var(--text); }
.maze-cell.player{ background:var(--pink-dark); }
.maze-cell.exit{ background:#e6f7ec; }
.dpad{
  display:grid;
  grid-template-columns:repeat(3, 44px);
  grid-template-rows:repeat(3, 44px);
  gap:4px;
}
.dpad button{
  border:none;
  border-radius:8px;
  background:var(--lavender);
  font-size:1.1rem;
  cursor:pointer;
}
.dpad button:hover{ background:var(--lavender-dark); }
.spot-grid{
  display:grid;
  gap:8px;
  margin:0 auto 8px;
  width:fit-content;
}
.spot-tile{
  width:44px;
  height:44px;
  border-radius:10px;
  background:var(--mint);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:1.4rem;
  cursor:pointer;
  box-shadow:var(--shadow);
}
.ws-grid{
  display:grid;
  gap:1px;
  margin:0 auto 14px;
  width:fit-content;
  background:var(--lavender);
  border:2px solid var(--lavender-dark);
}
.ws-cell{
  width:26px;
  height:26px;
  background:var(--white);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:0.85rem;
  font-weight:bold;
  cursor:pointer;
  user-select:none;
  color:var(--text);
}
.ws-cell.selecting{ background:var(--pink); }
.ws-cell.found{ background:#e6f7ec; color:var(--green-dark); }
.ws-word-list{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  justify-content:center;
  margin-bottom:10px;
}
.ws-word{
  font-size:0.75rem;
  background:var(--lavender);
  padding:4px 10px;
  border-radius:999px;
}
.ws-word.found{
  background:#e6f7ec;
  color:var(--green-dark);
  text-decoration:line-through;
}
.pattern-pad{
  display:grid;
  grid-template-columns:repeat(2, 90px);
  grid-template-rows:repeat(2, 90px);
  gap:10px;
  margin:14px auto;
  width:fit-content;
}
.pattern-btn{
  border-radius:16px;
  border:none;
  cursor:pointer;
  opacity:0.55;
  transition: opacity .1s ease, transform .1s ease;
}
.pattern-btn.lit{ opacity:1; transform:scale(0.96); }
.pattern-btn.p0{ background:var(--pink-dark); }
.pattern-btn.p1{ background:var(--mint-dark); }
.pattern-btn.p2{ background:var(--lavender-dark); }
.pattern-btn.p3{ background:var(--peach-dark); }
.math-question{
  text-align:center;
  font-size:1.8rem;
  font-weight:bold;
  margin:10px 0 16px;
  color:var(--text);
}
#mathInput{
  display:block;
  margin:0 auto 14px;
  width:100%;
  max-width:180px;
  padding:10px 14px;
  border-radius:999px;
  border:2px solid var(--lavender-dark);
  font-size:1.1rem;
  text-align:center;
}
#mathInput:focus{ outline:none; border-color:var(--pink-dark); }
.sudoku-cell.box-border-right{ border-right:3px solid var(--lavender-dark); }
.sudoku-cell.box-border-bottom{ border-bottom:3px solid var(--lavender-dark); }
