/* ═══════════════════════════════════════════════════
   GAME LAUNCHER — Retro CRT Stylesheet
   Font: Press Start 2P (Google Fonts)
═══════════════════════════════════════════════════ */

/* ── Reset & base ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --cyan:    #00e5ff;
  --pink:    #ff0080;
  --yellow:  #ffe000;
  --green:   #00ff88;
  --bg:      #06000f;
  --surface: rgba(0, 229, 255, 0.04);
  --border:  rgba(0, 229, 255, 0.22);
  --text:    #e8f8ff;           /* brighter base text */
  --dim:     #7ec8dd;           /* was #5a8090 — now readable on dark */
  --dim2:    #a8d8e8;           /* for card desc — lighter still */
  --glow-c:  0 0 8px var(--cyan), 0 0 20px rgba(0,229,255,0.3);
  --glow-p:  0 0 8px var(--pink), 0 0 20px rgba(255,0,128,0.3);
  --glow-y:  0 0 8px var(--yellow), 0 0 20px rgba(255,224,0,0.3);
  --font:    'Press Start 2P', monospace;
  --radius:  4px;
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  overflow: hidden;
  font-family: var(--font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision; /* sharper pixel font rendering */
}

/* ── Boot screen ───────────────────────────────── */
#boot {
  position: fixed; inset: 0; z-index: 999;
  background: #000;
  display: flex; align-items: center; justify-content: center;
}

#boot-inner {
  display: flex; flex-direction: column; align-items: center; gap: 24px;
  width: min(380px, 90vw);
}

#boot-logo {
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
}

.pixel-border {
  font-family: var(--font);
  font-size: clamp(0.9rem, 3.5vw, 1.5rem);
  color: var(--cyan);
  text-shadow: var(--glow-c);
  border: 3px solid var(--cyan);
  box-shadow: var(--glow-c), inset var(--glow-c);
  padding: 16px 28px;
  letter-spacing: 6px;
  animation: flicker 4s infinite;
  white-space: nowrap;
}

#boot-lines {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: var(--cyan);
  text-shadow: 0 0 6px var(--cyan);
  line-height: 1.8;
  width: 100%;
  min-height: 80px;
  letter-spacing: 1px;
}

#boot-bar-wrap {
  width: 100%;
  height: 10px;
  border: 1px solid var(--cyan);
  box-shadow: var(--glow-c);
  position: relative;
  overflow: hidden;
}

#boot-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--pink));
  box-shadow: var(--glow-c);
  transition: width 0.05s linear;
}

/* ── Background canvas ─────────────────────────── */
#bg {
  position: fixed; inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* ── CRT overlays ──────────────────────────────── */
#scanlines {
  position: fixed; inset: 0; z-index: 1;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0,0,0,0.18) 2px,
    rgba(0,0,0,0.18) 3px
  );
  animation: scanroll 8s linear infinite;
}

#vignette {
  position: fixed; inset: 0; z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse at center,
    transparent 55%,
    rgba(0,0,0,0.55) 85%,
    rgba(0,0,0,0.85) 100%
  );
}

/* ── Launcher shell ────────────────────────────── */
#launcher {
  position: relative; z-index: 10;
  width: 100vw; height: 100vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}

#launcher.hidden { display: none; }

/* ── Header ────────────────────────────────────── */
#header {
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
  padding: 14px 28px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(6px);
  gap: 16px;
  position: relative; z-index: 20;
}

#header::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  opacity: 0.6;
}

#header-left { display: flex; align-items: center; gap: 20px; }

#logo-text {
  display: flex; align-items: center; gap: 10px;
  cursor: default;
}

.logo-gl {
  font-size: 1.8rem;
  filter: drop-shadow(0 0 8px var(--cyan));
  animation: float 3s ease-in-out infinite;
}

.logo-title {
  font-family: var(--font);
  font-size: 0.68rem;
  line-height: 1.7;
  color: var(--cyan);
  text-shadow: var(--glow-c);
  letter-spacing: 3px;
}

#game-count-badge {
  font-size: 0.55rem;
  color: var(--pink);
  border: 1px solid var(--pink);
  padding: 4px 8px;
  letter-spacing: 2px;
  box-shadow: 0 0 6px rgba(255,0,128,0.3);
  white-space: nowrap;
}

#header-right { display: flex; align-items: center; gap: 12px; }

