/* ================= Sudoku — Lightshow theme ================= */
@property --ang { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

:root {
  --bg: #07040f;
  --text: #f4ecff;
  --muted: #9d8fc0;
  --pink: #ff2bd6;
  --cyan: #22e4ff;
  --violet: #8b5cff;
  --lime: #b6ff3b;
  --amber: #ffc23d;
  --red: #ff4d6d;
  --glass: rgba(20, 12, 44, .62);
  --glass-line: rgba(180, 150, 255, .18);
  --cell-line: rgba(150, 120, 255, .16);
  --box-line: rgba(34, 228, 255, .55);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Outfit', system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ================= Light rig ================= */
.stage { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; animation: hue 24s linear infinite; }
@keyframes hue { to { filter: hue-rotate(360deg); } }

.beam {
  position: absolute; top: -12vh; left: var(--x); width: 34vmax; height: 135vh;
  margin-left: -17vmax; transform-origin: 50% 0;
  background: linear-gradient(to bottom, var(--c) 0%, color-mix(in srgb, var(--c) 35%, transparent) 40%, transparent 85%);
  clip-path: polygon(48% 0, 52% 0, 100% 100%, 0 100%);
  filter: blur(18px); opacity: .32; mix-blend-mode: screen;
  animation: sweep var(--t) ease-in-out infinite alternate;
}
@keyframes sweep { from { transform: rotate(var(--a1)); } to { transform: rotate(var(--a2)); } }

.haze {
  position: absolute; inset: -20%;
  background:
    radial-gradient(40% 30% at 20% 80%, rgba(255, 43, 214, .18), transparent 70%),
    radial-gradient(45% 35% at 80% 70%, rgba(34, 228, 255, .16), transparent 70%),
    radial-gradient(50% 40% at 50% 10%, rgba(139, 92, 255, .22), transparent 70%);
  animation: drift 18s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translate(4%, -3%) scale(1.08); } }

.floor {
  position: absolute; left: -50%; right: -50%; bottom: -10vh; height: 45vh;
  background:
    linear-gradient(to top, rgba(139, 92, 255, .35), transparent 70%),
    repeating-linear-gradient(90deg, rgba(34, 228, 255, .35) 0 2px, transparent 2px 70px),
    repeating-linear-gradient(0deg, rgba(255, 43, 214, .35) 0 2px, transparent 2px 70px);
  transform: perspective(300px) rotateX(62deg);
  transform-origin: 50% 100%;
  mask-image: linear-gradient(to top, #000 10%, transparent 85%);
  -webkit-mask-image: linear-gradient(to top, #000 10%, transparent 85%);
  animation: floorRun 2.4s linear infinite;
}
@keyframes floorRun { to { background-position: 0 0, 0 0, 0 70px; } }

.strobe { position: absolute; inset: 0; background: #fff; opacity: 0; mix-blend-mode: overlay; }

/* Reactions to the game */
body.pulse .beam { opacity: .6; transition: opacity .1s; }
body.pulse .strobe { animation: strobeOnce .6s ease-out; }
@keyframes strobeOnce { 0% { opacity: .25; } 100% { opacity: 0; } }
body.party .beam { animation-duration: calc(var(--t) / 5); opacity: .55; }
body.party .strobe { animation: strobe .24s steps(2) infinite; }
body.party .floor { animation-duration: .6s; }
@keyframes strobe { 0% { opacity: .18; } 100% { opacity: 0; } }

/* ================= Layout ================= */
.app { position: relative; z-index: 1; max-width: 520px; margin: 0 auto; padding: 14px 16px 40px; }

.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-bottom: 18px; }
.back {
  justify-self: start; color: var(--muted); text-decoration: none; font-weight: 700; font-size: 14px;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--glass-line); background: var(--glass);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: color .2s, box-shadow .2s;
}
.back:hover { color: var(--cyan); box-shadow: 0 0 14px rgba(34, 228, 255, .4); }
.live {
  justify-self: end; display: inline-flex; align-items: center; gap: 6px;
  font-family: 'Orbitron', sans-serif; font-weight: 700; font-size: 11px; letter-spacing: 2px; color: var(--red);
}
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 10px var(--red); animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }

.sign { text-align: center; line-height: 1; margin: 0; font-weight: 400; }
.sign-main {
  display: block; font-family: 'Monoton', cursive; font-size: clamp(34px, 10vw, 52px); font-weight: 400;
  color: #ffe9fb;
  text-shadow: 0 0 4px #fff, 0 0 12px var(--pink), 0 0 28px var(--pink), 0 0 50px var(--violet);
  animation: flicker 6s infinite;
}
.sign-sub {
  display: block; margin-top: 6px; font-family: 'Orbitron', sans-serif; font-weight: 700; font-size: 11px;
  color: var(--cyan); text-shadow: 0 0 8px var(--cyan); letter-spacing: 4px; text-transform: uppercase;
}
@keyframes flicker {
  0%, 18%, 22%, 25%, 53%, 57%, 100% { opacity: 1; }
  20%, 24%, 55% { opacity: .45; text-shadow: none; }
}

/* ================= Controls ================= */
.sd-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }

