:root {
  --bg: #0b0e16;
  --bg2: #121728;
  --panel: #182036;
  --panel2: #202a45;
  --line: #2b3654;
  --text: #eef1fb;
  --muted: #8d97b5;
  --accent: #ffc94d;
  --accent2: #5ee08a;
  --pink: #ff5d73;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(1100px 600px at 15% -10%, #1a2340 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 0%, #2a1633 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
}

.app {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- HUD ---------- */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px;
}

.hud-left { display: flex; align-items: center; gap: 14px; }

.level-badge {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .4px;
  text-transform: uppercase;
  padding: 8px 14px;
  border-radius: 12px;
  background: linear-gradient(180deg, #2a3554, #1b2440);
  border: 1px solid #3a486e;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
  white-space: nowrap;
}

.moves { display: flex; flex-direction: column; align-items: flex-start; line-height: 1; }
.moves-num { font-size: 26px; font-weight: 800; color: var(--accent2); }
.moves-label { font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); margin-top: 3px; }

.hud-right { text-align: right; }
.score-line { font-variant-numeric: tabular-nums; line-height: 1; }
.score-num { font-size: 30px; font-weight: 800; color: #fff; }
.score-target { font-size: 14px; color: var(--muted); }

.stars { margin-top: 5px; font-size: 20px; letter-spacing: 3px; color: #37405d; }
.stars .star.on { color: var(--accent); text-shadow: 0 0 12px rgba(255, 201, 77, .65); }

/* ---------- progress ---------- */
.progress {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: #131a2e;
  border: 1px solid var(--line);
  overflow: hidden;
}
.progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #48d48a, #8be9a0 60%, #ffd76a);
  box-shadow: 0 0 14px rgba(94, 224, 138, .55);
  transition: width .35s ease;
}
.progress-marks { position: absolute; inset: 0; pointer-events: none; }
.progress-marks i {
  position: absolute;
  top: 50%;
  width: 2px; height: 18px;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, .28);
}

/* ---------- board ---------- */
.board-wrap {
  position: relative;
  border-radius: 20px;
  padding: 8px;
  background: linear-gradient(180deg, #1a2238, #121a2d);
  border: 1px solid #2e3a5c;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .05);
}

#board {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  touch-action: none;
  cursor: pointer;
  outline: none;
}

/* ---------- controls ---------- */
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 2px;
}

.icon-btn {
  width: 44px; height: 44px;
  border-radius: 13px;
  border: 1px solid #33415f;
  background: linear-gradient(180deg, #232d49, #18203a);
  color: var(--text);
  font-size: 20px; font-weight: 700;
  cursor: pointer;
  box-shadow: 0 5px 14px rgba(0, 0, 0, .35);
  transition: transform .08s ease, filter .15s ease;
}
.icon-btn:active { transform: translateY(1px) scale(.97); }
.icon-btn.muted { filter: grayscale(1) brightness(.7); }

.status {
  font-size: 13px;
  letter-spacing: .6px;
  color: var(--muted);
  text-transform: uppercase;
  text-align: center;
  flex: 1;
  min-height: 18px;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  transform: translate(-50%, 24px);
  background: rgba(24, 32, 54, .96);
  border: 1px solid #3a486e;
  color: var(--text);
  padding: 10px 18px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  z-index: 30;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 17, .78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 40;
}
.overlay[hidden] { display: none; }

.panel {
  width: min(430px, 100%);
  background: linear-gradient(180deg, #1e2740, #141b2f);
  border: 1px solid #3a486e;
  border-radius: 22px;
  padding: 24px 22px 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
  text-align: center;
  animation: pop .22s ease;
}
@keyframes pop { from { transform: scale(.94); opacity: .4; } to { transform: scale(1); opacity: 1; } }

.panel h2 { margin: 0 0 6px; font-size: 26px; letter-spacing: .3px; }
.panel p { margin: 6px 0; color: #c3cbe4; font-size: 15px; line-height: 1.45; }
.panel .big { font-size: 40px; font-weight: 800; color: var(--accent); margin: 4px 0 2px; }
.panel .stars-big { font-size: 34px; letter-spacing: 8px; color: #37405d; margin: 6px 0 2px; }
.panel .stars-big .star.on { color: var(--accent); text-shadow: 0 0 18px rgba(255, 201, 77, .7); }

.panel .btn {
  display: inline-block;
  margin-top: 14px;
  padding: 13px 26px;
  border-radius: 14px;
  border: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .4px;
  cursor: pointer;
  color: #10182b;
  background: linear-gradient(180deg, #ffe07a, #ffc94d);
  box-shadow: 0 8px 20px rgba(255, 201, 77, .28);
  transition: transform .08s ease, filter .15s ease;
}
.panel .btn:active { transform: translateY(1px) scale(.98); }
.panel .btn.ghost {
  background: linear-gradient(180deg, #2a3554, #1c2541);
  color: var(--text);
  box-shadow: none;
  border: 1px solid #3a486e;
  margin-left: 8px;
}
.panel .hint { font-size: 13px; color: var(--muted); margin-top: 10px; }
.panel ul { text-align: left; margin: 10px 0 0; padding-left: 20px; color: #c3cbe4; font-size: 14px; line-height: 1.6; }
.panel ul b { color: #fff; }