/* Search */
#search-wrap {
  display: flex; align-items: center;
  border: 1px solid var(--border);
  background: rgba(0,229,255,0.04);
  padding: 7px 12px;
  gap: 8px;
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#search-wrap:focus-within {
  border-color: var(--cyan);
  box-shadow: var(--glow-c);
}

.search-icon { font-size: 1.1rem; color: var(--dim); pointer-events: none; }

#search {
  background: transparent; border: none; outline: none;
  font-family: var(--font);
  font-size: 0.55rem;
  color: var(--cyan);
  letter-spacing: 2px;
  width: clamp(100px, 14vw, 200px);
  caret-color: var(--cyan);
}

#search::placeholder { color: var(--dim); }

#search-clear {
  cursor: pointer; color: var(--dim); font-size: 0.8rem;
  transition: color 0.2s;
}
#search-clear:hover { color: var(--pink); }
#search-clear.hidden { display: none; }

/* Music button */
#music-btn {
  display: flex; align-items: center; gap: 7px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--yellow);
  font-family: var(--font);
  font-size: 0.55rem;
  letter-spacing: 2px;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

#music-btn:hover {
  border-color: var(--yellow);
  box-shadow: var(--glow-y);
  color: var(--yellow);
}

#music-btn.playing {
  border-color: var(--yellow);
  box-shadow: var(--glow-y);
}

#music-icon { font-size: 0.9rem; }

/* ── Category bar ──────────────────────────────── */
#categories {
  display: flex; align-items: center;
  flex-shrink: 0;
  padding: 10px 28px;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid rgba(0,229,255,0.08);
  position: relative; z-index: 20;
}

#categories::-webkit-scrollbar { display: none; }

.cat-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--dim2);          /* was --dim, now clearly visible */
  font-family: var(--font);
  font-size: 0.52rem;
  letter-spacing: 2px;
  padding: 7px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  position: relative;
}

.cat-btn::before {
  content: '';
  position: absolute; inset: 0;
  background: var(--cyan);
  opacity: 0;
  transition: opacity 0.15s;
}

.cat-btn:hover { border-color: var(--cyan); color: var(--cyan); }
.cat-btn:active { transform: scale(0.97); }

.cat-btn.active {
  border-color: var(--cyan);
  color: var(--cyan);
  text-shadow: var(--glow-c);
  box-shadow: var(--glow-c);
  background: rgba(0,229,255,0.07);
}

/* ── Game grid ─────────────────────────────────── */
#grid-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 28px 28px;
  position: relative; z-index: 10;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#grid-wrap::-webkit-scrollbar { width: 6px; }
#grid-wrap::-webkit-scrollbar-track { background: transparent; }
#grid-wrap::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

#game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

/* ── Game card ─────────────────────────────────── */
.game-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  will-change: transform;
  text-decoration: none;
  display: block;
  color: inherit;
}

.game-card::before {
  content: '';
  position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(135deg,
    rgba(0,229,255,0.06) 0%,
    transparent 50%,
    rgba(255,0,128,0.04) 100%
  );
  opacity: 0;
  transition: opacity 0.25s;
}

.game-card:hover {
  transform: translateY(-5px) scale(1.02);
  border-color: var(--cyan);
  box-shadow:
    0 0 12px rgba(0,229,255,0.25),
    0 0 32px rgba(0,229,255,0.1),
    0 8px 24px rgba(0,0,0,0.5);
}

.game-card:hover::before { opacity: 1; }

.game-card:active { transform: translateY(-2px) scale(1.01); }

/* Thumbnail area */
.card-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #0a0020;
  display: flex; align-items: center; justify-content: center;
}

.card-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  filter: brightness(0.85) saturate(1.2);
  transition: filter 0.25s;
}

.game-card:hover .card-thumb img { filter: brightness(1.05) saturate(1.4); }

/* Thumbnail placeholder */
.card-thumb .no-thumb {
  font-family: var(--font);
  font-size: 0.55rem;
  color: var(--dim2);
  letter-spacing: 2px;
  text-align: center;
  line-height: 2;
  padding: 16px;
}

.card-thumb .no-thumb .no-thumb-icon { font-size: 2.5rem; display: block; margin-bottom: 8px; }

/* Scanline on thumb */
.card-thumb::after {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    to bottom, transparent 0, transparent 2px,
    rgba(0,0,0,0.12) 2px, rgba(0,0,0,0.12) 3px
  );
  pointer-events: none;
  z-index: 2;
}

