:root {
  /* NX Options screenshot + config_menu.c */
  --bg: #06080a;
  --panel: #162430;
  --panel2: #1a2834;
  --line: #5aa0be;
  --text: #ffffff;
  --title: #f0a830;
  --muted: #8cafbe;
  --hint: #c89646;
  --accent: #5aa0be;
  --accent-text: #06080a;
  --flash: #89f0f2;
  --focus-a: #1989c6;
  --focus-b: #89f0f2;
  --screen: #0a1218;
  --sel: #243444;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Open Sans", system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.45;
  font-weight: 400;
}

#bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.app {
  position: relative;
  z-index: 1;
  width: min(760px, calc(100% - 28px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

.brand {
  text-align: center;
  margin-bottom: 36px;
}

.brand a {
  display: inline-block;
  line-height: 0;
}

.logo {
  width: 256px;
  max-width: min(256px, 100%);
  height: auto;
  aspect-ratio: 1;
  display: block;
  margin: 0 auto 16px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

h1 {
  margin: 0;
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--title);
}

.lede {
  margin: 10px auto 0;
  max-width: 34rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.bg-cycle {
  appearance: none;
  display: inline-block;
  margin-top: 14px;
  border: 0;
  background: none;
  color: var(--muted);
  font: 600 0.9rem/1.2 "Open Sans", system-ui, sans-serif;
  padding: 6px 4px;
  cursor: pointer;
  border-radius: 2px;
}

.bg-cycle:hover {
  color: var(--flash);
}

.brand-controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 4px;
}

.drops {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.panel-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.linkish {
  appearance: none;
  border: 0;
  background: none;
  color: var(--line);
  font: 600 1rem/1.2 "Open Sans", system-ui, sans-serif;
  padding: 8px 4px;
  cursor: pointer;
  white-space: nowrap;
  border-radius: 2px;
}

.linkish:hover { color: var(--flash); }

.drop {
  appearance: none;
  display: block;
  position: relative;
  width: 100%;
  padding: 3px;
  border: 2px dashed var(--line);
  border-radius: 12px;
  background: var(--screen);
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  color: inherit;
  font: inherit;
  isolation: isolate;
}

.drop:hover,
.drop.drag {
  border-color: transparent;
  outline: 3px solid #1989c6;
  outline-offset: 0;
  animation: pulse-focus 850ms infinite;
}

/* Hex-ish force field around the Metroid drop zone */
.force-field-glow {
  pointer-events: none;
  position: absolute;
  inset: 0;
  border-radius: 12px;
  z-index: 0;
  background:
    radial-gradient(ellipse 70% 55% at 50% 42%, rgba(25, 137, 198, 0.22), transparent 70%),
    radial-gradient(ellipse 90% 70% at 50% 50%, rgba(137, 240, 242, 0.08), transparent 75%);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--flash) 35%, transparent),
    inset 0 0 28px color-mix(in srgb, var(--focus-a) 28%, transparent);
  animation: force-field-pulse 2.4s ease-in-out infinite;
}

.force-field-glow::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--flash) 28%, transparent);
  clip-path: polygon(
    18% 0%, 82% 0%, 100% 22%, 100% 78%, 82% 100%, 18% 100%, 0% 78%, 0% 22%
  );
  opacity: 0.55;
  animation: force-field-hex 3.2s linear infinite;
}

.force-field .drop-stage,
.force-field .drop-hint {
  position: relative;
  z-index: 1;
}

.drop.force-field:hover .force-field-glow,
.drop.force-field.drag .force-field-glow,
.drop.force-field:has(#metroid.alive) .force-field-glow {
  animation-duration: 1.1s;
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--flash) 55%, transparent),
    inset 0 0 40px color-mix(in srgb, var(--focus-b) 35%, transparent),
    0 0 18px color-mix(in srgb, var(--focus-a) 35%, transparent);
}

@keyframes force-field-pulse {
  0%, 100% { opacity: 0.72; filter: brightness(0.95); }
  50% { opacity: 1; filter: brightness(1.15); }
}

@keyframes force-field-hex {
  0% { opacity: 0.35; transform: scale(0.98); }
  50% { opacity: 0.7; transform: scale(1.01); }
  100% { opacity: 0.35; transform: scale(0.98); }
}

.panel[data-kind="logo"] .drop {
  background: #000;
}

.panel[data-kind="apk"] .drop {
  background: #000;
}

.drop-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  padding: 28px 16px 16px;
}

#metroid {
  width: 69px;
  height: 69px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: grayscale(1) brightness(0.85);
  opacity: 0.72;
  transition: filter 220ms ease, opacity 220ms ease;
}

#metroid.alive {
  filter: none;
  opacity: 1;
}

.drop canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  border-radius: 8px;
}

#metroid.drop-canvas,
.drop-stage canvas {
  width: 69px;
  height: 69px;
  aspect-ratio: auto;
  border-radius: 0;
}

.drop-hint {
  display: block;
  padding: 12px 14px 14px;
  background: var(--panel2);
  color: var(--muted);
  font-size: 1rem;
}

