/* ===== CSS Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Share+Tech+Mono&family=Orbitron:wght@400;700;900&display=swap');

:root {
  --bg-dark: #0a0a0f;
  --bg-panel: #111118;
  --bg-card: #1a1a24;
  --accent-cyan: #00f0ff;
  --accent-magenta: #ff00aa;
  --accent-green: #39ff14;
  --accent-amber: #ffaa00;
  --text-primary: #e0e0e8;
  --text-dim: #6a6a7a;
  --glow-cyan: 0 0 10px rgba(0, 240, 255, 0.3), 0 0 30px rgba(0, 240, 255, 0.1);
  --glow-magenta: 0 0 10px rgba(255, 0, 170, 0.3), 0 0 30px rgba(255, 0, 170, 0.1);
  --border-subtle: 1px solid rgba(255, 255, 255, 0.06);
  --crt-curve: 8px;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Share Tech Mono', monospace;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(0, 240, 255, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(255, 0, 170, 0.03) 0%, transparent 50%);
}

/* ===== Header ===== */
.header {
  width: 100%;
  max-width: 1000px;
  padding: 28px 20px 0;
  text-align: center;
}

.title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 2.4rem;
  letter-spacing: 6px;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(0, 240, 255, 0.25));
  margin-bottom: 4px;
  animation: titlePulse 4s ease-in-out infinite;
}

@keyframes titlePulse {
  0%, 100% { filter: drop-shadow(0 0 20px rgba(0, 240, 255, 0.25)); }
  50% { filter: drop-shadow(0 0 35px rgba(255, 0, 170, 0.35)); }
}

.subtitle {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 4px;
  text-transform: uppercase;
}

.subtitle span {
  color: var(--accent-green);
  text-shadow: 0 0 6px rgba(57, 255, 20, 0.4);
}

/* ===== CRT Monitor Frame ===== */
.crt-wrapper {
  position: relative;
  margin: 20px auto;
  padding: 16px;
  background: linear-gradient(145deg, #1e1e28, #14141c);
  border-radius: 18px;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.04),
    0 8px 40px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.crt-bezel {
  position: relative;
  border-radius: var(--crt-curve);
  overflow: hidden;
  box-shadow:
    inset 0 0 60px rgba(0, 0, 0, 0.5),
    0 0 3px rgba(0, 240, 255, 0.15);
}

/* CRT Scanlines */
.crt-bezel::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.12) 0px,
    rgba(0, 0, 0, 0.12) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  z-index: 10;
  mix-blend-mode: multiply;
}

/* CRT Flicker */
.crt-bezel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    180deg,
    rgba(0, 240, 255, 0.01) 0%,
    transparent 8%,
    transparent 92%,
    rgba(0, 240, 255, 0.01) 100%
  );
  pointer-events: none;
  z-index: 11;
  animation: crtFlicker 0.1s infinite alternate;
}

@keyframes crtFlicker {
  0% { opacity: 0.97; }
  100% { opacity: 1; }
}

/* js-dos container */
#dos-container {
  width: 740px;
  height: 480px;
  background: #000;
  border-radius: var(--crt-curve);
  position: relative;
}

/* Override js-dos default styles for clean integration */
#dos-container .emulator-mouse-overlay {
  cursor: none !important;
}

/* Power LED */
.power-led {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 0 4px;
}

.led-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green), 0 0 12px rgba(57, 255, 20, 0.3);
  animation: ledBlink 3s ease-in-out infinite;
}

@keyframes ledBlink {
  0%, 90%, 100% { opacity: 1; }
  95% { opacity: 0.5; }
}

.led-label {
  font-size: 0.55rem;
  color: var(--text-dim);
  letter-spacing: 3px;
  text-transform: uppercase;
}

/* ===== Controls Info Panel ===== */
.info-panel {
  width: 100%;
  max-width: 772px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 0 auto 30px;
  padding: 0 16px;
}

.info-card {
  background: var(--bg-card);
  border: var(--border-subtle);
  border-radius: 10px;
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.info-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-cyan), transparent);
  opacity: 0.5;
}

.info-card.magenta::before {
  background: linear-gradient(90deg, var(--accent-magenta), transparent);
}

.info-card h3 {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent-cyan);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.info-card.magenta h3 {
  color: var(--accent-magenta);
}

.key-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.key-row:last-child {
  border-bottom: none;
}

.key-label {
  font-size: 0.75rem;
  color: var(--text-dim);
}

kbd {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.5rem;
  background: linear-gradient(180deg, #2a2a36, #1e1e28);
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 2px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
}

/* ===== Footer ===== */
.footer {
  width: 100%;
  max-width: 772px;
  text-align: center;
  padding: 0 16px 30px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  margin-top: auto;
}

.footer p {
  font-size: 0.65rem;
  color: var(--text-dim);
  letter-spacing: 2px;
  padding-top: 16px;
}

.footer .year {
  color: var(--accent-amber);
}

/* ===== Loading Screen ===== */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  border-radius: var(--crt-curve);
  transition: opacity 0.8s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-text {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.7rem;
  color: var(--accent-cyan);
  animation: loadBlink 1s steps(2) infinite;
  margin-bottom: 20px;
}

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

.loading-bar-track {
  width: 200px;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  width: 30%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-magenta));
  border-radius: 2px;
  animation: loadSlide 1.5s ease-in-out infinite;
}

@keyframes loadSlide {
  0% { transform: translateX(-100%); width: 30%; }
  50% { width: 60%; }
  100% { transform: translateX(400%); width: 30%; }
}

/* ===== Responsive ===== */
@media (max-width: 800px) {
  .title { font-size: 1.5rem; letter-spacing: 3px; }
  #dos-container { width: 100%; height: 0; padding-bottom: 64.8%; }
  .crt-wrapper { margin: 16px; padding: 10px; border-radius: 12px; }
  .info-panel { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .title { font-size: 1.1rem; }
  .crt-wrapper { margin: 10px; padding: 8px; }
}

/* ===== Soft Fullscreen (js-dos) ===== */
/* When active: game fills the entire viewport, all UI chrome hidden */
.jsdos-fullscreen-workaround body {
  overflow: hidden;
}

.jsdos-fullscreen-workaround .header,
.jsdos-fullscreen-workaround .info-panel,
.jsdos-fullscreen-workaround .footer,
.jsdos-fullscreen-workaround .power-led {
  display: none !important;
}

.jsdos-fullscreen-workaround .crt-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: #000;
  box-shadow: none;
  z-index: 9999;
}

.jsdos-fullscreen-workaround .crt-bezel {
  width: 100%;
  height: 100%;
  border-radius: 0;
  box-shadow: none;
}

.jsdos-fullscreen-workaround .crt-bezel::after,
.jsdos-fullscreen-workaround .crt-bezel::before {
  display: none;
}

.jsdos-fullscreen-workaround #dos-container {
  width: 100% !important;
  height: 100% !important;
  border-radius: 0;
}