/* Play overlay */
.play-overlay {
  position: absolute; inset: 0; z-index: 3;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.game-card:hover .play-overlay { opacity: 1; }

.play-btn-text {
  font-family: var(--font);
  font-size: 0.7rem;
  color: var(--cyan);
  letter-spacing: 4px;
  text-shadow: var(--glow-c);
  animation: pulse 1.5s ease-in-out infinite;
}

/* Card info bar */
.card-info {
  padding: 12px 14px 14px;
  position: relative; z-index: 4;
  border-top: 1px solid var(--border);
}

.card-cat {
  font-size: 0.5rem;           /* was 0.38rem — that's ~6px, near invisible */
  color: var(--pink);
  letter-spacing: 2px;
  margin-bottom: 7px;
  text-shadow: 0 0 8px rgba(255,0,128,0.6);
}

.card-title {
  font-size: 0.58rem;          /* was 0.52rem */
  color: var(--text);
  letter-spacing: 1px;
  line-height: 1.7;
  margin-bottom: 8px;
  word-break: break-word;
}

.game-card:hover .card-title { color: var(--cyan); text-shadow: 0 0 8px rgba(0,229,255,0.5); }

.card-desc {
  font-family: 'Courier New', monospace;
  font-size: 12px;             /* was 10px */
  color: var(--dim2);          /* was --dim — much more legible */
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Corner decoration */
.card-corner {
  position: absolute;
  top: 0; right: 0;
  width: 24px; height: 24px;
  z-index: 5;
}

.card-corner::before,
.card-corner::after {
  content: '';
  position: absolute;
  background: var(--cyan);
}

.card-corner::before { top: 0; right: 0; width: 2px; height: 12px; }
.card-corner::after  { top: 0; right: 0; width: 12px; height: 2px; }

.game-card:hover .card-corner::before,
.game-card:hover .card-corner::after {
  background: var(--pink);
  box-shadow: 0 0 6px var(--pink);
}

/* ── Empty state ───────────────────────────────── */
#empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 80px 20px;
  text-align: center;
}

#empty-state.hidden { display: none; }

.empty-icon { font-size: 3.5rem; margin-bottom: 16px; animation: float 3s ease-in-out infinite; }

.empty-text {
  font-size: 0.65rem;
  color: var(--dim2);
  letter-spacing: 4px;
  margin-bottom: 10px;
}

.empty-sub {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: var(--dim);           /* was rgba(90,128,144,0.7) — near invisible */
}

/* ── Footer ticker ─────────────────────────────── */
#footer {
  flex-shrink: 0;
  border-top: 1px solid rgba(0,229,255,0.08);
  padding: 8px 0;
  overflow: hidden;
  position: relative; z-index: 20;
  background: rgba(0,0,0,0.4);
}

#ticker {
  display: inline-block;
  white-space: nowrap;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--dim);           /* --dim is now #7ec8dd — readable */
  letter-spacing: 3px;
  animation: ticker-scroll 30s linear infinite;
  padding-left: 100%;
}

/* ── Animations ────────────────────────────────── */
@keyframes scanroll {
  from { background-position: 0 0; }
  to   { background-position: 0 100px; }
}

@keyframes flicker {
  0%,90%,100% { opacity: 1; }
  91%          { opacity: 0.8; }
  92%          { opacity: 1; }
  93%          { opacity: 0.5; }
  94%          { opacity: 1; }
}

@keyframes float {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-6px); }
}

@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%     { opacity: 0.7; transform: scale(0.97); }
}

@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}

@keyframes blink {
  0%,100% { opacity: 1; }
  50%     { opacity: 0; }
}

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

/* ── Pixel-art selection flash ─────────────────── */
@keyframes pixel-flash {
  0%,100% { filter: brightness(1); }
  50%     { filter: brightness(2) saturate(2); }
}

.card-flash { animation: pixel-flash 0.12s steps(1) 3; }

/* ── Game Detail Modal ─────────────────────────── */
#modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 0, 15, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 24px;
}

#modal-overlay.hidden { display: none; }

#modal-card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(900px, 100%);
  max-height: 90vh;
  background: rgba(6, 0, 22, 0.96);
  border: 1px solid var(--cyan);
  box-shadow:
    0 0 0 1px rgba(0,229,255,0.15),
    0 0 40px rgba(0,229,255,0.2),
    0 0 80px rgba(0,229,255,0.08),
    0 32px 80px rgba(0,0,0,0.7);
  overflow: hidden;
}

