:root {
  --bg-0: #0a0608;
  --bg-1: #140a0e;
  --red: #ff2a2a;
  --red-hot: #ff4d3a;
  --red-dim: #ff2a2a66;
  --red-glow: #ff2a2a44;
  --orange: #ff7a3c;
  --text: #f6f0f2;
  --muted: #b8a4a9;
  --ok: #3dff9a;
  --warn: #ffb020;
  --card: #16090eef;
  --panel: #12080c;
  --line: #ff2a2a55;
  --radius: 0;
  --topbar-h: 3.75rem;
  --font-display: "Rajdhani Local", "Segoe UI", sans-serif;
  --font-body: "Exo Local", "Segoe UI", Tahoma, sans-serif;
}

@font-face {
  font-family: "Rajdhani Local";
  src: local("Rajdhani"), local("Arial Black"), local("Segoe UI Bold");
  font-display: swap;
}

@font-face {
  font-family: "Exo Local";
  src: local("Exo 2"), local("Segoe UI"), local("Tahoma");
  font-display: swap;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  color: var(--text);
  font-family: var(--font-body);
  background-color: var(--bg-0);
  background-image:
    radial-gradient(900px 500px at 12% -8%, #5a101844 0%, transparent 55%),
    radial-gradient(700px 420px at 88% 8%, #3a0a12aa 0%, transparent 50%),
    linear-gradient(165deg, var(--bg-0), var(--bg-1) 48%, #080406);
  background-attachment: fixed;
  overflow-x: hidden;
}

.scanlines,
.glow-bg,
.particles {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
}

.scanlines {
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 3px,
    #00000018 4px
  );
  mix-blend-mode: soft-light;
  animation: flicker 7s infinite;
}

.glow-bg {
  background:
    radial-gradient(circle at 18% 22%, #ff2a2a1a, transparent 32%),
    radial-gradient(circle at 78% 28%, #ff7a3c14, transparent 36%);
}

.particles {
  background-image:
    radial-gradient(circle, #ffffff22 0 1px, transparent 2px),
    radial-gradient(circle, #ff2a2a33 0 1.5px, transparent 3px),
    radial-gradient(circle, #ffffff14 0 1px, transparent 2px);
  background-size: 180px 180px, 260px 260px, 120px 120px;
  background-position: 0 0, 40px 60px, 90px 20px;
  animation: drift 40s linear infinite;
  opacity: 0.55;
}

.app-frame {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--topbar-h);
  padding: 0.85rem clamp(1rem, 3vw, 1.75rem);
  border-bottom: 1px solid var(--line);
  background: #12070acc;
  backdrop-filter: blur(8px);
}

.brand {
  font-family: var(--font-display);
  letter-spacing: 0.22em;
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 1.05rem;
}

.brand span {
  color: var(--red);
  text-shadow: 0 0 10px var(--red-dim), 0 0 22px var(--red-glow);
}

.shell {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 1rem clamp(0.9rem, 3vw, 1.5rem) 1.25rem;
}

.shell-login {
  flex: 1 1 auto;
  display: flex;
  width: 100%;
  max-width: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.shell-panel {
  flex: 1 1 auto;
  display: flex;
  width: 100%;
  max-width: none;
  min-height: 0;
  padding: 1rem clamp(0.9rem, 3vw, 1.5rem) 1.25rem;
}

.login-stage {
  width: min(420px, 100%);
}

.panel-stage {
  flex: 1 1 auto;
  display: flex;
  width: 100%;
  min-height: 0;
}

.frame {
  position: relative;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow:
    0 18px 40px #00000088,
    0 0 0 1px #ffffff08 inset,
    0 0 28px var(--red-glow);
}

.frame::before,
.frame::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid var(--red);
  pointer-events: none;
  z-index: 2;
}

.frame::before {
  top: -2px;
  left: -2px;
  border-right: 0;
  border-bottom: 0;
  box-shadow: -2px -2px 10px var(--red-glow);
}

.frame::after {
  right: -2px;
  bottom: -2px;
  border-left: 0;
  border-top: 0;
  box-shadow: 2px 2px 10px var(--red-glow);
}

.frame-corners {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.frame-corners::before,
.frame-corners::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid var(--red-hot);
}

.frame-corners::before {
  top: -2px;
  right: -2px;
  border-left: 0;
  border-bottom: 0;
}

.frame-corners::after {
  left: -2px;
  bottom: -2px;
  border-right: 0;
  border-top: 0;
}

.login-card {
  width: 100%;
  display: grid;
  gap: 0.85rem;
  padding: 1.35rem 1.25rem 1.25rem;
}

.input {
  width: 100%;
  border: 1px solid var(--red-dim);
  border-radius: var(--radius);
  background: #0c0608;
  color: var(--text);
  padding: 0.95rem 1rem;
  font-size: 1rem;
  outline: none;
  box-shadow: inset 0 0 0 1px #ffffff06, 0 0 12px #ff2a2a14;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 1px var(--red-dim), 0 0 18px var(--red-glow);
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.75rem 1rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease,
    filter 0.15s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, var(--red-hot), var(--red));
  color: #fff;
  border-color: #ff6a55;
  box-shadow: 0 0 18px var(--red-dim), 0 8px 20px #00000066;
}

.btn-wide {
  width: 100%;
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.btn-run {
  background: #0c1a12;
  border-color: var(--ok);
  color: var(--ok);
  box-shadow: 0 0 12px #3dff9a33;
}

.btn-stop {
  background: #1a080c;
  border-color: var(--red);
  color: var(--red-hot);
  box-shadow: 0 0 12px var(--red-glow);
}

.btn-restart {
  background: #1a1008;
  border-color: var(--orange);
  color: var(--orange);
  box-shadow: 0 0 12px #ff7a3c33;
}

.flash {
  margin: 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--red);
  color: #ffd0d6;
  background: #2a0710cc;
  box-shadow: 0 0 16px var(--red-glow);
  font-size: 0.88rem;
  line-height: 1.35;
}

.games-rail {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 1.15rem;
  width: 100%;
  height: calc(100dvh - var(--topbar-h) - 2.25rem);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  padding: 0.15rem 0.1rem 0.85rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-color: var(--red) #1a0a10;
}

.games-rail::-webkit-scrollbar {
  height: 8px;
}

.games-rail::-webkit-scrollbar-thumb {
  background: var(--red);
}

.games-rail::-webkit-scrollbar-track {
  background: #1a0a10;
}

.game-tile {
  flex: 0 0 clamp(220px, 22vw, 280px);
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  scroll-snap-align: start;
  animation: card-in 0.45s ease both;
}

.tile-media {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0d0609;
  box-shadow:
    0 18px 36px #00000099,
    0 0 22px var(--red-glow);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.game-tile:hover .tile-media,
.game-tile:focus-within .tile-media {
  border-color: #ff5a4a;
  box-shadow: 0 22px 42px #000000aa, 0 0 30px var(--red-dim);
  transform: translateY(-2px);
}

.tile-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.tile-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    #0a040822 0%,
    #0a040855 45%,
    #080306f0 100%
  );
}

.tile-meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  display: grid;
  gap: 0.45rem;
  padding: 0.9rem;
}

.tile-endpoint {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  z-index: 3;
  max-width: calc(100% - 1.2rem);
  padding: 0.35rem 0.5rem;
  border: 1px solid #ff2a2a55;
  background: #0a0508cc;
  backdrop-filter: blur(5px);
  box-shadow: 0 0 12px #ff2a2a33;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  line-height: 1.2;
  text-align: right;
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-name {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 1.15rem;
  text-shadow: 0 2px 12px #000;
}

.status {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 0.45rem;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.35rem 0.55rem;
  border: 1px solid #ffffff18;
  background: #0a0508aa;
  backdrop-filter: blur(4px);
}

.status-dot {
  width: 0.55rem;
  height: 0.55rem;
  box-shadow: 0 0 10px currentColor;
  flex-shrink: 0;
}

.status-dot.on {
  background: var(--ok);
  color: var(--ok);
}

.status-dot.off {
  background: var(--red);
  color: var(--red);
}

.status-dot.busy {
  background: var(--warn);
  color: var(--warn);
  animation: blink 1s steps(2) infinite;
}

.tile-actions {
  flex: 0 0 auto;
  display: grid;
  gap: 0.4rem;
  padding: 0.65rem;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 10px 24px #00000077, 0 0 16px #ff2a2a22;
}

.tile-actions .btn {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font-size: 0.78rem;
}

.loading,
.error-inline {
  color: var(--muted);
}

.error-inline {
  color: #ffb0b8;
  font-size: 0.82rem;
  margin: 0;
}

@keyframes flicker {
  0%,
  97%,
  100% {
    opacity: 0.5;
  }
  98% {
    opacity: 0.32;
  }
}

@keyframes blink {
  50% {
    opacity: 0.25;
  }
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes drift {
  from {
    background-position: 0 0, 40px 60px, 90px 20px;
  }
  to {
    background-position: 180px 120px, 300px 180px, 210px 140px;
  }
}

@media (max-width: 720px) {
  body.page-panel {
    overflow-y: auto;
  }

  .games-rail {
    flex-direction: column;
    height: auto;
    overflow-x: hidden;
    overflow-y: visible;
    scroll-snap-type: none;
    gap: 1.1rem;
    padding-bottom: 0.25rem;
  }

  .game-tile {
    flex: 0 0 auto;
    width: min(100%, 420px);
    margin: 0 auto;
    height: auto;
  }

  .tile-media {
    flex: 0 0 auto;
    aspect-ratio: 1 / 1;
    width: 100%;
  }

  .tile-art {
    object-fit: contain;
    background: #0a0508;
  }

  .tile-shade {
    background: linear-gradient(180deg, transparent 55%, #080306ee 100%);
  }

  .topbar {
    padding-inline: 0.9rem;
  }
}

@media (min-width: 721px) {
  body.page-login,
  body.page-panel {
    overflow: hidden;
  }
}
