/* =============================================================
   Windows 98 Setup Challenge
   Recreates the look of DOS boot + Win98 setup.
   ============================================================= */

:root {
  --bg-deep: #06070a;
  --bg-desk: #3a6ea5;
  --bg-desk-2: #1f3e6b;

  --dos-bg: #000;
  --dos-fg: #d6d6c8;
  --dos-fg-dim: #6a6a60;
  --dos-accent: #55ff55;
  --dos-error: #ff6060;

  --win-bg: #c3c3c3;
  --win-bg-2: #d8d8d8;
  --win-bg-3: #ececec;
  --win-dark: #5a5a5a;
  --win-light: #ffffff;
  --win-mid: #808080;
  --win-shadow: #000000;
  --win-title-1: #07146a;
  --win-title-2: #1084d0;
  --win-text: #111111;
  --win-link: #0000a0;

  --danger: #c83838;
  --good: #2d8a2d;
  --warn: #c98a18;

  --font-dos: 'IBM Plex Mono', 'Courier New', monospace;
  --font-win: Tahoma, 'MS Sans Serif', Geneva, Verdana, sans-serif;
  --font-mono: 'Share Tech Mono', 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg-deep);
  color: var(--win-text);
  font-family: var(--font-win);
  font-size: 13px;
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

/* ----- Screen ----- */
.screen {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--dos-bg);
  transition: background 250ms ease;
  isolation: isolate;
}

.screen.win-mode {
  background: var(--win-bg);
}