/* Close button */
#modal-close {
  position: absolute; top: 14px; right: 16px; z-index: 10;
  background: transparent;
  border: 1px solid rgba(0,229,255,0.3);
  color: var(--dim2);
  font-family: var(--font);
  font-size: 0.7rem;
  width: 34px; height: 34px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  line-height: 1;
}

#modal-close:hover {
  border-color: var(--pink);
  color: var(--pink);
  box-shadow: 0 0 10px rgba(255,0,128,0.4);
}

/* Big preview side */
#modal-thumb {
  position: relative;
  background: #030010;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  display: flex; align-items: center; justify-content: center;
  border-right: 1px solid var(--border);
}

#modal-img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  filter: brightness(0.9) saturate(1.2);
}

#modal-no-thumb {
  font-family: var(--font);
  font-size: 0.55rem;
  color: var(--dim2);
  letter-spacing: 2px;
  text-align: center;
  line-height: 2.5;
}

#modal-no-thumb .no-thumb-icon { font-size: 3.5rem; display: block; margin-bottom: 12px; }

#modal-no-thumb.hidden { display: none; }

.modal-scanlines {
  position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(
    to bottom, transparent 0, transparent 2px,
    rgba(0,0,0,0.14) 2px, rgba(0,0,0,0.14) 3px
  );
}

/* Info panel side */
#modal-info {
  display: flex; flex-direction: column;
  padding: 36px 32px 28px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  gap: 14px;
}

#modal-info::-webkit-scrollbar { width: 4px; }
#modal-info::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

#modal-cat {
  font-size: 0.55rem;
  color: var(--pink);
  letter-spacing: 3px;
  text-shadow: 0 0 8px rgba(255,0,128,0.6);
}

#modal-title {
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--cyan);
  letter-spacing: 2px;
  line-height: 1.8;
  text-shadow: var(--glow-c);
  margin: 0;
  word-break: break-word;
}

#modal-desc {
  font-family: 'Courier New', monospace;
  font-size: 16px;
  color: var(--text);
  line-height: 1.8;
  flex: 1;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Action buttons */
#modal-actions {
  display: flex;
  gap: 14px;
  margin-top: auto;
  flex-wrap: wrap;
}

#modal-play {
  flex: 1;
  font-family: var(--font);
  font-size: 0.58rem;
  letter-spacing: 3px;
  padding: 14px 20px;
  background: transparent;
  border: 2px solid var(--cyan);
  color: var(--cyan);
  cursor: pointer;
  text-shadow: var(--glow-c);
  box-shadow: var(--glow-c), inset 0 0 20px rgba(0,229,255,0.06);
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

#modal-play::before {
  content: '';
  position: absolute; inset: 0;
  background: var(--cyan);
  opacity: 0;
  transition: opacity 0.2s;
}

#modal-play:hover {
  color: #000;
  text-shadow: none;
  box-shadow: 0 0 24px rgba(0,229,255,0.6), inset 0 0 40px rgba(0,229,255,0.3);
}

#modal-play:hover::before { opacity: 1; }
#modal-play span { position: relative; z-index: 1; }


/* Corner accent on modal card */
#modal-card::before,
#modal-card::after {
  content: '';
  position: absolute;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  z-index: 10;
}

#modal-card::before { top: 0; left: 0; width: 40px; height: 2px; }
#modal-card::after  { top: 0; left: 0; width: 2px; height: 40px; }

/* ── Responsive ────────────────────────────────── */
@media (max-width: 700px) {
  #modal-card { grid-template-columns: 1fr; }
  #modal-thumb { aspect-ratio: 16 / 9; border-right: none; border-bottom: 1px solid var(--border); }
  #modal-info { padding: 24px 20px 20px; }
  #modal-title { font-size: 0.62rem; }
}

@media (max-width: 600px) {
  #header { padding: 10px 14px 10px; flex-wrap: wrap; gap: 10px; }
  #header-left, #header-right { flex-wrap: wrap; gap: 8px; }
  .logo-title { font-size: 0.58rem; }
  .cat-btn { font-size: 0.46rem; }
  #categories { padding: 8px 14px; }
  #grid-wrap { padding: 16px 14px 20px; }
  #game-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
  #search { width: 120px; }
}
