/* ============================================================
   RANDOM AI GAMES — portal styling
   Two base themes (dark / light), chosen by the user and stored,
   plus per-game "vibes": hovering a game card re-tints the whole
   portal toward that game's palette. Everything runs off CSS
   custom properties set on <html data-theme="..." data-vibe="...">
   ============================================================ */

:root {
  /* Neutral hub identity: graphite + silver. */
  --bg: #0b0d14;
  --surf: rgba(21, 24, 36, 0.72);
  --ink: #e9ecf6;
  --dim: #8b92a8;
  --acc: #b7c0d4;
  --gold: #ffd166;
  --line: rgba(185, 195, 220, 0.16);
}

html[data-theme='light'] {
  --bg: #edeff4;
  --surf: rgba(255, 255, 255, 0.85);
  --ink: #1c2130;
  --dim: #60687c;
  --acc: #5a6580;
  --line: rgba(28, 33, 48, 0.18);
}

/* --- PERIGEE vibe: deep space blue --- */
html[data-vibe='perigee'] {
  --bg: #080b16;
  --surf: rgba(15, 20, 38, 0.75);
  --acc: #8ab4ff;
  --line: rgba(138, 180, 255, 0.22);
}

html[data-theme='light'][data-vibe='perigee'] {
  --bg: #e8edf7;
  --surf: rgba(234, 240, 251, 0.88);
  --acc: #3e6cc7;
  --line: rgba(62, 108, 199, 0.28);
}

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

html,
body {
  min-height: 100%;
  background: var(--bg);
  transition: background 0.45s ease;
}

body {
  color: var(--ink);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  transition: color 0.45s ease;
  overflow-x: hidden;
}

::selection {
  background: var(--acc);
  color: var(--bg);
}

::-webkit-scrollbar {
  width: 10px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--acc) 35%, transparent);
  border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--acc);
}

/* ---- CRT scanline texture (very subtle) ---- */
.scanlines {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 2px,
    color-mix(in srgb, var(--ink) 2.2%, transparent) 2px 3px
  );
  mix-blend-mode: overlay;
}

/* ---- top bar: auth + theme ---- */
.top-bar {
  position: fixed;
  top: 16px;
  right: 18px;
  z-index: 12;
  display: flex;
  gap: 8px;
}

.pill {
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--dim);
  background: var(--surf);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  transition:
    color 0.2s,
    border-color 0.2s;
}

.pill:hover {
  color: var(--ink);
  border-color: var(--acc);
}

.pill.wide {
  width: 100%;
  margin-top: 10px;
}

#auth-btn.me {
  color: var(--gold);
}

/* ---- auth dropdown panel ---- */
.auth-panel {
  position: fixed;
  top: 58px;
  right: 18px;
  z-index: 12;
  width: 300px;
  background: var(--surf);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  backdrop-filter: blur(6px);
  transition:
    border-color 0.45s ease,
    background 0.45s ease;
}

.auth-panel .auth-note {
  margin-top: 12px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--dim);
  text-align: center;
}

.auth-hello {
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--dim);
  margin-bottom: 12px;
}

.auth-hello b {
  color: var(--gold);
}

.auth-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.auth-stats > div {
  text-align: center;
  padding: 10px 4px 8px;
}

.auth-stats > div + div {
  border-left: 1px solid var(--line);
}

.auth-stats span {
  display: block;
  font-size: 16px;
  font-weight: 800;
  color: var(--acc);
}

.auth-stats label {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--dim);
}

.auth-rename {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.auth-rename input {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  outline: none;
}

.auth-rename input:focus {
  border-color: var(--acc);
}

.auth-panel .hidden {
  display: none !important;
}

/* ---- ambient starfield canvas ---- */
#stars {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

main {
  position: relative;
  z-index: 1;
  max-width: 1060px;
  margin: 0 auto;
  padding: 72px 24px 40px;
}

/* ---- header ---- */
header {
  position: relative;
  text-align: center;
  margin-bottom: 34px;
}

/* soft halo behind the title */
header::before {
  content: '';
  position: absolute;
  inset: -60px -80px;
  background: radial-gradient(
    ellipse 60% 70% at 50% 45%,
    color-mix(in srgb, var(--acc) 9%, transparent),
    transparent 70%
  );
  pointer-events: none;
}

.pre {
  color: var(--dim);
  font-size: 13px;
  letter-spacing: 2px;
  margin-bottom: 10px;
}

h1 {
  font-size: clamp(30px, 7vw, 66px);
  letter-spacing: 10px;
  font-weight: 800;
  white-space: nowrap;
}

/* per-letter title: staggered rise on load, wave on hover */
h1 .lt {
  display: inline-block;
  animation: lt-in 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.2) backwards;
  transition:
    color 0.25s,
    transform 0.25s,
    text-shadow 0.25s;
}

@keyframes lt-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.9);
  }
}

h1:hover .lt {
  color: var(--acc);
  transform: translateY(-6px);
  text-shadow: 0 0 22px color-mix(in srgb, var(--acc) 60%, transparent);
}

