/* =============================================================
   GAME: Code Breaker
   ============================================================= */
.cb-wrap {
  --peg: min(calc((100vw - 150px) / var(--p, 5) - 6px), 36px);
  --gap: calc(var(--peg) * .2);
  --fb: calc(var(--peg) * .32);
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 12px; border-radius: 20px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 138, 216, .12), transparent 60%),
    linear-gradient(180deg, #2a1d58, #150f33);
  box-shadow: 0 0 0 2px #ff8ad8, 0 0 28px rgba(255, 138, 216, .3), inset 0 2px 0 rgba(255, 255, 255, .08), inset 0 -6px 0 rgba(0, 0, 0, .3), 0 14px 30px rgba(0, 0, 0, .45);
}
.cb-c0 { --pc: #ff4d5e; --pi: #4a0010; }
.cb-c1 { --pc: #ff9f1c; --pi: #3a1e00; }
.cb-c2 { --pc: #ffe14d; --pi: #3a3000; }
.cb-c3 { --pc: #3ddc84; --pi: #00301a; }
.cb-c4 { --pc: #3dd8ff; --pi: #00303a; }
.cb-c5 { --pc: #4d6bff; --pi: #ffffff; }
.cb-c6 { --pc: #b05cff; --pi: #ffffff; }
.cb-c7 { --pc: #f2f0ff; --pi: #2a2350; }

/* secret code */
.cb-secret-wrap { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 14px; background: rgba(0, 0, 0, .3); box-shadow: inset 0 0 0 1px rgba(255, 138, 216, .35); }
.cb-label { font: 700 .72rem var(--font-head); letter-spacing: .08em; text-transform: uppercase; color: #ffb8e8; }
.cb-secret { display: flex; gap: var(--gap); }
.cb-cover {
  width: var(--peg); height: var(--peg); border-radius: 30%; display: grid; place-items: center;
  background: linear-gradient(160deg, #4a3a8a, #241a4a); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .18), inset 0 -3px 0 rgba(0, 0, 0, .3);
}
.cb-cover::after { content: "?"; font: 800 calc(var(--peg) * .55) var(--font-body); color: rgba(255, 184, 232, .7); }
.cb-reveal { animation: cbreveal .5s ease both; }
.cb-reveal:nth-child(2) { animation-delay: .08s; } .cb-reveal:nth-child(3) { animation-delay: .16s; } .cb-reveal:nth-child(4) { animation-delay: .24s; }
.cb-reveal:nth-child(5) { animation-delay: .32s; } .cb-reveal:nth-child(6) { animation-delay: .4s; }
@keyframes cbreveal { from { transform: rotateY(90deg); } }

/* guess rows */
.cb-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.cb-row { display: flex; align-items: center; gap: 10px; padding: 3px 10px 3px 6px; border-radius: 14px; transition: background .2s ease; }
.cb-num { width: 18px; text-align: right; font: 700 .72rem var(--font-head); color: var(--muted); opacity: .7; }
.cb-pegs { display: flex; gap: var(--gap); }
.cb-active { background: rgba(255, 138, 216, .1); box-shadow: inset 0 0 0 1.5px rgba(255, 138, 216, .7); }
.cb-active .cb-num { color: #ff8ad8; opacity: 1; }
.cb-win { background: rgba(61, 220, 132, .12); box-shadow: inset 0 0 0 1.5px #3ddc84, 0 0 16px rgba(61, 220, 132, .35); }

.cb-hole, .cb-peg { width: var(--peg); height: var(--peg); border-radius: 50%; flex: none; display: grid; place-items: center; }
.cb-hole { background: radial-gradient(circle, #07041a 0 26%, rgba(255, 255, 255, .06) 28% 100%); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .5); }
.cb-peg {
  background:
    radial-gradient(circle at 33% 27%, rgba(255, 255, 255, .9) 0 8%, rgba(255, 255, 255, .25) 16%, transparent 30%),
    radial-gradient(circle at 45% 40%, color-mix(in srgb, var(--pc) 85%, #fff), var(--pc) 45%, color-mix(in srgb, var(--pc) 55%, #000));
  box-shadow: 0 3px 4px rgba(0, 0, 0, .45), inset 0 -2px 3px rgba(0, 0, 0, .25);
}
.cb-peg svg { width: 52%; height: 52%; fill: var(--pi); opacity: .8; }
.cb-new .cb-peg { animation: cbdrop .3s cubic-bezier(.3, 1.5, .5, 1) backwards; }
@keyframes cbdrop { from { transform: translateY(-8px) scale(.7); opacity: 0; } }

.cb-slot { padding: 0; margin: 0; border: 0; background: none; border-radius: 50%; cursor: pointer; position: relative; }
.cb-slot.cb-on::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px dashed #ff8ad8; animation: cbspin 5s linear infinite; pointer-events: none; }
@keyframes cbspin { to { transform: rotate(360deg); } }
.cb-slot:focus { outline: none; }
.cb-slot:focus-visible { box-shadow: 0 0 0 3px var(--focus); }
.cb-slot:hover .cb-hole { background: radial-gradient(circle, #07041a 0 26%, rgba(255, 255, 255, .12) 28% 100%); }

/* feedback: exact = solid white dot, colour only = hollow ring (not colour coded) */
.cb-fb { display: grid; grid-template-columns: repeat(3, var(--fb)); gap: 3px; }
.cb-p4 .cb-fb { grid-template-columns: repeat(2, var(--fb)); }
.cb-fbp { width: var(--fb); height: var(--fb); border-radius: 50%; background: rgba(255, 255, 255, .08); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .5); }
.cb-fbp.cb-ex { background: radial-gradient(circle at 35% 30%, #fff, #e6e0ff 50%, #b7aee8); box-shadow: 0 0 6px rgba(255, 255, 255, .7); }
.cb-fbp.cb-near { background: transparent; box-shadow: inset 0 0 0 2px #ffb8e8, 0 0 4px rgba(255, 184, 232, .5); }
.cb-new .cb-fbp { animation: cbfb .3s ease-out calc(.25s + var(--i) * 80ms) backwards; }
@keyframes cbfb { from { transform: scale(0); } 60% { transform: scale(1.4); } }

/* colour pad */
.cb-pad { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 420px; padding-top: 4px; }
.cb-pad[hidden] { display: none; }
.cb-key { --peg: 40px; position: relative; padding: 0; border: 0; background: none; border-radius: 50%; cursor: pointer; transition: transform .12s ease; }
.cb-key small { position: absolute; right: -3px; bottom: -3px; font: 700 .66rem/1 var(--font-body); color: var(--muted); background: var(--surface); border-radius: 6px; padding: 2px 4px; box-shadow: inset 0 0 0 1px var(--line); }
.cb-key:hover:not(:disabled) { transform: translateY(-3px); }
.cb-key:active:not(:disabled) { transform: scale(.92); }
.cb-key:disabled { opacity: .35; cursor: default; }
.cb-acts { display: flex; gap: 8px; width: 100%; justify-content: center; }
.cb-acts .btn { min-width: 110px; }
@media (max-width: 420px) { .cb-secret-wrap { flex-direction: column; gap: 6px; } .cb-key { --peg: 34px; } .cb-pad { gap: 6px; } .cb-row { gap: 7px; padding-right: 7px; } }

.cb-dot { background: radial-gradient(circle at 35% 30%, #fff 0 15%, #ff8ad8 50%, #7a1a5c); }
.cb-note { color: #ffe08a; font-weight: 600; }
.cb-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); margin: 0; }
@media (prefers-reduced-motion: reduce) { .cb-slot.cb-on::after, .cb-new .cb-fbp, .cb-new .cb-peg, .cb-reveal { animation: none; } }
