* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  overflow: hidden;
  background: #050508;
  color: #00ffcc;
  font-family: "Courier New", Courier, monospace;
}

.grid-bg {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 255, 204, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 204, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  animation: gridShift 12s linear infinite;
  z-index: 0;
  pointer-events: none;
}

@keyframes gridShift {
  from { transform: translateY(0); }
  to { transform: translateY(48px); }
}

#ui-layer {
  position: absolute;
  top: 24px;
  left: 24px;
  z-index: 10;
  max-width: min(440px, 92vw);
  pointer-events: auto;
}

.tag {
  font-size: 12px;
  letter-spacing: 0.12em;
  opacity: 0.75;
  margin-bottom: 8px;
}

h1 {
  font-size: 28px;
  text-shadow: 0 0 14px #00ffcc;
  margin-bottom: 6px;
}

.sub {
  font-size: 13px;
  opacity: 0.85;
  margin-bottom: 16px;
}

.layers {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  font-size: 12px;
}

.layers li {
  padding: 6px 10px;
  margin-bottom: 4px;
  border-left: 3px solid rgba(0, 255, 204, 0.25);
  opacity: 0.55;
  background: rgba(0, 20, 24, 0.45);
}

.layers li.active {
  opacity: 1;
  border-left-color: #00ffcc;
  box-shadow: 0 0 12px rgba(0, 255, 204, 0.2);
}

.layers li.done {
  opacity: 0.9;
  border-left-color: #cc00ff;
  color: #e0b0ff;
}

.meta {
  font-size: 13px;
  margin: 2px 0;
  opacity: 0.85;
}

.meta.warn {
  color: #ffaa55;
}

#status,
.hud {
  margin-top: 18px;
  font-weight: bold;
  color: #ff0055;
  text-shadow: 0 0 10px #ff0055;
  font-size: 14px;
  line-height: 1.4;
  min-height: 2.8em;
}

#status.ok,
.hud.ok {
  color: #cc00ff;
  text-shadow: 0 0 10px #cc00ff;
}

#status.warn,
.hud.warn {
  color: #ffaa00;
  text-shadow: 0 0 10px #ffaa00;
}

#status.fail,
.hud.fail {
  color: #ff3355;
  text-shadow: 0 0 12px #ff0033;
}

.hint {
  margin-top: 14px;
  font-size: 11px;
  opacity: 0.7;
  max-width: 42ch;
  line-height: 1.45;
}

.hint code {
  color: #7dffe0;
}

/* Multi-layer security core visualization */
#core-stage {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(0, 255, 204, 0.35);
  box-shadow:
    0 0 20px rgba(0, 255, 204, 0.15),
    inset 0 0 20px rgba(0, 255, 204, 0.08);
  transition: border-color 0.35s ease, opacity 0.35s ease, filter 0.35s ease;
}

.ring-outer {
  width: min(420px, 70vw);
  height: min(420px, 70vw);
  animation: spin 28s linear infinite;
  border-style: dashed;
}

.ring-mid {
  width: min(300px, 52vw);
  height: min(300px, 52vw);
  animation: spin-rev 18s linear infinite;
  border-color: rgba(204, 0, 255, 0.4);
}

.ring-inner {
  width: min(190px, 34vw);
  height: min(190px, 34vw);
  animation: spin 12s linear infinite;
  border-color: rgba(0, 255, 170, 0.5);
}

/* Breached rings after successful layer 1 / 2 */
.ring.breached {
  border-style: solid;
  border-color: rgba(255, 40, 80, 0.15) !important;
  opacity: 0.42;
  filter: saturate(0.35);
  box-shadow:
    0 0 8px rgba(255, 0, 60, 0.25),
    inset 0 0 30px rgba(255, 0, 40, 0.12);
  animation-duration: 48s !important;
}

