:root {
  --bg: #0f1117;
  --panel: rgba(31, 35, 46, 0.92);
  --text: #f2f4f8;
  --muted: #9aa3b5;
  --border: #353b4a;
  --accent: #7dd3fc;
  --gold: #f5c84c;
  --green: #4ade80;
  --peg: 34px;
  --pal: 44px;
  --kp: calc(var(--peg) * 0.3);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; color: var(--text); overflow: hidden;
  font: 15px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { background: radial-gradient(ellipse at 50% 0%, #1c2436 0%, var(--bg) 70%) fixed, var(--bg); }
/* backdrop art stays faint and blurred so pegs and text read clearly on top of it */
body::before { content: ""; position: fixed; inset: -24px; z-index: -1; opacity: 0; transition: opacity 0.4s; filter: blur(6px);
  background: linear-gradient(rgba(12, 14, 20, 0.84), rgba(12, 14, 20, 0.93)), url(img/bg.webp) center / cover no-repeat; }
body.has-bg::before { opacity: 1; }

#app { height: 100vh; height: 100dvh; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column;
  padding: 8px 10px 10px; gap: 6px; }

.top { display: flex; align-items: center; gap: 8px; min-height: 34px; }
.title { font-weight: 800; font-size: 19px; letter-spacing: 0.2px; white-space: nowrap; }
.chip { margin-left: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 99px; padding: 4px 11px;
  font-size: 12px; color: #d9dee8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.msg { text-align: center; min-height: 20px; font-size: 14px; color: #dfe4ee; transition: color 0.2s; }
.msg.good { color: var(--green); font-weight: 700; }
.msg.bad { color: #f87171; }
.msg.hint { color: var(--gold); }
.msg.dim { color: var(--muted); }
.legend { display: flex; justify-content: center; gap: 16px; font-size: 12px; color: #c3cad8; flex: none;
  position: relative; z-index: 1; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend .kp { width: 11px; height: 11px; }

/* ---------- board ---------- */
.board { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 4px;
  overflow: hidden; }
.row { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 12px; flex: none;
  background: rgba(22, 26, 35, 0.88); border: 1px solid rgba(255, 255, 255, 0.06); transition: background 0.2s, opacity 0.2s; }
.row.future { opacity: 0.55; }
.row.active { background: #1a2635; border-color: rgba(125, 211, 252, 0.55); }
.row.clue { background: #26231a; border: 1px dashed rgba(245, 200, 76, 0.55); }
.row.secret { background: linear-gradient(180deg, #2a3142, #1a1f2b); border-color: #485066; margin-bottom: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08); }
.row.shake { animation: shake 0.35s; }
.lbl { width: 26px; text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); flex: none; }
.row.active .lbl { color: var(--accent); }
.row.clue .lbl { font-size: 9px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gold); }
.row.secret .lbl { font-size: 15px; }
.slots { display: flex; gap: 6px; }

.peg { --c: #888; width: var(--peg); height: var(--peg); border-radius: 50%; flex: none; position: relative;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: calc(var(--peg) * 0.55);
  background: radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 42%), var(--c);
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.55); user-select: none; }
.peg.empty { background: rgba(0, 0, 0, 0.28); box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.6); border: 1.5px solid rgba(255, 255, 255, 0.06); }
.row.active .peg { cursor: pointer; }
.row.active .peg.empty { border: 2px solid rgba(255, 255, 255, 0.16); }
.row.active .peg.cur.empty { border: 2px solid var(--accent); box-shadow: 0 0 0 3px rgba(125, 211, 252, 0.22), inset 0 2px 5px rgba(0, 0, 0, 0.5); }
.row.active .peg:not(.empty) { animation: pop 0.12s; }
.row.active .peg.cur:not(.empty) { outline: 2px solid var(--accent); outline-offset: 2px; }
.peg.lock { border-radius: 26%; background: linear-gradient(160deg, #4a5368, #2b3140); color: #aab3c6; border: 0;
  font-size: calc(var(--peg) * 0.5); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 3px rgba(0, 0, 0, 0.6); }
.peg.flip { animation: flip 0.45s ease both; }
.peg.hinted { box-shadow: 0 0 0 2px var(--gold), 0 0 12px rgba(245, 200, 76, 0.6); }
.peg.dig { border-radius: 26%; color: var(--c); text-shadow: 0 0 8px color-mix(in srgb, var(--c) 45%, transparent);
  background: linear-gradient(160deg, #303849, #1d222e); border: 1.5px solid color-mix(in srgb, var(--c) 45%, #3a4152);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.55); }
#app.digits .peg.empty { border-radius: 26%; }
.secret.open .peg { box-shadow: 0 0 10px color-mix(in srgb, var(--c) 55%, transparent), inset 0 -3px 6px rgba(0, 0, 0, 0.3); }
.secret.open .peg.dig { box-shadow: 0 0 10px color-mix(in srgb, var(--c) 40%, transparent); }

.s0 { --c: #ef4444; }
.s1 { --c: #fb8a24; }
.s2 { --c: #facc15; }
.s3 { --c: #22c55e; }
.s4 { --c: #22d3ee; }
.s5 { --c: #3b82f6; }
.s6 { --c: #a855f7; }
.s7 { --c: #f472b6; }

/* key pegs: solid = right spot, ring = wrong spot */
.fb { display: grid; gap: 3px; flex: none; }
.fb.ghost { visibility: hidden; }
.kp { display: block; width: var(--kp); height: var(--kp); border-radius: 50%; background: rgba(255, 255, 255, 0.09); }
.kp.b { background: #f4f6fb; box-shadow: 0 0 6px rgba(255, 255, 255, 0.45); }
.kp.w { background: transparent; border: 2px solid #f4f6fb; }
.fb.show .kp { animation: pop-in 0.3s ease both; }
.fb.show .kp:nth-child(2) { animation-delay: 0.08s; }
.fb.show .kp:nth-child(3) { animation-delay: 0.16s; }
.fb.show .kp:nth-child(4) { animation-delay: 0.24s; }
.fb.show .kp:nth-child(5) { animation-delay: 0.32s; }
.fb.show .kp:nth-child(6) { animation-delay: 0.4s; }

/* ---------- input ---------- */
.palette { display: flex; justify-content: center; gap: 6px; user-select: none; }
.pal { width: var(--pal); height: var(--pal); padding: 0; border: 0; border-radius: 12px; background: var(--panel);
  display: flex; align-items: center; justify-content: center; cursor: pointer; touch-action: manipulation;
  box-shadow: inset 0 0 0 1px var(--border); transition: transform 0.08s; }
.pal:active { transform: scale(0.92); }
.pal .peg { --peg: calc(var(--pal) * 0.72); }
.pal.del { color: var(--text); font-size: 20px; }

.bar { display: flex; gap: 8px; }
.bar button { flex: 1; height: 40px; border: 0; border-radius: 10px; background: var(--panel); color: var(--text);
  font: 600 14px system-ui, sans-serif; cursor: pointer; box-shadow: inset 0 0 0 1px var(--border); touch-action: manipulation; }
.bar button.primary { flex: 1.4; background: linear-gradient(180deg, #38bdf8, #0284c7); box-shadow: none; font-weight: 800; color: #04121c; }
.bar button:disabled { opacity: 0.4; cursor: default; }

.end { text-align: center; background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 11px 12px; font-size: 14px; font-weight: 600; color: #e6eaf2; }
#app.won .end { border-color: rgba(74, 222, 128, 0.5); color: var(--green); }

@keyframes pop { 50% { transform: scale(1.1); } }
@keyframes pop-in { 0% { transform: scale(0); opacity: 0; } 70% { transform: scale(1.25); } 100% { transform: scale(1); opacity: 1; } }
@keyframes flip { 0% { transform: rotateY(90deg); } 100% { transform: rotateY(0); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

@media (max-height: 520px) {
  .legend { display: none; }
  .bar button { height: 34px; }
}
