/* ============================================================
   Need for Speed III - Hot Pursuit | Cinematic launch screen
   Full-bleed chase artwork + floating dark glass panel.
   Sections: tokens | base | atmosphere | hero | glass panel
   | meta | title | description | CTA | controls | states
   | footer | transitions | emulator | modal | responsive
   | short screens | reduced motion
   ============================================================ */

/* ---------- tokens ---------- */
:root {
  --bg-deep: #050609;

  --glass-bg: rgba(5, 6, 9, 0.78);
  --glass-border: rgba(255, 255, 255, 0.14);
  --glass-inner: rgba(255, 255, 255, 0.04);

  --text-main: #f4f4f2;
  --text-soft: rgba(255, 255, 255, 0.70);
  --text-dim: rgba(255, 255, 255, 0.55);
  --text-faint: rgba(255, 255, 255, 0.40);

  --accent-orange: #ff8a3a;
  --accent-red: #ef4421;
  --accent-red-deep: #c51f14;
  --accent-ember: #8e100c;
  --cta-glow: rgba(255, 64, 25, 0.28);

  --police-blue: rgba(40, 100, 255, 0.11);
  --police-red: rgba(255, 35, 25, 0.13);

  --key-bg: rgba(255, 255, 255, 0.035);
  --key-border: rgba(255, 255, 255, 0.24);

  --font-condensed: "Arial Narrow", "Helvetica Neue Condensed", "Roboto Condensed", "Arial Narrow", Arial, sans-serif;
  --font-mono: "Consolas", "SF Mono", "Menlo", monospace;
  --font-body: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
}

.app-root {
  width: 100vw;
  height: 100vh;
  position: relative;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

:focus-visible {
  outline: 2px solid rgba(255, 179, 64, 0.9);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- splash root ---------- */
.splash-screen {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 10;
  background: var(--bg-deep);
}

/* ---------- layer 1: atmospheric background ---------- */
.bg-base {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
  background: var(--bg-deep);
}

.bg-blur {
  position: absolute;
  inset: -40px;
  background-image: url('/assets/loginimage.webp');
  background-size: cover;
  background-position: center 25%;
  filter: blur(24px) brightness(0.24) saturate(0.85);
  transform: scale(1.12);
  opacity: 0.75;
}

/* very light police light ambience */
.bg-police-blue {
  position: absolute;
  left: 22%;
  top: 38%;
  width: 34vw;
  height: 40vh;
  background: radial-gradient(circle, var(--police-blue) 0%, transparent 70%);
  filter: blur(110px);
  animation: policeBreath 4.2s ease-in-out infinite;
}

.bg-police-red {
  position: absolute;
  left: 42%;
  top: 52%;
  width: 36vw;
  height: 42vh;
  background: radial-gradient(circle, var(--police-red) 0%, transparent 70%);
  filter: blur(130px);
  animation: policeBreath 4.2s ease-in-out infinite reverse;
}

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

.bg-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 105% at 50% 45%, transparent 52%, rgba(0, 0, 0, 0.6) 100%);
}

/* ---------- layer 2: sharp chase hero ---------- */
.hero-media {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 60vw;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
  background: var(--bg-deep);
}

.hero-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 8%;
  -webkit-mask-image: linear-gradient(
    90deg,
    #000 0%,
    #000 58%,
    rgba(0, 0, 0, 0.90) 70%,
    rgba(0, 0, 0, 0.55) 82%,
    transparent 100%
  );
  mask-image: linear-gradient(
    90deg,
    #000 0%,
    #000 58%,
    rgba(0, 0, 0, 0.90) 70%,
    rgba(0, 0, 0, 0.55) 82%,
    transparent 100%
  );
}

/* left-to-right melt: image -> dark -> panel, no hard seam */
.hero-fade {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    transparent 42%,
    rgba(5, 6, 9, 0.15) 56%,
    rgba(5, 6, 9, 0.70) 76%,
    var(--bg-deep) 100%
  );
}