/* Every phase is a full-screen layer. Only the active one is shown. */
.phase {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

.phase[hidden] { display: none; }
.hud[hidden] { display: none; }

/* ----- HUD (always-visible status bar in DOS mode) ----- */
.hud {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 10;
  display: flex;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  background: rgba(0, 0, 0, 0.55);
  color: #cfe6ff;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  text-shadow: 0 0 4px rgba(80, 160, 255, 0.4);
  pointer-events: none;
}
.hud-level { color: var(--dos-accent); }
.hud-errors { color: #ffaa55; }
.hud-time { color: #cfe6ff; }

/* ===========================================================
   START SCREEN
   =========================================================== */

.phase-start {
  background:
    radial-gradient(ellipse at 50% 50%, #2d4f7a 0%, #0b1c33 100%);
  align-items: center;
  justify-content: center;
}

.start-card {
  width: min(560px, 92vw);
  background: var(--win-bg);
  border-top: 2px solid var(--win-light);
  border-left: 2px solid var(--win-light);
  border-right: 2px solid var(--win-shadow);
  border-bottom: 2px solid var(--win-shadow);
  padding: 0;
  box-shadow:
    inset -1px -1px 0 var(--win-dark),
    inset 1px 1px 0 #eaeaea,
    4px 4px 0 rgba(0, 0, 0, 0.4);
}

.start-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: linear-gradient(180deg, var(--win-title-1) 0%, var(--win-title-2) 100%);
  color: white;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 13px;
}
.start-flag {
  display: inline-block;
  width: 14px;
  height: 14px;
  background:
    linear-gradient(135deg, transparent 50%, #ff5050 50%, #ff5050 60%, transparent 60%),
    linear-gradient(45deg, transparent 50%, #ff5050 50%, #ff5050 60%, transparent 60%);
  background-size: 100% 100%, 100% 100%;
  background-position: 0 0, 7px 7px;
  background-repeat: no-repeat;
  background-color: #ff5050;
}
.start-name {
  font-size: 16px;
  font-weight: 700;
}
.start-tag {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.18);
  padding: 2px 8px;
  border-radius: 2px;
}

.start-body {
  padding: 18px 22px 22px;
}
.start-body p { margin: 8px 0; }
.start-body b { color: #111; }
.start-rules {
  margin: 14px 0;
  padding-left: 18px;
}
.start-rules li {
  margin: 6px 0;
  line-height: 1.45;
}
.start-rules code {
  background: #fff;
  border: 1px solid #aaa;
  padding: 1px 5px;
  border-radius: 2px;
  font-family: var(--font-mono);
}

.start-btn {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 24px;
  background: var(--win-bg-2);
  border-top: 2px solid var(--win-light);
  border-left: 2px solid var(--win-light);
  border-right: 2px solid var(--win-dark);
  border-bottom: 2px solid var(--win-dark);
  font-size: 14px;
  font-weight: 600;
  color: #111;
}
.start-btn:active {
  border-top-color: var(--win-dark);
  border-left-color: var(--win-dark);
  border-right-color: var(--win-light);
  border-bottom-color: var(--win-light);
}

.start-mute {
  margin-top: 14px;
  font-size: 12px;
  color: var(--win-dark);
}

/* ===========================================================
   DOS MODE (boot + prompt + launch screens)
   =========================================================== */

.phase-dos { background: var(--dos-bg); color: var(--dos-fg); }

.dos-screen {
  flex: 1;
  padding: 24px 32px;
  font-family: var(--font-dos);
  font-size: 16px;
  line-height: 1.25;
  letter-spacing: 0.02em;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-shadow: 0 0 2px rgba(120, 200, 120, 0.18);
}

.dos-text {
  margin: 0;
  white-space: pre-wrap;
  font-size: 16px;
  line-height: 1.25;
  font-family: var(--font-dos);
}

.dos-input-row {
  display: flex;
  align-items: center;
  font-family: var(--font-dos);
  font-size: 16px;
  margin-top: 2px;
}

.dos-prompt {
  color: var(--dos-fg);
  margin-right: 4px;
  font-weight: 600;
}

.dos-input {
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--dos-fg);
  font-family: var(--font-dos);
  font-size: 16px;
  flex: 1;
  padding: 0;
  caret-color: transparent;
  text-shadow: 0 0 2px rgba(120, 200, 120, 0.18);
}

.dos-cursor {
  display: inline-block;
  width: 8px;
  margin-left: 1px;
  color: var(--dos-fg);
  animation: blink 1.05s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.success-line { color: var(--dos-accent); }
.error-line { color: var(--dos-error); }
.dim-line { color: var(--dos-fg-dim); }

/* ----- Drive picker HUD ----- */
.hud-drives {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  gap: 8px;
  z-index: 5;
}

.drive-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--win-bg-2);
  border-top: 2px solid var(--win-light);
  border-left: 2px solid var(--win-light);
  border-right: 2px solid var(--win-dark);
  border-bottom: 2px solid var(--win-dark);
  padding: 4px 8px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--win-text);
  text-align: left;
}
.drive-btn:disabled { opacity: 0.7; cursor: default; }
.drive-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5a0000;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.5);
}
.drive-led.lit { background: var(--dos-accent); box-shadow: 0 0 5px var(--dos-accent); }
.drive-label {
  font-weight: 700;
  font-size: 13px;
}
.drive-disk {
  color: var(--win-dark);
  font-size: 11px;
}

/* ----- Disk-insert prompt ----- */
.insert-card {
  position: absolute;
  bottom: 14%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--win-bg);
  border-top: 2px solid var(--win-light);
  border-left: 2px solid var(--win-light);
  border-right: 2px solid var(--win-shadow);
  border-bottom: 2px solid var(--win-shadow);
  padding: 12px 18px;
  text-align: center;
  z-index: 6;
  font-size: 13px;
}
.insert-card p { margin: 8px 0 0; }