.panel-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.panel-bar .primary {
  width: auto;
  min-width: 140px;
  padding: 12px 22px;
  font-size: 1.05rem;
}

.panel-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: right;
}

.ghost {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 600 1.05rem "Open Sans", system-ui, sans-serif;
  padding: 10px 8px;
  cursor: pointer;
  border-radius: 2px;
}

.ghost:hover { color: var(--text); }

.seg {
  display: flex;
  gap: 6px;
}

.seg button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  font: 400 1.05rem "Open Sans", system-ui, sans-serif;
  padding: 10px 16px;
  border-radius: 2px;
  cursor: pointer;
}

.seg button:hover {
  border-color: var(--accent);
  background: #3a3b3c;
}

.seg button.on {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.seg button.on:hover {
  background: #95b6ff;
  border-color: #95b6ff;
}

.cta {
  margin-top: 32px;
  text-align: center;
}

.lede + .lede {
  margin-top: 4px;
}

.status {
  margin: 18px 0 0;
  min-height: 1.45em;
  color: var(--muted);
  font-size: 1.05rem;
  text-align: center;
  white-space: pre-line;
}

.primary {
  appearance: none;
  border: 0;
  width: min(100%, 420px);
  background: var(--title);
  color: var(--accent-text);
  font: 400 1.25rem "Open Sans", system-ui, sans-serif;
  padding: 16px 28px;
  border-radius: 2px;
  cursor: pointer;
}

.primary:hover {
  background: #ffb84a;
}
.primary:active { transform: scale(0.97); }

.primary.compact {
  width: auto;
  padding: 12px 20px;
  font-size: 1.05rem;
}

.primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.primary:disabled:hover {
  background: var(--title);
}

.bar-track {
  height: 14px;
  min-height: 14px;
  max-height: 14px;
  border-radius: 2px;
  background: var(--bg);
  border: 1px solid var(--line);
  outline: none;
  animation: none;
  overflow: hidden;
  margin: 10px 0 16px;
  box-sizing: border-box;
}

.bar-fill {
  display: block;
  height: 14px;
  min-height: 14px;
  max-height: 14px;
  width: 0%;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--focus-a);
  animation: pulse-bar-fill 850ms infinite;
  transition: width 180ms ease-out;
  box-sizing: border-box;
}

@keyframes pulse-bar-fill {
  0%, 100% { background-color: var(--focus-a); }
  50% { background-color: var(--focus-b); }
}

.progress-flavor {
  color: var(--text) !important;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.98rem !important;
  min-height: 2.6em;
  margin: 0 0 4px !important;
  white-space: pre-line;
}

.progress-log {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  max-height: none;
  margin: 0 0 4px;
  /* Always reserve the gutter - avoids scrollbar popping mid-run then vanishing. */
  overflow-x: hidden;
  overflow-y: scroll;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--line) 35%, transparent);
  border-radius: 8px;
  background:
    radial-gradient(ellipse at center, rgba(20, 48, 58, 0.55), rgba(0, 0, 0, 0.82)),
    #020608;
  box-sizing: border-box;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--line) 55%, transparent)
    color-mix(in srgb, #000 35%, transparent);
  isolation: isolate;
  text-shadow: 0 0 2px color-mix(in srgb, var(--flash) 35%, transparent);
}

.progress-log.crt .console-viewport {
  position: relative;
  z-index: 1;
}

.crt-scanlines,
.crt-glow {
  pointer-events: none;
  position: absolute;
  inset: 0;
  border-radius: 8px;
  z-index: 2;
}

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

.crt-glow {
  background:
    linear-gradient(rgba(137, 240, 242, 0.05), transparent 30%, transparent 70%, rgba(0, 0, 0, 0.35)),
    radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.45) 100%);
  box-shadow: inset 0 0 28px rgba(25, 137, 198, 0.18);
  animation: crt-flicker 3.8s steps(2, end) infinite;
}

@keyframes crt-flicker {
  0%, 100% { opacity: 0.85; }
  48% { opacity: 0.92; }
  50% { opacity: 0.7; }
  52% { opacity: 0.95; }
}

.progress-log::-webkit-scrollbar {
  width: 8px;
}

.progress-log::-webkit-scrollbar-track {
  background: color-mix(in srgb, #000 35%, transparent);
  border-radius: 8px;
}

.progress-log::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--line) 55%, transparent);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.progress-log::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--flash, var(--accent)) 70%, var(--line));
  background-clip: padding-box;
  border: 2px solid transparent;
}

