:root{
  --bg: #ffffff;
  --ink: #111;
  --muted: #6b6b6b;

  --tile: #f3f3ea;
  --tileBorder: rgba(0,0,0,.08);
  --tileSel: #b8b8ad;

  --y: #f7df7d;
  --g: #a9c46f;
  --b: #b9c9ee;
  --p: #b88ad6;

  --radius: 18px;
  --shadow: 0 10px 30px rgba(0,0,0,.06);
}

*{ box-sizing: border-box; }
html, body{
  margin:0;
  padding:0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.wrap{
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 14px 40px;
}

h1{
  margin: 18px 0 10px;
  text-align:center;
  font-size: clamp(38px, 7vw, 56px);
  letter-spacing: -0.02em;
  font-weight: 900;
}

.card{
  background: #fff;
  border: 1px solid rgba(0,0,0,.07);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 14px;
  margin: 12px 0;
}

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

.label{
  font-weight: 800;
  font-size: 18px;
}

.muted{
  color: var(--muted);
  font-weight: 650;
}

#stats{
  font-size: 14px;
  line-height: 1.35;
  color: #1a1a1a;
  font-weight: 650;
}

.sliderRow{
  display:flex;
  align-items:center;
  gap: 10px;
}

input[type="range"]{
  width: 100%;
}

#diffHint{
  margin-top: 8px;
  color: var(--muted);
  font-weight: 650;
}

/* solved bars */
#solvedArea{
  display:flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0;
}

.solvedBar{
  border-radius: 18px;
  padding: 14px 14px 12px;
  text-align:center;
  color:#111;
  box-shadow: var(--shadow);
}

.solvedBar .cat{
  font-weight: 950;
  letter-spacing: .04em;
}

.solvedBar .words{
  margin-top: 6px;
  font-weight: 750;
  opacity: .92;
}

/* GRID */
#grid{
  display:grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.tile{
  background: var(--tile);
  border: 1px solid var(--tileBorder);
  border-radius: var(--radius);
  height: 86px;
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  padding: 10px;

  /* FIX OVERFLOW */
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
  hyphens: auto;

  /* Auto feel: smaller font on small screens */
  font-size: clamp(12px, 2.5vw, 18px);
  font-weight: 900;
  letter-spacing: .01em;
  line-height: 1.05;
  user-select:none;
}

.tile.sel{
  background: var(--tileSel);
  transform: translateY(-1px);
}

@media (max-width: 420px){
  .tile{ height: 78px; }
}

/* Mistake dots */
#dots{
  display:flex;
  justify-content:center;
  gap: 10px;
  margin: 10px 0 8px;
}
.dot{
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #d8d8d8;
}
.dot.on{
  background: #6b6b6b;
}

/* Buttons */
.btnRow{
  display:flex;
  gap: 12px;
  justify-content:center;
  margin: 10px 0;
  flex-wrap: wrap;
}

button{
  border: 2px solid #111;
  background: #fff;
  color: #111;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 900;
  min-width: 150px;
}

button:disabled{
  opacity: .4;
}

/* bottom row */
.bottomRow{
  display:flex;
  justify-content: space-between;
  align-items:center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.bottomRow .left{
  font-weight: 750;
  color: var(--muted);
}

.bottomRow .right{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
}

.smallBtn{
  border-width: 1px;
  min-width: unset;
  padding: 10px 14px;
}

.danger{
  border-color: #b31414;
  color: #b31414;
}

/* Hint line */
#hintLine{
  margin-top: 10px;
  text-align:center;
  color: var(--muted);
  font-weight: 750;
}

/* Toast */
#toast{
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: rgba(17,17,17,.92);
  color: #fff;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 800;
  opacity: 0;
  pointer-events:none;
  transition: opacity .15s ease;
  max-width: 92vw;
  text-align:center;
}
#toast.show{ opacity: 1; }