.hint {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.55);
  color: #ddd;
  font-family: var(--font-mono);
  font-size: 13px;
  text-align: center;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  pointer-events: none;
  max-width: 90vw;
  line-height: 1.4;
}
.hint b { color: var(--dos-accent); }
.hint span { color: #888; }
.insert-disk {
  display: inline-block;
  background:
    linear-gradient(135deg, #fafafa 0%, #dadada 50%, #888 100%);
  width: 200px;
  height: 200px;
  border-radius: 50%;
  font-family: var(--font-dos);
  font-weight: 700;
  font-size: 13px;
  text-align: center;
  padding-top: 80px;
  color: #222;
  border: 2px solid #555;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.6);
  transition: transform 0.15s ease;
  position: relative;
}
.insert-disk::after {
  content: '';
  position: absolute;
  inset: 30%;
  border-radius: 50%;
  background: #444;
  border: 4px solid #aaa;
}
.insert-disk:active { transform: scale(0.98); }

/* ===========================================================
   WIN98 SETUP MODE
   =========================================================== */

.phase-win {
  background:
    linear-gradient(180deg, #5794ce 0%, #3a6ea5 60%, #2f5e92 100%);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.win-setup-window {
  width: min(640px, 96vw);
  max-height: 88vh;
  overflow: auto;
  background: var(--win-bg);
  border-top: 2px solid var(--win-light);
  border-left: 2px solid var(--win-light);
  border-right: 2px solid var(--win-shadow);
  border-bottom: 2px solid var(--win-shadow);
  padding: 0;
  box-shadow:
    inset -1px -1px 0 var(--win-dark),
    inset 1px 1px 0 #eaeaea,
    4px 4px 16px rgba(0, 0, 0, 0.45);
}

.setup-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, var(--win-title-1) 0%, var(--win-title-2) 100%);
  color: white;
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 700;
}

.setup-body {
  padding: 18px 22px;
  font-size: 13px;
  color: var(--win-text);
}
.setup-body p { margin: 8px 0; }

.setup-welcome h1 {
  margin: 8px 0 12px;
  font-size: 22px;
  font-weight: 700;
}

.setup-eula-wrap { margin: 12px 0; }
.eula-box {
  height: 170px;
  overflow: auto;
  background: white;
  border: 2px inset var(--win-mid);
  padding: 8px 12px;
  font-family: var(--font-dos);
  font-size: 12px;
  line-height: 1.35;
  white-space: pre-wrap;
  color: #111;
  outline: 0;
}
.eula-box::-webkit-scrollbar { width: 16px; }
.eula-box::-webkit-scrollbar-track { background: var(--win-bg); }
.eula-box::-webkit-scrollbar-thumb {
  background: var(--win-bg-2);
  border-top: 1px solid var(--win-light);
  border-left: 1px solid var(--win-light);
  border-right: 1px solid var(--win-dark);
  border-bottom: 1px solid var(--win-dark);
}

.setup-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--win-dark);
}
.setup-hint .key {
  font-family: var(--font-mono);
  background: #fff;
  border: 1px solid var(--win-mid);
  border-bottom-width: 2px;
  padding: 1px 6px;
  border-radius: 2px;
  color: var(--win-text);
}

.setup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.setup-btn {
  background: var(--win-bg-2);
  border-top: 2px solid var(--win-light);
  border-left: 2px solid var(--win-light);
  border-right: 2px solid var(--win-dark);
  border-bottom: 2px solid var(--win-dark);
  padding: 4px 14px;
  font-size: 13px;
  color: var(--win-text);
  font-family: var(--font-win);
  min-width: 110px;
  text-align: center;
}
.setup-btn.primary { font-weight: 600; }
.setup-btn:active:not(:disabled) {
  border-top-color: var(--win-dark);
  border-left-color: var(--win-dark);
  border-right-color: var(--win-light);
  border-bottom-color: var(--win-light);
  padding: 5px 13px 3px 15px;
}
.setup-btn[disabled] {
  color: var(--win-dark);
  text-shadow: 1px 1px 0 var(--win-light);
  cursor: not-allowed;
}

.setup-status {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 10px !important;
}

.setup-progress {
  width: 100%;
  height: 18px;
  background: white;
  border: 2px inset var(--win-mid);
  position: relative;
  overflow: hidden;
}
.setup-progress.wide { height: 22px; }
.setup-progress-fill {
  height: 100%;
  width: 0%;
  background:
    repeating-linear-gradient(
      90deg,
      var(--win-title-1) 0 18px,
      var(--win-title-2) 18px 36px
    );
  transition: width 120ms linear;
}

.setup-meta {
  margin-top: 10px !important;
  color: var(--win-dark);
  font-size: 12px;
}

.setup-path {
  background: white;
  border: 2px inset var(--win-mid);
  padding: 6px 10px;
  margin: 6px 0 12px;
  font-family: var(--font-dos);
  font-size: 13px;
}