.hero-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, rgba(5, 6, 9, 0.55), transparent 30%),
    radial-gradient(120% 90% at 30% 40%, transparent 55%, rgba(0, 0, 0, 0.4) 100%);
}

/* ---------- launch wrap + floating glass panel ---------- */
.launch-wrap {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  padding-right: clamp(24px, 3.3vw, 58px);
  padding-left: 40vw;
  padding-top: 20px;
  padding-bottom: 8px;
}

.glass-panel {
  width: min(620px, 43vw);
  max-height: calc(100dvh - 44px);
  overflow-y: auto;
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(115%);
  -webkit-backdrop-filter: blur(20px) saturate(115%);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.55),
    inset 0 1px var(--glass-inner);
  padding: 40px 42px 30px;
}

.panel-state {
  display: flex;
  flex-direction: column;
}

/* ---------- meta ---------- */
.meta-row {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.74);
  margin-bottom: 22px;
  white-space: nowrap;
}

.meta-divider {
  width: 26px;
  height: 1px;
  background: rgba(255, 255, 255, 0.28);
}

/* ---------- title ---------- */
.game-title {
  margin-bottom: 14px;
}

.game-title-main {
  display: block;
  font-family: var(--font-condensed);
  font-size: clamp(46px, 4.1vw, 64px);
  font-weight: 900;
  font-style: italic;
  line-height: 0.95;
  letter-spacing: -0.035em;
  color: #f4f4f2;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.5);
  transform: skewX(-4deg);
  transform-origin: left;
}

.game-title-sub {
  display: block;
  font-family: var(--font-condensed);
  font-size: clamp(78px, 6.4vw, 96px);
  font-weight: 900;
  font-style: italic;
  line-height: 0.84;
  letter-spacing: -0.045em;
  background: linear-gradient(180deg, #ff8a3a 0%, #ef4421 34%, #c51f14 67%, #8e100c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 4px 24px rgba(238, 53, 24, 0.22));
}

/* ---------- description ---------- */
.game-subtitle {
  font-size: 17px;
  line-height: 1.5;
  color: var(--text-soft);
  margin-bottom: 24px;
  max-width: 30rem;
}

/* ---------- CTA ---------- */
.action-area {
  margin-bottom: 14px;
}

.btn-primary {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  height: 86px;
  padding: 0 42px 0 34px;
  font-family: var(--font-condensed);
  font-size: 34px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #ffffff;
  background: linear-gradient(110deg, #8e1008 0%, #da2916 48%, #f24b21 100%);
  border: none;
  cursor: pointer;
  clip-path: polygon(5% 0, 100% 0, 95% 100%, 0 100%);
  box-shadow: 0 0 28px var(--cta-glow);
  transition: transform 0.18s var(--ease-out), filter 0.18s ease, box-shadow 0.18s ease;
}

.btn-primary .btn-arrow {
  font-size: 0.85em;
  line-height: 1;
  transition: transform 0.2s var(--ease-out);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.08);
  box-shadow: 0 0 40px rgba(255, 64, 25, 0.38);
}

.btn-primary:hover:not(:disabled) .btn-arrow {
  transform: translateX(6px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  filter: brightness(0.96);
}

.btn-primary:disabled {
  opacity: 0.55;
  pointer-events: none;
  filter: saturate(0.7);
}

.btn-primary:focus-visible {
  outline: none;
  filter: drop-shadow(0 0 0 3px rgba(255, 179, 64, 0.9));
}

/* ---------- CTA hint ---------- */
.cta-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-faint);
  margin-bottom: 22px;
}

.cta-hint b {
  color: var(--accent-red);
  font-weight: 700;
}

/* ---------- controls ---------- */
.controls-section {
  padding-top: 18px;
}

.controls-rule {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin-bottom: 18px;
}

.controls-primary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  margin-bottom: 12px;
}

