:root {
  --bg: #0c0714;
  --panel: #1c1129;
  --panel-edge: #3b2656;
  --text: #ece3f7;
  --muted: #a594bd;
  --brew: #9dff6a;
  --brew-deep: #3f9e2e;
  --pumpkin: #ff8a2a;
  --title-font: 'Creepster', 'Grenze', fantasy;
  --body-font: 'Grenze', Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--body-font);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
}

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px 4px;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.hud h1 {
  font-family: var(--title-font);
  font-weight: 400;
  font-size: clamp(26px, 7vw, 36px);
  letter-spacing: 1px;
  margin: 0;
  color: #fff;
  text-shadow: 0 0 14px rgba(255, 255, 255, 0.3), 0 2px 0 #000;
}

.byline {
  margin: 2px 0 0;
  font-size: 14px;
  letter-spacing: 1px;
  color: var(--muted);
}

.scores { display: flex; gap: 14px; }

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1;
}

.stat .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
}

.stat span:last-child {
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
}

#board { position: relative; }

.board-btns {
  position: absolute;
  top: 6px;
  left: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#game {
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 4, 14, 0.55);
  backdrop-filter: blur(2px);
}

.hidden { display: none !important; }

.card {
  max-width: 340px;
  text-align: center;
  background: var(--panel);
  border: 2px solid var(--panel-edge);
  border-radius: 18px;
  padding: 22px 22px 18px;
  box-shadow: 0 0 40px rgba(157, 255, 106, 0.12), 0 12px 40px rgba(0, 0, 0, 0.6);
}

.card h2 {
  font-family: var(--title-font);
  font-weight: 400;
  font-size: 40px;
  margin: 0 0 10px;
  color: var(--brew);
  text-shadow: 0 0 14px rgba(157, 255, 106, 0.5);
}

.card p { margin: 0 0 10px; font-size: 18px; line-height: 1.3; }
.card .hint { color: var(--muted); font-size: 16px; }
.card .keys { color: var(--muted); font-size: 14px; margin: 12px 0 0; }
.card .final { font-size: 26px; }
.card .final span { color: var(--pumpkin); font-weight: 600; }
.new-best { color: var(--brew); font-size: 20px; }

button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.big-btn {
  margin-top: 6px;
  font-family: var(--title-font);
  font-size: 26px;
  letter-spacing: 1px;
  padding: 10px 26px;
  border-radius: 999px;
  border: 2px solid #1a3d12;
  background: linear-gradient(#b6ff8a, var(--brew-deep));
  color: #10240b;
  box-shadow: 0 0 18px rgba(157, 255, 106, 0.45);
}

.big-btn:active { transform: translateY(2px); }

.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--panel-edge);
  background: rgba(28, 17, 41, 0.75);
}

#grimoire {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 4px 16px 10px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

#grimoire img {
  width: clamp(22px, 7vw, 32px);
  height: clamp(22px, 7vw, 32px);
  display: block;
}

#grimoire img.locked {
  filter: brightness(0) drop-shadow(0 0 2px rgba(181, 120, 255, 0.6));
  opacity: 0.6;
}