.setup-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 10px 0;
}
.setup-option {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  background: var(--win-bg-2);
  border-top: 2px solid var(--win-light);
  border-left: 2px solid var(--win-light);
  border-right: 2px solid var(--win-dark);
  border-bottom: 2px solid var(--win-dark);
  text-align: left;
  color: var(--win-text);
}
.setup-option b { font-size: 14px; }
.setup-option span { font-size: 11px; color: var(--win-dark); }
.setup-option:active {
  border-top-color: var(--win-dark);
  border-left-color: var(--win-dark);
  border-right-color: var(--win-light);
  border-bottom-color: var(--win-light);
}

.setup-field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}
.setup-field-row label {
  min-width: 80px;
  font-weight: 600;
}
.setup-input {
  flex: 1;
  padding: 4px 6px;
  background: white;
  border: 2px inset var(--win-mid);
  font-family: var(--font-dos);
  font-size: 13px;
  outline: 0;
}
.setup-input:focus { border-color: var(--win-title-1); }
.setup-input.wide { font-family: var(--font-dos); letter-spacing: 0.04em; }

/* ----- SCANDISK mini-game grid ----- */
.scandisk-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 4px;
  margin: 12px 0;
  background: #000;
  padding: 8px;
  border: 2px inset var(--win-mid);
  min-height: 140px;
}
.scandisk-cell {
  background: #0a3a0a;
  aspect-ratio: 1;
  border: 1px solid #1c5d1c;
  cursor: pointer;
  position: relative;
  transition: background 80ms ease;
}
.scandisk-cell.bad {
  background: var(--danger);
  box-shadow: inset 0 0 0 2px #ffaaaa;
  animation: pulse-bad 0.6s ease-in-out infinite alternate;
}
.scandisk-cell.fixed {
  background: var(--good);
  cursor: default;
  animation: none;
}
.scandisk-cell.missed {
  background: #2a0a0a;
  border-color: var(--danger);
}
@keyframes pulse-bad {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}

.scandisk-stat {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--win-dark);
  text-align: right;
}
.scandisk-stat .danger { color: var(--danger); font-weight: 700; }

/* ----- Disc prop ----- */
.disc-prop {
  position: relative;
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  background: var(--win-bg-3);
  border-top: 1px solid var(--win-mid);
  border-bottom: 1px solid var(--win-shadow);
  font-family: var(--font-mono);
}
.disc-label-strip { display: flex; align-items: center; gap: 6px; }
.disc-label-strip span { font-size: 10px; color: var(--win-dark); }
.disc-label-strip b { font-size: 12px; color: var(--win-title-1); }
.disc-key {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: white;
  padding: 4px 8px;
  border: 1px solid var(--win-mid);
}
.disc-hint { font-size: 10px; color: var(--win-dark); }

.setup-done {
  font-weight: 700;
  color: var(--good);
  font-size: 14px;
  margin-top: 12px !important;
}

/* ===========================================================
   BSOD
   =========================================================== */

.phase-bsod {
  background: #0000aa;
  color: #fff;
  padding: 40px 60px;
  align-items: flex-start;
  justify-content: flex-start;
}

.bsod {
  max-width: 700px;
  font-family: var(--font-win);
  font-size: 18px;
  line-height: 1.3;
}
.bsod p { margin: 6px 0; }
.bsod-msg {
  background: #fff;
  color: #0000aa;
  padding: 10px 14px;
  margin: 14px 0 !important;
  font-family: var(--font-mono);
  font-size: 14px;
  white-space: pre-wrap;
}
.bsod ul {
  list-style: none;
  padding-left: 0;
  margin: 14px 0;
}
.bsod ul li {
  padding-left: 18px;
  text-indent: -14px;
}
.bsod ul li::before {
  content: '* ';
}
.bsod-footer {
  margin-top: 24px !important;
  font-style: italic;
  animation: blink 1s steps(2) infinite;
}

/* ===========================================================
   WINDOWS ME BOOT — punchline reveal
   =========================================================== */