.ctl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-soft);
  white-space: nowrap;
}

.ctl .key-cap + .key-cap {
  margin-left: -8px;
}

.key-cap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 7px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  background: var(--key-bg);
  border: 1px solid var(--key-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}

.controls-secondary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.controls-secondary .key-cap {
  min-height: 28px;
  padding: 0 9px;
  font-size: 11px;
}

.controls-secondary b {
  color: var(--accent-red);
  font-weight: 700;
}

/* ---------- loading state ---------- */
.panel-status {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 26px 0 18px;
  gap: 20px;
}

.spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent-red);
  border-right-color: var(--accent-orange);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-kicker {
  font-family: var(--font-condensed);
  font-size: 26px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.08em;
  color: var(--accent-red);
  text-transform: uppercase;
}

.status-steps {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.step {
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-faint);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
  transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.step.active {
  color: var(--text-main);
  background: rgba(255, 59, 48, 0.14);
  border-color: rgba(255, 59, 48, 0.4);
}

.step.done {
  color: var(--accent-orange);
}

/* ---------- error state ---------- */
.panel-error {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 20px 0 10px;
}

.error-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 1.4rem;
  color: var(--accent-red);
  background: rgba(255, 35, 25, 0.12);
  border: 1px solid rgba(255, 35, 25, 0.35);
}

.error-title {
  font-family: var(--font-condensed);
  font-size: 30px;
  font-weight: 900;
  font-style: italic;
  color: var(--text-main);
}

.error-message {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text-dim);
  max-width: 24rem;
}

.btn-retry {
  height: 64px;
  font-size: 24px;
  margin-top: 6px;
}

/* ---------- panel dim during launch ---------- */
.panel-idle {
  transition: opacity 0.35s ease, filter 0.35s ease, transform 0.35s ease;
}

.panel-idle.panel-dim {
  opacity: 0.3;
  filter: blur(2px);
  pointer-events: none;
  transform: scale(0.995);
}

/* ---------- footer ---------- */
.splash-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 8px 10px;
  font-size: 12px;
  color: var(--text-faint);
}

.splash-footer .dot {
  opacity: 0.6;
}

.link-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12.5px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s ease;
}

.link-btn:hover {
  color: var(--text-main);
}

/* ---------- transitions ---------- */
.splash-screen.splash-done {
  animation: splashOut 0.45s var(--ease-out) forwards;
}

@keyframes splashOut {
  to {
    opacity: 0;
    filter: blur(10px);
    transform: scale(1.04);
    visibility: hidden;
  }
}

/* ---------- emulator stage ---------- */
.emulator-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000000;
  display: flex;
  flex-direction: column;
  z-index: 5;
  opacity: 1;
  transition: opacity 0.45s var(--ease-out);
  animation: emulatorIn 0.4s var(--ease-out);
}

/* pre-loader staging: measurable size (100vw x 100vh) but invisible; the
   splash (z-index 10) covers it until EJS_ready reveals the game */
.emulator-wrapper.pre-stage {
  opacity: 0;
  pointer-events: none;
  animation: none;
}

@keyframes emulatorIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.game-canvas-area {
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.game-canvas-area iframe,
.game-canvas-area canvas,
.game-canvas-area #ejs-parent-container {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain !important;
}

.overlay-toolbar {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 6px 16px;
  background: rgba(15, 15, 20, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 30px;
  opacity: 0.25;
  transition: opacity 0.3s ease;
}

.overlay-toolbar:hover {
  opacity: 1;
}

.toolbar-brand {
  font-family: var(--font-condensed);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--text-dim);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tb-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-main);
  padding: 5px 10px;
  border-radius: 14px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.tb-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.tb-btn.warning:hover {
  background: rgba(239, 68, 68, 0.4);
}

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-card {
  background: #0c0e13;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.7);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.modal-header h2 {
  font-family: var(--font-condensed);
  font-size: 1.35rem;
  font-weight: 900;
  font-style: italic;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  transition: color 0.2s ease;
}

