@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=VT323&display=swap');

/* ============================================================
   TOKENS
   ============================================================ */
:root {
  /* PS2 BIOS palette — deep navy void + ice-blue glow + a single
     hazard-amber accent reserved for warnings/active states */
  --void:         #01040a;
  --deep-1:       #050f1e;
  --deep-2:       #081a30;
  --steel:        #16324f;
  --steel-line:   #2a4c6e;
  --ice:          #7fd3ff;
  --ice-bright:   #cdf1ff;
  --ice-dim:      #4c88a8;
  --ghost:        #8fa3b8;
  --paper:        #eaf6ff;
  --hazard:       #ffb020;
  --danger:       #ff5f6d;

  --panel-bg:     rgba(4, 14, 27, 0.82);
  --panel-border: rgba(127, 211, 255, 0.28);
  --glass-hi:     rgba(127, 211, 255, 0.06);

  --font-display: 'VT323', monospace;
  --font-mono:    'Share Tech Mono', monospace;

  --radius: 2px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--void);
  color: var(--paper);
  font-family: var(--font-mono);
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* ============================================================
   BACKGROUND CANVAS (Three.js BIOS shapes live behind everything)
   ============================================================ */
#bios-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  background: radial-gradient(ellipse 90% 70% at 50% 40%, var(--deep-2) 0%, var(--deep-1) 55%, var(--void) 100%);
}

/* ============================================================
   CRT OVERLAY STACK
   ============================================================ */
.crt-scanlines,
.crt-mask,
.crt-vignette,
.crt-flicker,
.crt-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

/* Horizontal scanlines */
.crt-scanlines {
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0.16) 1px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0) 3px
  );
  mix-blend-mode: multiply;
  opacity: 0.55;
}

/* Faint RGB subpixel / chromatic aberration mask at the edges */
.crt-mask {
  background:
    radial-gradient(ellipse 60% 60% at 49.7% 50%, rgba(255, 60, 60, 0.05), transparent 70%),
    radial-gradient(ellipse 60% 60% at 50.3% 50%, rgba(60, 120, 255, 0.05), transparent 70%);
  mix-blend-mode: screen;
}

/* Screen curvature illusion via vignette */
.crt-vignette {
  background: radial-gradient(ellipse 78% 78% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
  box-shadow: inset 0 0 180px 60px rgba(0, 0, 0, 0.85);
}

/* Subtle flicker */
.crt-flicker {
  background: var(--ice);
  opacity: 0;
  animation: flicker 6.5s infinite;
}
@keyframes flicker {
  0%, 96%, 100% { opacity: 0; }
  97% { opacity: 0.02; }
  97.5% { opacity: 0; }
  98.2% { opacity: 0.035; }
  98.6% { opacity: 0; }
}

/* Faint animated noise grain */
.crt-noise {
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: noiseShift 0.4s steps(2) infinite;
}
@keyframes noiseShift {
  0%   { transform: translate(0,0); }
  50%  { transform: translate(-1%, 1%); }
  100% { transform: translate(1%, -1%); }
}

/* ============================================================
   CONSOLE FRAME — floats a 4:3-honoring terminal in a dark void
   ============================================================ */
.console-frame {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.console-screen {
  position: relative;
  width: min(1180px, 96vw);
  min-height: min(820px, 88vh);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--steel-line);
  border-radius: 3px;
  background: linear-gradient(180deg, rgba(6, 20, 38, 0.55), rgba(2, 8, 16, 0.7));
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.6),
    0 0 60px rgba(127, 211, 255, 0.08),
    0 30px 80px rgba(0, 0, 0, 0.6),
    inset 0 0 40px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.console-frame-label {
  margin-top: 14px;
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 2px;
  color: var(--ice-dim);
  opacity: 0.75;
  text-align: center;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--steel-line);
  background: linear-gradient(180deg, rgba(127, 211, 255, 0.05), transparent);
}

.logo-mark {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 2px;
  color: var(--ice);
  text-shadow: 0 0 8px rgba(127, 211, 255, 0.5);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.15;
  font-family: var(--font-display);
}