.ring.breached::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background:
    conic-gradient(
      from 40deg,
      transparent 0 18deg,
      rgba(255, 60, 80, 0.55) 18deg 32deg,
      transparent 32deg 55deg,
      rgba(255, 80, 100, 0.4) 55deg 62deg,
      transparent 62deg 100deg,
      rgba(255, 40, 70, 0.5) 100deg 118deg,
      transparent 118deg 360deg
    );
  mix-blend-mode: screen;
  pointer-events: none;
  animation: breach-flicker 1.2s ease-in-out infinite alternate;
}

@keyframes breach-flicker {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

.core-hex {
  width: min(110px, 20vw);
  height: min(110px, 20vw);
  background: linear-gradient(135deg, rgba(0, 255, 204, 0.15), rgba(204, 0, 255, 0.2));
  clip-path: polygon(50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
  box-shadow: 0 0 40px rgba(0, 255, 204, 0.35);
  animation: pulse-core 2.4s ease-in-out infinite;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.core-pulse {
  position: absolute;
  width: min(80px, 14vw);
  height: min(80px, 14vw);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 255, 204, 0.45), transparent 70%);
  animation: pulse-glow 2.4s ease-in-out infinite;
}

body.core-purple .ring:not(.breached) {
  border-color: rgba(204, 0, 255, 0.55);
}
body.core-purple .core-hex {
  background: linear-gradient(135deg, rgba(204, 0, 255, 0.3), rgba(0, 255, 204, 0.15));
}
body.core-amber .ring:not(.breached) {
  border-color: rgba(255, 170, 0, 0.55);
}
body.core-amber .core-hex {
  background: linear-gradient(135deg, rgba(255, 170, 0, 0.35), rgba(255, 0, 85, 0.15));
}
body.core-danger .ring:not(.breached) {
  border-color: rgba(255, 0, 60, 0.7);
  animation-duration: 4s !important;
}
body.core-danger .core-hex {
  background: linear-gradient(135deg, rgba(255, 0, 60, 0.5), rgba(80, 0, 0, 0.4));
}

/* Short success / fail flash on core */
body.core-flash-ok .core-hex,
body.core-flash-ok .core-pulse,
#core-stage.stage-flash-ok .core-hex,
#core-stage.stage-flash-ok .core-pulse {
  animation: flash-ok 1.1s ease-out 1;
  box-shadow: 0 0 70px rgba(180, 80, 255, 1) !important;
}
body.core-flash-fail .core-hex,
body.core-flash-fail .core-pulse,
#core-stage.stage-flash-fail .core-hex,
#core-stage.stage-flash-fail .core-pulse {
  animation: flash-fail 1.1s ease-out 1;
  box-shadow: 0 0 70px rgba(255, 30, 60, 1) !important;
}

#status.hud.flash-hud-ok {
  animation: hud-pulse-ok 1s ease-out 1;
}
#status.hud.flash-hud-fail {
  animation: hud-pulse-fail 1s ease-out 1;
}

@keyframes hud-pulse-ok {
  0% { transform: scale(1); filter: brightness(1); }
  40% { transform: scale(1.03); filter: brightness(1.4); }
  100% { transform: scale(1); filter: brightness(1); }
}
@keyframes hud-pulse-fail {
  0% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  100% { transform: translateX(0); }
}

@keyframes flash-ok {
  0% { filter: brightness(1); transform: scale(1); }
  40% { filter: brightness(1.8); transform: scale(1.12); }
  100% { filter: brightness(1); transform: scale(1); }
}
@keyframes flash-fail {
  0% { filter: brightness(1) hue-rotate(0deg); }
  35% { filter: brightness(1.6) hue-rotate(-20deg); transform: scale(1.08); }
  100% { filter: brightness(1); transform: scale(1); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes spin-rev {
  to { transform: rotate(-360deg); }
}
@keyframes pulse-core {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.08); opacity: 1; }
}
@keyframes pulse-glow {
  0%, 100% { transform: scale(0.85); opacity: 0.5; }
  50% { transform: scale(1.25); opacity: 0.9; }
}

@media (max-width: 640px) {
  #ui-layer {
    top: 12px;
    left: 12px;
  }
  h1 { font-size: 22px; }
}
