:root {
  --cyan: #45d6ff;
  --cyan-soft: rgba(69, 214, 255, 0.35);
  --ink: #e8f7ff;
  --red: #ff4d6a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #020814; color: var(--ink); overflow: hidden; }
body { font-family: "Rajdhani", system-ui, sans-serif; }

.bg {
  position: fixed; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: 50% 30%;
  filter: saturate(1.15) brightness(0.75);
}
.veil {
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse at 50% 38%, rgba(2, 8, 20, 0) 0%, rgba(2, 8, 20, 0.55) 55%, rgba(2, 8, 20, 0.92) 100%),
    linear-gradient(to bottom, rgba(2, 8, 20, 0.5), rgba(2, 8, 20, 0.15) 30%, rgba(2, 8, 20, 0.85) 70%, #020814);
}
.scanline {
  position: fixed; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(69, 214, 255, 0.04) 0 1px, transparent 1px 4px);
  mix-blend-mode: screen;
}

.gate {
  position: relative; z-index: 2; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding: calc(env(safe-area-inset-top, 0px) + 28px) 20px calc(env(safe-area-inset-bottom, 0px) + 26px);
  gap: 14px;
}
header { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 36px); text-align: center; }
h1 {
  margin: 0; font-family: "Orbitron", sans-serif; font-weight: 900;
  font-size: clamp(2.4rem, 11vw, 3.6rem); letter-spacing: 0.32em; padding-left: 0.32em;
  color: #fff; text-shadow: 0 0 18px var(--cyan), 0 0 42px rgba(69, 214, 255, 0.55);
  animation: flicker 6s infinite;
}
.tag { margin: 6px 0 0; font-size: 0.8rem; letter-spacing: 0.45em; text-transform: uppercase; color: var(--cyan); opacity: 0.85; }

.reactor { position: relative; width: 92px; height: 92px; margin-bottom: 4px; }
.ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid transparent; }
.r1 { border-top-color: var(--cyan); border-bottom-color: var(--cyan); animation: spin 3.2s linear infinite; box-shadow: 0 0 14px var(--cyan-soft); }
.r2 { inset: 12px; border-left-color: var(--cyan); border-right-color: rgba(69, 214, 255, 0.4); animation: spin 2.2s linear infinite reverse; }
.r3 { inset: 24px; border: 1px dashed rgba(69, 214, 255, 0.6); animation: spin 8s linear infinite; }
.core {
  position: absolute; inset: 34px; border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, var(--cyan) 45%, rgba(69, 214, 255, 0) 75%);
  animation: pulse 2.4s ease-in-out infinite;
}
.reactor.busy .r1 { animation-duration: 0.8s; }
.reactor.busy .r2 { animation-duration: 0.6s; }
.reactor.bad .ring { border-top-color: var(--red); border-bottom-color: var(--red); border-left-color: var(--red); }
.reactor.bad .core { background: radial-gradient(circle, #fff 0%, var(--red) 45%, transparent 75%); }

.status {
  margin: 0; min-height: 1.3em; font-size: 0.85rem; letter-spacing: 0.28em; text-transform: uppercase;
  color: var(--cyan); text-align: center;
}
.status.err { color: var(--red); }

.dots { display: flex; gap: 16px; margin: 2px 0 10px; }
.dots i {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid var(--cyan); transition: all 0.15s;
}
.dots i.on { background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
.dots.shake { animation: shake 0.45s; }
.dots.shake i { border-color: var(--red); }

.pad {
  display: grid; grid-template-columns: repeat(3, 76px); gap: 14px 26px; justify-content: center;
}
.pad button {
  width: 76px; height: 76px; border-radius: 50%;
  font: 600 1.9rem "Rajdhani", sans-serif; color: #fff;
  background: rgba(8, 30, 52, 0.45);
  border: 1px solid rgba(69, 214, 255, 0.45);
  box-shadow: inset 0 0 18px rgba(69, 214, 255, 0.12), 0 0 10px rgba(69, 214, 255, 0.12);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: transform 0.08s, background 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
.pad button:active, .pad button.hit {
  transform: scale(0.92); background: rgba(69, 214, 255, 0.28);
  box-shadow: inset 0 0 22px rgba(69, 214, 255, 0.4), 0 0 22px rgba(69, 214, 255, 0.5);
}
.pad button[data-k="del"] { font-size: 1.4rem; }
.pad[aria-disabled="true"] { opacity: 0.4; pointer-events: none; }

#pinStep { display: flex; flex-direction: column; align-items: center; }
.face-step { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 30px; }
.face-btn {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 22px 34px; border-radius: 22px; cursor: pointer;
  background: rgba(8, 30, 52, 0.55); border: 1px solid var(--cyan); color: #fff;
  font: 600 1rem "Rajdhani", sans-serif; letter-spacing: 0.2em; text-transform: uppercase;
  box-shadow: 0 0 24px rgba(69, 214, 255, 0.35), inset 0 0 20px rgba(69, 214, 255, 0.15);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: glow 2.2s ease-in-out infinite;
}
.face-btn svg { width: 64px; height: 64px; fill: none; stroke: var(--cyan); stroke-width: 2.5; stroke-linecap: round; filter: drop-shadow(0 0 8px var(--cyan)); }
.face-btn.small { flex-direction: row; padding: 10px 18px; animation: none; }
.link-btn { background: none; border: 0; color: var(--cyan); opacity: 0.8; font: 500 0.85rem "Rajdhani", sans-serif; letter-spacing: 0.12em; cursor: pointer; }
.code-row { display: flex; gap: 10px; }
.code-row input {
  width: 170px; text-align: center; font: 700 1rem "Orbitron", sans-serif; letter-spacing: 0.12em; color: #fff;
  background: rgba(2, 12, 24, 0.7); border: 1px solid var(--cyan); border-radius: 12px; padding: 10px;
}
@keyframes glow { 0%, 100% { box-shadow: 0 0 18px rgba(69, 214, 255, 0.3), inset 0 0 20px rgba(69, 214, 255, 0.12); } 50% { box-shadow: 0 0 34px rgba(69, 214, 255, 0.6), inset 0 0 24px rgba(69, 214, 255, 0.25); } }

.granted {
  position: fixed; inset: 0; z-index: 5; display: grid; place-items: center;
  background: radial-gradient(circle, rgba(69, 214, 255, 0.25), rgba(2, 8, 20, 0.95) 70%);
  opacity: 0; pointer-events: none; transition: opacity 0.35s;
}
.granted span {
  font: 700 1.3rem "Orbitron", sans-serif; letter-spacing: 0.35em; color: #fff;
  text-shadow: 0 0 20px var(--cyan);
}
.granted.show { opacity: 1; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 0.75; transform: scale(0.92); } 50% { opacity: 1; transform: scale(1.06); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
@keyframes flicker { 0%, 92%, 100% { opacity: 1; } 93% { opacity: 0.6; } 94% { opacity: 1; } 96% { opacity: 0.75; } }

@media (max-height: 640px) {
  .pad { grid-template-columns: repeat(3, 64px); gap: 10px 22px; }
  .pad button { width: 64px; height: 64px; font-size: 1.6rem; }
  .reactor { width: 64px; height: 64px; }
  .r2 { inset: 9px; } .r3 { inset: 17px; } .core { inset: 24px; }
}