#clock-time {
  font-size: 24px;
  color: var(--paper);
  letter-spacing: 1px;
}

#clock-date {
  font-size: 13px;
  color: var(--ghost);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--ghost);
  letter-spacing: 0.5px;
}

/* ============================================================
   SCREENS
   ============================================================ */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 20px;
  width: 100%;
  position: relative;
}

/* ---------- Panel (memory-card block styling) ---------- */
.panel {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: var(--panel-bg);
  padding: 26px 26px 22px;
  width: 100%;
  position: relative;
}

/* corner ticks — evokes memory-card slot brackets */
.panel::before, .panel::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid var(--ice);
  opacity: 0.7;
}
.panel::before { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.panel::after  { bottom: -1px; right: -1px; border-left: none; border-top: none; }

.auth-panel {
  max-width: 400px;
  margin-top: 36px;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 19px;
  letter-spacing: 1px;
  color: var(--ice-bright);
  margin-bottom: 18px;
  text-shadow: 0 0 6px rgba(127, 211, 255, 0.4);
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  margin-bottom: 20px;
  border: 1px solid var(--panel-border);
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-right: 1px solid var(--panel-border);
  color: var(--ghost);
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 10px;
  cursor: pointer;
  letter-spacing: 1px;
  font-size: 12px;
  transition: background 0.05s, color 0.05s;
}
.tab-btn:last-child { border-right: none; }

.tab-btn.active {
  background: var(--ice);
  color: var(--void);
}

.tab-btn:hover:not(.active) {
  background: rgba(127, 211, 255, 0.12);
  color: var(--ice-bright);
}

.tab-content { display: none; flex-direction: column; gap: 6px; }
.tab-content.active { display: flex; }

label {
  font-size: 11px;
  color: var(--ghost);
  letter-spacing: 1.5px;
  margin-top: 8px;
  text-transform: uppercase;
}

input[type="text"], input[type="password"] {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--panel-border);
  border-radius: 0;
  color: var(--ice-bright);
  font-family: var(--font-mono);
  font-size: 15px;
  padding: 10px 12px;
  outline: none;
}

input:focus {
  border-color: var(--ice);
  box-shadow: 0 0 0 2px rgba(127, 211, 255, 0.25);
}

/* ---------- Buttons: chunky, tactile, low-poly block feel ---------- */
.btn {
  font-family: var(--font-mono);
  font-weight: 700;
  background: linear-gradient(180deg, var(--steel), #0c2036);
  border: 1px solid var(--steel-line);
  border-radius: 0;
  color: var(--paper);
  padding: 11px 18px;
  cursor: pointer;
  letter-spacing: 1px;
  font-size: 13px;
  margin-top: 14px;
  position: relative;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 3px 0 rgba(0,0,0,0.5);
  transition: transform 0.04s linear, box-shadow 0.04s linear, background 0.05s, color 0.05s;
}

.btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 0 0 rgba(0,0,0,0.5);
}

.btn:hover:not(:disabled) {
  background: var(--ice);
  color: var(--void);
  border-color: var(--ice-bright);
}

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

.btn-primary {
  width: 100%;
  background: linear-gradient(180deg, var(--ice-dim), #0d3552);
  border-color: var(--ice);
}
.btn-primary:hover:not(:disabled) { background: var(--ice); color: var(--void); }

.btn-ghost {
  background: transparent;
  color: var(--ghost);
  box-shadow: none;
  border-color: var(--panel-border);
}
.btn-ghost:hover { background: rgba(127,211,255,0.12); color: var(--ice-bright); }

.message {
  min-height: 18px;
  font-size: 12px;
  margin-top: 12px;
  color: var(--hazard);
  letter-spacing: 0.5px;
}
.message.error { color: var(--danger); }

/* ============================================================
   XMB-STYLE CAROUSEL (dashboard)
   ============================================================ */
#dashboard-screen, #emulator-screen { max-width: 1100px; margin: 0 auto; align-items: stretch; }

.xmb {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin-top: 8vh;
}

.xmb-category {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--ghost);
  margin-bottom: 4px;
}