.close-btn:hover {
  color: var(--text-main);
}

.control-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.control-row .key-cap {
  min-width: 4.6em;
}

.action-desc {
  font-size: 0.85rem;
  color: var(--text-dim);
  text-align: right;
}

.save-state-note {
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--text-faint);
  line-height: 1.4;
}

/* ---------- responsive: tablet / mobile ---------- */
@media (max-width: 1100px) {
  .glass-panel {
    width: min(560px, 50vw);
  }
}

@media (max-width: 900px) {
  /* hero becomes a top band with vertical fade */
  .hero-media {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 40svh;
    bottom: auto;
  }

  .hero-image {
    object-position: 50% 15%;
    -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 58%, rgba(0, 0, 0, 0.6) 82%, transparent 100%);
    mask-image: linear-gradient(to bottom, #000 0%, #000 58%, rgba(0, 0, 0, 0.6) 82%, transparent 100%);
  }

  .hero-fade {
    background: linear-gradient(to bottom, transparent 30%, rgba(5, 6, 9, 0.55) 70%, var(--bg-deep) 100%);
  }

  .launch-wrap {
    align-items: stretch;
    padding: 0;
    padding-top: 38svh;
    min-height: 100dvh;
    justify-content: flex-start;
  }

  .glass-panel {
    width: 100%;
    max-height: none;
    border-radius: 24px 24px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    padding: 30px 24px 26px;
  }

  .splash-footer {
    padding-bottom: 14px;
  }

  .game-title-main {
    font-size: clamp(34px, 9vw, 42px);
  }

  .game-title-sub {
    font-size: clamp(50px, 13vw, 62px);
  }

  .btn-primary {
    height: 70px;
    font-size: 26px;
  }
}

@media (max-width: 520px) {
  .controls-primary {
    gap: 8px 12px;
  }

  .controls-secondary {
    gap: 6px 10px;
  }

  .cta-hint {
    gap: 8px;
    font-size: 12px;
  }
}

/* ---------- short screens (1366x768 laptops etc.) ---------- */
@media (max-height: 820px) {
  .glass-panel {
    padding: 26px 34px 20px;
    max-height: calc(100dvh - 36px);
  }

  .meta-row {
    margin-bottom: 14px;
  }

  .game-title-main {
    font-size: clamp(38px, 3.6vw, 48px);
  }

  .game-title-sub {
    font-size: clamp(60px, 5.4vw, 72px);
  }

  .game-subtitle {
    font-size: 15px;
    margin-bottom: 14px;
  }

  .btn-primary {
    height: 70px;
    font-size: 27px;
  }

  .cta-hint {
    margin-bottom: 14px;
    font-size: 12px;
  }

  .controls-section {
    padding-top: 12px;
  }

  .controls-rule {
    margin-bottom: 12px;
  }

  .controls-primary {
    gap: 8px 14px;
    margin-bottom: 8px;
  }

  .key-cap {
    min-height: 32px;
    padding: 0 10px;
    font-size: 12px;
  }

  .controls-secondary .key-cap {
    min-height: 26px;
    padding: 0 8px;
    font-size: 10.5px;
  }

  .splash-footer {
    padding: 10px 8px 8px;
  }
}

/* ---------- ultrawide ---------- */
@media (min-width: 1800px) {
  .hero-media {
    width: min(60vw, 1160px);
  }

  .glass-panel {
    width: min(620px, 43vw, 700px);
  }

  .launch-wrap {
    padding-left: 46vw;
  }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .bg-police-blue,
  .bg-police-red,
  .spinner {
    animation: none !important;
  }

  .splash-screen.splash-done,
  .emulator-wrapper,
  .panel-idle,
  .btn-primary,
  .btn-primary .btn-arrow {
    transition: none !important;
    animation: none !important;
  }
}