.console-viewport {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: 0.12em;
  min-height: 100%;
  font-family: ui-monospace, Consolas, "Cascadia Mono", monospace;
  font-size: 0.72rem;
  line-height: 1.35;
  color: color-mix(in srgb, var(--text) 88%, #7dffb3);
}

.console-line {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  opacity: 1;
}

.console-line-done {
  opacity: 0.55;
}

.console-cursor {
  display: inline-block;
  margin-left: 3px;
  font-size: 1.05em;
  line-height: 1;
  vertical-align: -0.05em;
  color: var(--focus-a);
  text-shadow: 0 0 8px color-mix(in srgb, var(--focus-b) 55%, transparent);
  animation: console-cursor-pulse 850ms ease-in-out infinite;
}

@keyframes console-cursor-pulse {
  0%, 100% {
    color: var(--focus-a);
    opacity: 1;
    text-shadow: 0 0 6px color-mix(in srgb, var(--focus-a) 45%, transparent);
  }
  50% {
    color: var(--focus-b);
    opacity: 1;
    text-shadow: 0 0 10px color-mix(in srgb, var(--focus-b) 70%, transparent);
  }
}

#progress {
  width: min(520px, calc(100% - 28px));
  height: min(430px, calc(100vh - 48px));
  max-width: 520px;
  max-height: min(430px, calc(100vh - 48px));
  border-radius: 16px;
  box-sizing: border-box;
  overflow: hidden;
  padding: 22px 22px 16px;
}

#progress[open] {
  display: flex;
  flex-direction: column;
  gap: 0;
}

#progress .dialog-actions {
  flex: 0 0 auto;
  margin-top: auto;
  padding-top: 10px;
  padding-bottom: 0;
}

.progress-actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.progress-actions-btns {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.ghost.compact {
  padding: 12px 16px;
  font-size: 1.05rem;
}

.progress-auto {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  min-width: 0;
  flex: 1 1 auto;
  color: var(--muted);
  font: 600 0.82rem/1.2 "Open Sans", system-ui, sans-serif;
  cursor: pointer;
  user-select: none;
  border-radius: 2px;
}

.progress-auto input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.progress-auto-box {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel2);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #000 25%, transparent);
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.progress-auto-box::after {
  content: "";
  display: block;
  width: 10px;
  height: 10px;
  margin: 3px auto 0;
  background: var(--title);
  border-radius: 1px;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 160ms ease, transform 160ms ease;
}

.progress-auto-label {
  color: var(--muted);
  white-space: nowrap;
  transition: color 160ms ease;
}

.progress-auto:hover .progress-auto-box {
  border-color: var(--flash);
}

.progress-auto:hover .progress-auto-label {
  color: var(--text);
}

.progress-auto:has(input:checked) .progress-auto-box {
  border-color: var(--title);
  background: color-mix(in srgb, var(--title) 18%, var(--panel2));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--title) 35%, transparent);
}

.progress-auto:has(input:checked) .progress-auto-box::after {
  opacity: 1;
  transform: scale(1);
}

.progress-auto:has(input:checked) .progress-auto-label {
  color: var(--title);
}

.progress-auto:has(input:focus-visible) .progress-auto-box {
  outline: 2px solid var(--focus-a);
  outline-offset: 2px;
}

#progress-download:hover:not(:disabled),
#progress-download:focus:hover:not(:disabled) {
  outline: 3px solid var(--focus-a);
  outline-offset: 0;
  animation: pulse-focus 850ms infinite;
}

footer {
  margin-top: 40px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 1rem;
}

footer a {
  color: var(--line);
}

footer a:hover {
  color: var(--flash);
}

@keyframes pulse-focus {
  0% { outline-color: var(--focus-a); }
  50% { outline-color: var(--focus-b); }
  100% { outline-color: var(--focus-a); }
}

.switch-focus-ring:hover,
.switch-focus-ring:focus:hover,
.drop:hover,
.drop.drag {
  outline: 3px solid var(--focus-a);
  outline-offset: 0;
  animation: pulse-focus 850ms infinite;
}

.switch-focus-ring:focus:not(:hover) {
  outline: none;
  animation: none;
}

.switch-focus-ring:focus-visible:not(:hover) {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  animation: none;
}

dialog {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 16px;
  padding: 24px;
  max-width: 560px;
  width: calc(100% - 28px);
  overflow: visible;
}

dialog:not([open]) {
  display: none;
}

#help-close:hover,
#help-close:focus:hover,
#progress-close:hover,
#progress-close:focus:hover {
  outline: 3px solid var(--focus-a);
  outline-offset: 0;
  animation: pulse-focus 850ms infinite;
}

#progress-download:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

dialog::backdrop { background: rgba(0, 0, 0, 0.72); }

dialog h3 {
  margin: 0 0 12px;
  color: var(--title);
  font-size: 1.15rem;
  font-weight: 700;
}

dialog p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 1.05rem;
}

pre {
  margin: 0 0 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  font: 16px/1.45 ui-monospace, Consolas, monospace;
  padding: 14px 16px;
  border-radius: 2px;
  overflow: auto;
}

.dialog-actions {
  text-align: right;
  padding-top: 8px;
}

@media (max-width: 520px) {
  .app { padding: 24px 0 36px; }
  h1 { font-size: 1.85rem; }
  .logo {
    width: 256px;
    max-width: min(256px, calc(100vw - 48px));
  }
  .seg button { flex: 1; padding: 12px 8px; }
  .panel-bar .primary { width: auto; flex: 0 0 auto; }
  .progress-auto { font-size: 0.78rem; }
  .ghost.compact { padding: 12px 12px; }
  .primary.compact { padding: 12px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  #bg { display: none; }
  .crt-glow,
  .force-field-glow,
  .force-field-glow::before {
    animation: none !important;
  }
}