.tagline {
  margin-top: 14px;
  color: var(--dim);
  letter-spacing: 3px;
  font-size: 14px;
}

/* ---- ticker marquee ---- */
.ticker {
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 0 -24px 30px;
  transition: border-color 0.45s ease;
}

.ticker-track {
  display: flex;
  align-items: center;
  gap: 28px;
  width: max-content;
  padding: 9px 0;
  animation: ticker 26s linear infinite;
}

.ticker:hover .ticker-track {
  animation-play-state: paused;
}

.ticker-track span {
  font-size: 11.5px;
  letter-spacing: 3px;
  color: var(--dim);
  white-space: nowrap;
}

.ticker-track i {
  font-style: normal;
  font-size: 8px;
  color: var(--acc);
  transition: color 0.45s ease;
}

@keyframes ticker {
  to {
    transform: translateX(-50%);
  }
}

/* ---- stats strip ---- */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surf);
  margin-bottom: 44px;
  transition:
    border-color 0.45s ease,
    background 0.45s ease;
}

.stats-strip .stat {
  padding: 16px 10px 14px;
  text-align: center;
}

.stats-strip .stat + .stat {
  border-left: 1px solid var(--line);
}

.stats-strip .num {
  display: block;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--acc);
  transition: color 0.45s ease;
}

.stats-strip .lbl {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: 2.5px;
  color: var(--dim);
}

@media (max-width: 640px) {
  .stats-strip {
    grid-template-columns: repeat(2, 1fr);
  }
  .stats-strip .stat:nth-child(3) {
    border-left: none;
  }
  .stats-strip .stat:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }
}

/* ---- section label ---- */
.section-label {
  font-size: 12px;
  letter-spacing: 4px;
  color: var(--dim);
  margin-bottom: 18px;
}

/* ---- game grid ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 28px;
}

.card {
  position: relative;
  display: block;
  text-decoration: none;
  color: var(--ink);
  background: var(--surf);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  transform-style: preserve-3d;
  transition:
    transform 0.15s ease-out,
    box-shadow 0.3s ease,
    border-color 0.3s ease,
    background 0.45s ease;
}

/* corner brackets — targeting-reticle personality */
.card::before,
.card::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  z-index: 3;
  opacity: 0.55;
  transition:
    opacity 0.25s,
    border-color 0.45s ease;
  pointer-events: none;
}

.card::before {
  top: 8px;
  left: 8px;
  border-top: 2px solid var(--acc);
  border-left: 2px solid var(--acc);
}

.card::after {
  bottom: 8px;
  right: 8px;
  border-bottom: 2px solid var(--acc);
  border-right: 2px solid var(--acc);
}

.card:hover::before,
.card:hover::after {
  opacity: 1;
}

/* shine sweep on hover */
.shine {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(
    115deg,
    transparent 35%,
    color-mix(in srgb, var(--ink) 9%, transparent) 48%,
    color-mix(in srgb, var(--ink) 13%, transparent) 50%,
    color-mix(in srgb, var(--ink) 9%, transparent) 52%,
    transparent 65%
  );
  transform: translateX(-120%);
}

a.card:hover .shine {
  animation: shine 0.9s ease;
}

@keyframes shine {
  to {
    transform: translateX(120%);
  }
}

a.card:hover {
  border-color: color-mix(in srgb, var(--acc) 55%, transparent);
  box-shadow: 0 16px 48px color-mix(in srgb, var(--acc) 22%, transparent);
}

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg);
  transition: background 0.45s ease;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s ease;
}

a.card:hover .thumb img {
  transform: scale(1.05);
}

/* gradient fade into the card body */
.thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--bg) 0%, transparent 32%);
  opacity: 0.5;
  pointer-events: none;
}

.idx {
  position: absolute;
  top: 10px;
  left: 34px;
  z-index: 2;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--dim);
}

.badge {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #1a1409;
  background: var(--gold);
  border-radius: 4px;
  padding: 4px 8px;
}

.badge.soon {
  color: var(--dim);
  background: transparent;
  border: 1px solid var(--line);
}

.mystery {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 72px;
  font-weight: 800;
  color: color-mix(in srgb, var(--acc) 26%, transparent);
}

.ghost {
  opacity: 0.55;
}

.body {
  padding: 18px 20px 20px;
}

.body h2 {
  letter-spacing: 5px;
  font-size: 22px;
  margin-bottom: 8px;
}

.body p {
  color: var(--dim);
  font-size: 13.5px;
  line-height: 1.65;
  margin-bottom: 14px;
}

.play {
  display: inline-block;
  color: var(--gold);
  letter-spacing: 3px;
  font-size: 13px;
  font-weight: 700;
}

a.card:hover .play {
  animation: nudge 0.7s ease infinite alternate;
}

@keyframes nudge {
  to {
    transform: translateX(5px);
  }
}

.play.soon {
  color: var(--dim);
}

footer {
  text-align: center;
  margin-top: 56px;
  color: var(--dim);
  font-size: 12.5px;
  letter-spacing: 1px;
}

.cursor {
  animation: blink 1.1s steps(1) infinite;
}

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