.phase-me {
  background:
    radial-gradient(ellipse at 50% 25%, #b6e84c 0%, #6fcd80 30%, #2a8c8a 65%, #0e3b4c 100%);
  align-items: center;
  justify-content: center;
  color: white;
  text-align: center;
}

.me-boot {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 60px;
  animation: me-in 700ms cubic-bezier(0.2, 0.7, 0.3, 1.2) both;
}

@keyframes me-in {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.me-flag {
  font-size: 86px;
  filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.4));
  margin-bottom: 14px;
}

.me-name {
  font-family: 'Trebuchet MS', 'Tahoma', sans-serif;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.35),
    0 0 18px rgba(255, 255, 255, 0.5);
  margin-bottom: 6px;
}
.me-name sup {
  font-size: 0.45em;
  vertical-align: super;
  font-weight: 400;
  margin-left: 1px;
}

.me-tagline {
  font-family: 'Trebuchet MS', 'Tahoma', sans-serif;
  font-size: 19px;
  font-style: italic;
  font-weight: 600;
  margin-bottom: 28px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  animation: me-tag 1.4s ease-in-out 400ms both;
}
@keyframes me-tag {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.me-loader {
  width: 240px;
  height: 8px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}
.me-loader-fill {
  height: 100%;
  width: 0%;
  background:
    linear-gradient(90deg, #fff 0%, #c8f08a 50%, #fff 100%);
  box-shadow: 0 0 12px white;
  border-radius: 4px;
  animation: me-fill 2.5s ease-in-out forwards;
}
@keyframes me-fill {
  from { width: 0%; }
  to   { width: 100%; }
}

.me-version {
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.65);
  letter-spacing: 0.1em;
}

/* ===========================================================
   WIN / END SCREEN
   =========================================================== */

.phase-end {
  background:
    radial-gradient(ellipse at 50% 30%, #b6e84c 0%, #6fcd80 40%, #2a8c8a 75%, #0e3b4c 100%);
  align-items: center;
  justify-content: center;
  color: white;
}

.end-card {
  width: min(540px, 92vw);
  background: var(--win-bg);
  color: var(--win-text);
  border-top: 2px solid var(--win-light);
  border-left: 2px solid var(--win-light);
  border-right: 2px solid var(--win-shadow);
  border-bottom: 2px solid var(--win-shadow);
  padding: 24px;
  text-align: center;
}

.end-title {
  margin: 4px 0 8px;
  font-size: 26px;
  color: #1f7a52;
}
.end-sub {
  margin: 4px 0 20px;
  color: var(--win-dark);
  font-size: 14px;
}
.end-stats {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin: 18px 0 20px;
}
.end-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 90px;
}
.end-stat b {
  font-family: var(--font-mono);
  font-size: 26px;
  color: #1f7a52;
}
.end-stat span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--win-dark);
}

.end-quote {
  font-style: italic;
  color: #444;
  margin: 18px 0;
  font-size: 13px;
  line-height: 1.4;
}

.end-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 24px;
  background: var(--win-bg-2);
  border-top: 2px solid var(--win-light);
  border-left: 2px solid var(--win-light);
  border-right: 2px solid var(--win-dark);
  border-bottom: 2px solid var(--win-dark);
  color: var(--win-text);
  font-size: 13px;
  font-weight: 600;
}

/* ===========================================================
   CRT OVERLAY
   =========================================================== */

.crt {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 99;
  background-image: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.18) 0px,
    rgba(0, 0, 0, 0.18) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: multiply;
  opacity: 0.55;
}

.crt-flicker {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 98;
  background: radial-gradient(
    ellipse at center,
    transparent 60%,
    rgba(0, 0, 0, 0.45) 100%
  );
}

@keyframes crt-flicker {
  0%, 96%, 100% { opacity: 1; }
  97% { opacity: 0.96; }
  98% { opacity: 0.9; }
}

/* ===========================================================
   SMALL SCREENS
   =========================================================== */

@media (max-width: 520px) {
  .start-card { width: 96vw; }
  .dos-screen { padding: 14px 16px; font-size: 14px; }
  .dos-text, .dos-input, .dos-input-row { font-size: 14px; }
  .win-setup-window { max-height: 96vh; }
  .setup-body { padding: 14px 14px; font-size: 12px; }
  .hud { font-size: 11px; padding: 4px 8px; }
}