.system-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  justify-content: center;
}

.system-tab {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--ghost);
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 7px 16px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.system-tab:hover:not(.active):not(:disabled) {
  border-color: var(--ice);
  color: var(--ice-bright);
}

.system-tab.active {
  background: var(--ice);
  border-color: var(--ice);
  color: var(--void);
}

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

.xmb-carousel-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 960px;
}

.xmb-carousel {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 30px;
  padding: 30px 10px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.xmb-carousel::-webkit-scrollbar { display: none; }

.game-card {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  opacity: 0.5;
  transform: scale(0.8) perspective(400px) rotateY(0deg);
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.game-card .icon {
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  background: linear-gradient(160deg, var(--steel), #061523);
  border: 1px solid var(--steel-line);
  color: var(--ice);
  clip-path: polygon(12% 0, 100% 0, 100% 88%, 88% 100%, 0 100%, 0 12%);
}

.game-card .size {
  font-size: 10px;
  color: var(--ghost);
  letter-spacing: 1px;
}
.game-card .name { display: none; }

.game-card.selected {
  opacity: 1;
  transform: scale(1.18);
}

.game-card.selected .icon {
  border-color: var(--ice);
  color: var(--ice-bright);
  box-shadow: 0 0 0 2px rgba(127,211,255,0.3), 0 0 22px rgba(127,211,255,0.35);
}

.carousel-arrow {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid var(--panel-border);
  border-radius: 0;
  color: var(--ice-bright);
  width: 38px;
  height: 38px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.05s, color 0.05s;
}
.carousel-arrow:hover { background: var(--ice); color: var(--void); }

.xmb-title-display {
  margin-top: 16px;
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: 1px;
  color: var(--paper);
  min-height: 30px;
  text-shadow: 0 0 10px rgba(127, 211, 255, 0.45);
}

.xmb-hint {
  margin-top: 10px;
  font-size: 11px;
  color: var(--ghost);
  opacity: 0.75;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ============================================================
   EMULATOR SCREEN
   ============================================================ */
.emu-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.emu-title {
  font-family: var(--font-display);
  color: var(--ice-bright);
  font-size: 20px;
  letter-spacing: 1px;
}
.emu-actions { display: flex; gap: 8px; }

.emu-progress { width: 100%; margin-bottom: 10px; }
.emu-progress-label {
  font-size: 11px;
  color: var(--hazard);
  margin-bottom: 6px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.emu-progress-bar {
  width: 100%;
  height: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(0,0,0,0.4);
  overflow: hidden;
}
.emu-progress-fill {
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(
    90deg, var(--ice) 0px, var(--ice) 8px, var(--ice-dim) 8px, var(--ice-dim) 16px
  );
  transition: width 0.2s;
}

.game-container {
  width: 100%;
  min-height: 440px;
  border: 1px solid var(--panel-border);
  background: #000;
  overflow: hidden;
}

/* ============================================================
   STATUS BAR
   ============================================================ */
.statusbar {
  border-top: 1px solid var(--steel-line);
  padding: 8px 18px;
  font-size: 12px;
  color: var(--ghost);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 1px;
  background: rgba(0,0,0,0.25);
}
.statusbar-icon { color: var(--ice); }

.bundler-link {
  margin-left: auto;
  color: var(--ice-dim);
  text-decoration: none;
  font-size: 11px;
  letter-spacing: 1px;
}
.bundler-link:hover { color: var(--ice); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  .console-screen { min-height: 92vh; }
  .emu-toolbar { justify-content: center; text-align: center; }
  .xmb { margin-top: 4vh; }
  .game-card .icon { width: 68px; height: 68px; font-size: 26px; }
  .xmb-title-display { font-size: 20px; }
  #clock-time { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  .crt-flicker, .crt-noise { animation: none; }
  .ps2-waves { animation: none; }
}