.seg {
  position: relative; display: flex; padding: 4px; border-radius: 14px;
  background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.seg button {
  position: relative; z-index: 1; border: 0; background: none; cursor: pointer;
  padding: 8px 14px; border-radius: 10px; font-weight: 800; font-size: 14px; color: var(--muted); transition: color .3s, text-shadow .3s;
}
.seg button.active { color: #fff; text-shadow: 0 0 8px rgba(255, 255, 255, .8); }
.seg-indicator {
  position: absolute; top: 4px; bottom: 4px; left: 0; width: 0; border-radius: 10px;
  background: linear-gradient(135deg, var(--pink), var(--violet));
  box-shadow: 0 0 16px rgba(255, 43, 214, .6), 0 0 30px rgba(139, 92, 255, .45);
  transition: transform .45s cubic-bezier(.5, 1.6, .4, 1), width .45s cubic-bezier(.5, 1.6, .4, 1);
}

.btn {
  border: 0; cursor: pointer; padding: 10px 20px; border-radius: 12px;
  font-family: 'Orbitron', sans-serif; font-weight: 700; font-size: 14px; letter-spacing: 1px; color: #07040f;
  background: linear-gradient(135deg, var(--cyan), var(--lime));
  box-shadow: 0 0 18px rgba(34, 228, 255, .55), inset 0 -3px 0 rgba(0, 0, 0, .2);
  transition: transform .1s, box-shadow .2s;
}
.btn:hover { box-shadow: 0 0 28px rgba(34, 228, 255, .85), inset 0 -3px 0 rgba(0, 0, 0, .2); }
.btn:active { transform: scale(.96); }
.btn.ghost { background: transparent; color: var(--cyan); box-shadow: inset 0 0 0 1.5px var(--cyan), 0 0 14px rgba(34, 228, 255, .35); }

.sd-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat {
  text-align: center; padding: 7px 4px; border-radius: 12px;
  background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.stat small { display: block; font-size: 10px; font-weight: 800; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }
.stat b {
  display: block; margin-top: 2px; font-family: 'Orbitron', sans-serif; font-weight: 700; font-size: 16px;
  font-variant-numeric: tabular-nums; color: var(--text); text-shadow: 0 0 10px rgba(139, 92, 255, .9);
}
#sd-mistakes { color: #ffd0da; text-shadow: 0 0 10px var(--red); }
#sd-level { color: #e7fffb; text-shadow: 0 0 10px var(--cyan); }

/* ================= Board ================= */
.sd-wrap {
  position: relative; padding: 3px; border-radius: 20px;
  background: conic-gradient(from var(--ang), var(--pink), var(--cyan), var(--violet), var(--lime), var(--amber), var(--pink));
  animation: spinBorder 5s linear infinite;
  box-shadow: 0 0 30px rgba(139, 92, 255, .45), 0 0 80px rgba(255, 43, 214, .18);
}
@keyframes spinBorder { to { --ang: 360deg; } }

.sd-board {
  display: grid; grid-template-columns: repeat(9, 1fr); grid-template-rows: repeat(9, 1fr);
  aspect-ratio: 1; border-radius: 17px; overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(139, 92, 255, .2), transparent 60%),
    rgba(9, 5, 22, .94);
  container-type: inline-size; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.sd-cell {
  position: relative; display: flex; align-items: center; justify-content: center;
  border-right: 1px solid var(--cell-line); border-bottom: 1px solid var(--cell-line);
  font-family: 'Orbitron', sans-serif; font-size: 5.4cqw; font-weight: 700; cursor: pointer;
  color: var(--cyan); text-shadow: 0 0 6px rgba(34, 228, 255, .85), 0 0 14px rgba(34, 228, 255, .45);
  transition: background-color .2s ease, box-shadow .2s ease;
}
.sd-cell.ec { border-right: 0; }
.sd-cell.er { border-bottom: 0; }
.sd-cell.br { border-right: 2px solid var(--box-line); }
.sd-cell.bb { border-bottom: 2px solid var(--box-line); }

.sd-cell.given { color: #fbf6ff; font-weight: 900; text-shadow: 0 0 6px rgba(255, 255, 255, .55); }
.sd-cell.peer { background: rgba(139, 92, 255, .13); }
.sd-cell.same { background: rgba(255, 43, 214, .22); box-shadow: inset 0 0 14px rgba(255, 43, 214, .45); }
.sd-cell.sel {
  z-index: 1;
  background: radial-gradient(circle, rgba(34, 228, 255, .42), rgba(34, 228, 255, .1) 75%);
  box-shadow: inset 0 0 0 2px var(--cyan), 0 0 18px rgba(34, 228, 255, .8);
  animation: spot 1.6s ease-in-out infinite;
}
@keyframes spot {
  50% { box-shadow: inset 0 0 0 2px var(--cyan), 0 0 28px rgba(34, 228, 255, 1); }
}
.sd-cell.wrong { color: var(--red); text-shadow: 0 0 8px var(--red), 0 0 18px var(--red); }
.sd-cell.wrong .v { animation: wrongBlink 1s ease-in-out infinite; }
@keyframes wrongBlink { 50% { opacity: .55; } }
.sd-cell .v { display: block; line-height: 1; }

.notes {
  position: absolute; inset: 7%; display: grid;
  grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  font-family: 'Outfit', sans-serif; font-size: 2.5cqw; font-weight: 800; line-height: 1;
  color: #b9a8ff; text-shadow: 0 0 4px rgba(139, 92, 255, .9);
}
.notes span { display: flex; align-items: center; justify-content: center; }
.notes span.hl { color: #ffd6f7; text-shadow: 0 0 6px var(--pink), 0 0 12px var(--pink); }

/* Cells "power on" like stage lights */
.sd-board.entering .sd-cell { animation: lightsOn .7s steps(1) var(--d) backwards, cellIn .5s ease var(--d) backwards; }
@keyframes lightsOn { 0% { opacity: 0; } 30% { opacity: .8; } 45% { opacity: .1; } 60% { opacity: 1; } }
@keyframes cellIn { from { filter: brightness(3) blur(2px); } }

.sd-cell.placed .v { animation: bloom .45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes bloom {
  0% { transform: scale(.2); opacity: 0; }
  50% { transform: scale(1.4); text-shadow: 0 0 12px #fff, 0 0 30px var(--cyan); color: #fff; }
}
.sd-cell.shake { animation: shake .42s ease; }
@keyframes shake {
  20% { transform: translateX(-4px); background: rgba(255, 77, 109, .35); }
  40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); }
}
.sd-cell.flash { animation: laser .7s ease var(--fd-flash, 0ms); }
@keyframes laser {
  40% { background: rgba(182, 255, 59, .45); box-shadow: inset 0 0 16px rgba(182, 255, 59, .9), 0 0 22px rgba(182, 255, 59, .7); }
}
.sd-cell.autofill .v { animation: autoIn .65s cubic-bezier(.2, 1.5, .4, 1) var(--fd-autofill, 0ms) backwards; }
@keyframes autoIn {
  0% { opacity: 0; transform: scale(2.2); filter: blur(6px); }
  55% { opacity: 1; transform: scale(1.15); color: #fff; text-shadow: 0 0 10px var(--lime), 0 0 26px var(--lime); filter: none; }
  100% { transform: none; }
}
.sd-cell.hinted .v { animation: hintIn .9s ease; }
@keyframes hintIn {
  0% { transform: scale(0) rotate(-180deg); opacity: 0; }
  60% { transform: scale(1.45); color: #fff; text-shadow: 0 0 12px var(--amber), 0 0 30px var(--amber); }
  100% { transform: none; }
}

/* ================= Tools & number pad ================= */
.sd-controls { display: flex; justify-content: space-around; margin-top: 18px; }
.ctrl {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: 0; background: none; padding: 2px 8px; cursor: pointer;
  font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--muted);
}
.ctrl .ic {
  width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center;
  color: var(--text); background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: color .2s, box-shadow .25s, border-color .25s, transform .1s;
}
.ctrl:hover .ic { color: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 16px rgba(34, 228, 255, .55); }
.ctrl:active .ic { transform: scale(.92); }
.ctrl svg { width: 22px; height: 22px; }
.ctrl.on .ic {
  color: #fff; border-color: var(--pink);
  background: radial-gradient(circle, rgba(255, 43, 214, .55), rgba(139, 92, 255, .35));
  box-shadow: 0 0 20px rgba(255, 43, 214, .75);
}
.badge {
  position: absolute; top: -4px; right: 0; font-style: normal; font-size: 9px; font-weight: 900; letter-spacing: 1px;
  padding: 2px 6px; border-radius: 999px; background: #2a2145; color: var(--muted);
}
.ctrl.on .badge { background: var(--pink); color: #fff; box-shadow: 0 0 10px var(--pink); }

.sd-pad { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; margin-top: 18px; }
.pad-btn {
  padding: 0; min-width: 0;
  --c: var(--cyan);
  aspect-ratio: .75; border-radius: 12px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: var(--glass); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: var(--c); transition: transform .1s, box-shadow .2s, background .2s, opacity .3s;
}
.pad-btn:nth-child(1) { --c: #ff2bd6; }
.pad-btn:nth-child(2) { --c: #ff5ca8; }
.pad-btn:nth-child(3) { --c: #ffc23d; }
.pad-btn:nth-child(4) { --c: #b6ff3b; }
.pad-btn:nth-child(5) { --c: #3dffa8; }
.pad-btn:nth-child(6) { --c: #22e4ff; }
.pad-btn:nth-child(7) { --c: #4f9dff; }
.pad-btn:nth-child(8) { --c: #8b5cff; }
.pad-btn:nth-child(9) { --c: #c86bff; }
.pad-btn b {
  font-family: 'Orbitron', sans-serif; font-size: clamp(18px, 5.6vw, 26px); font-weight: 700; line-height: 1;
  text-shadow: 0 0 8px var(--c), 0 0 18px var(--c);
}
.pad-btn small { font-size: 11px; font-weight: 800; color: var(--muted); }
.pad-btn:hover { box-shadow: 0 0 18px color-mix(in srgb, var(--c) 70%, transparent); background: color-mix(in srgb, var(--c) 14%, var(--glass)); }
.pad-btn:active { transform: scale(.92); background: color-mix(in srgb, var(--c) 30%, var(--glass)); }
.pad-btn.done { opacity: .18; pointer-events: none; }
.notes-mode .pad-btn b { font-size: clamp(14px, 4.4vw, 19px); opacity: .8; }

.hint { text-align: center; color: var(--muted); font-size: 13px; font-weight: 700; margin-top: 20px; }
kbd {
  font-family: 'Orbitron', sans-serif; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 5px;
  color: var(--cyan); border: 1px solid rgba(34, 228, 255, .4);
}

/* ================= Content & footer ================= */
.seo {
  margin-top: 34px; padding: 22px 20px; border-radius: 18px; line-height: 1.6;
  background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.seo h2 {
  margin: 24px 0 8px; font-family: 'Orbitron', sans-serif; font-size: 17px; font-weight: 700; letter-spacing: .5px;
  color: #fff; text-shadow: 0 0 10px rgba(255, 43, 214, .7);
}
.seo h2:first-child { margin-top: 0; }
.seo p, .seo li { color: #ddd2f5; font-weight: 500; }
.seo .lead { color: #efe7ff; }
.seo a, .site-footer a:hover { color: var(--cyan); }
.ticks { list-style: none; padding: 0; margin: 8px 0; }
.ticks li { position: relative; padding: 4px 0 4px 26px; }
.ticks li::before { content: '★'; position: absolute; left: 2px; top: 4px; color: var(--amber); text-shadow: 0 0 8px var(--amber); }
.faq { border-top: 1px solid var(--glass-line); }
.faq:last-of-type { border-bottom: 1px solid var(--glass-line); }
.faq summary { cursor: pointer; list-style: none; padding: 12px 28px 12px 0; position: relative; font-weight: 700; color: #fff; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; position: absolute; right: 4px; top: 7px; font-size: 22px; color: var(--pink); text-shadow: 0 0 8px var(--pink); transition: transform .25s; }
.faq[open] summary::after { transform: rotate(45deg); }
.faq p { margin: 0 0 14px; color: var(--muted); }
.more { margin: 20px 0 0; }

.site-footer { margin-top: 28px; text-align: center; color: var(--muted); font-size: 13px; font-weight: 700; }
.site-footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin-bottom: 8px; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer p { margin: 0; line-height: 1.5; }

/* ================= Overlay ================= */
.overlay {
  position: absolute; inset: 3px; z-index: 10; border-radius: 17px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  background: rgba(7, 4, 15, .72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity .35s ease;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.overlay .card { padding: 16px; transform: scale(.8); filter: brightness(3); transition: transform .5s cubic-bezier(.2, 1.5, .4, 1), filter .6s; }
.overlay.show .card { transform: none; filter: none; }
.overlay h2 {
  margin: 0 0 8px; font-family: 'Monoton', cursive; font-weight: 400; font-size: 38px; color: #fff;
  text-shadow: 0 0 6px #fff, 0 0 18px var(--lime), 0 0 36px var(--cyan);
}
.overlay p { margin: 0 0 18px; color: var(--muted); font-weight: 700; }
.overlay .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.spinner {
  width: 54px; height: 54px; margin: 0 auto 16px; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent, var(--pink), var(--cyan));
  -webkit-mask: radial-gradient(circle, transparent 55%, #000 57%);
  mask: radial-gradient(circle, transparent 55%, #000 57%);
  filter: drop-shadow(0 0 8px var(--cyan));
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 100; mix-blend-mode: screen; }

@media (max-width: 400px) {
  .seg button { padding: 7px 10px; font-size: 13px; }
  .live { display: none; }
  .topbar { grid-template-columns: auto 1fr; }
  .sign { justify-self: end; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}
