:root {
  color-scheme: dark;
  --ink: #f8f7ff;
  --muted: #aaa8c5;
  --cyan: #6ff7ff;
  --violet: #9a7bff;
  --pink: #ff75c7;
  --panel: rgba(12, 10, 34, 0.78);
  --line: rgba(170, 159, 255, 0.22);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: #070617; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(115deg, rgba(5, 5, 22, 0.98) 0%, rgba(8, 6, 27, 0.85) 45%, rgba(12, 7, 32, 0.72) 100%),
    url("/assets/anime/bg-cyberpunk.webp") center / cover fixed;
  overflow-x: hidden;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  pointer-events: none;
  background-image:
    linear-gradient(rgba(111, 247, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(111, 247, 255, 0.035) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: linear-gradient(to bottom, black, transparent 90%);
}

.ambient {
  position: fixed;
  width: 45vw;
  height: 45vw;
  right: -15vw;
  top: 15vh;
  z-index: -1;
  border-radius: 50%;
  background: rgba(139, 80, 255, 0.22);
  filter: blur(110px);
  pointer-events: none;
}

a { color: inherit; }

.page-shell {
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto;
  padding: 24px 0 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(7, 6, 24, 0.55);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  font-size: 14px;
  letter-spacing: 0.05em;
}

.brand img {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  object-fit: cover;
}

.brand b { color: var(--cyan); }

.topbar-actions { display: flex; align-items: center; gap: 6px; }

.logout-button {
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 11px;
  color: #aaa6c0;
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.logout-button:hover,
.logout-button:focus-visible {
  border-color: rgba(255, 117, 199, 0.5);
  color: #ffe3f3;
  background: rgba(255, 117, 199, 0.08);
  outline: none;
}

.logout-button:disabled { cursor: wait; opacity: 0.52; }
.logout-button[hidden] { display: none; }

.back-link {
  padding: 10px 14px;
  border-radius: 12px;
  color: #d7d3ef;
  text-decoration: none;
  font-size: 14px;
  transition: background 160ms ease, color 160ms ease;
}

.back-link:hover,
.back-link:focus-visible {
  color: white;
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.hero {
  min-height: calc(100vh - 160px);
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(520px, 1.1fr);
  gap: clamp(40px, 7vw, 110px);
  align-items: center;
  padding: clamp(44px, 7vh, 90px) clamp(8px, 3vw, 48px);
}

.intro { max-width: 630px; }

.eyebrow,
.screen-kicker {
  margin: 0 0 18px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.eyebrow span {
  display: inline-block;
  margin-right: 8px;
  color: #7eff9d;
  filter: drop-shadow(0 0 8px #7eff9d);
}

h1 {
  margin: 0;
  font-size: clamp(48px, 6vw, 88px);
  line-height: 0.95;
  letter-spacing: -0.065em;
}

h1 em {
  display: inline-block;
  margin-top: 14px;
  color: transparent;
  font-size: 0.48em;
  font-style: normal;
  letter-spacing: 0.02em;
  -webkit-text-stroke: 1px rgba(203, 194, 255, 0.86);
}

.lead {
  max-width: 590px;
  margin: 30px 0 24px;
  color: #c8c5dd;
  font-size: 16px;
  line-height: 1.9;
}

code {
  color: #b9fbff;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.privacy-card {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 590px;
  padding: 14px 16px;
  border: 1px solid rgba(111, 247, 255, 0.18);
  border-radius: 16px;
  background: rgba(19, 28, 46, 0.48);
}

.privacy-icon {
  display: grid;
  flex: 0 0 35px;
  width: 35px;
  height: 35px;
  place-items: center;
  border-radius: 12px;
  color: #061114;
  background: var(--cyan);
  box-shadow: 0 0 24px rgba(111, 247, 255, 0.28);
  font-weight: 900;
}

.privacy-card strong {
  display: block;
  color: var(--cyan);
  font-size: 11px;
  letter-spacing: 0.16em;
}

.privacy-card p {
  margin: 4px 0 0;
  color: #aaa9c0;
  font-size: 12px;
  line-height: 1.5;
}

.control-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 24px;
  color: #8f8ca8;
  font-size: 11px;
  letter-spacing: 0.06em;
}

.control-hint span { display: flex; align-items: center; gap: 6px; }

kbd {
  min-width: 28px;
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-bottom-width: 3px;
  border-radius: 6px;
  color: #eeeaff;
  background: rgba(255, 255, 255, 0.08);
  font: inherit;
  text-align: center;
}

.device-column { min-width: 0; }

.device {
  position: relative;
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 22px 26px 28px;
  border: 1px solid rgba(212, 205, 255, 0.38);
  border-radius: 42px 42px 86px 42px;
  background:
    linear-gradient(145deg, rgba(171, 154, 222, 0.29), transparent 26%),
    linear-gradient(135deg, #37314f 0%, #1b1733 58%, #25203d 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -10px 22px rgba(5, 3, 20, 0.45),
    0 30px 90px rgba(0, 0, 0, 0.5),
    0 0 70px rgba(125, 88, 255, 0.12);
}

.device-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px 14px;
  color: #bdb5d7;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.power { display: flex; align-items: center; gap: 7px; }

.power i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7eff9d;
  box-shadow: 0 0 12px #7eff9d;
}

.screen-bezel {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  border: 9px solid #0c0a18;
  border-radius: 25px 25px 48px 25px;
  background: #070713;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 8px 18px rgba(0, 0, 0, 0.45);
}

.device.is-playing .screen-bezel { aspect-ratio: 3 / 2; }

.screen-bezel::after {
  position: absolute;
  inset: 0;
  z-index: 5;
  content: "";
  pointer-events: none;
  background: linear-gradient(110deg, rgba(255, 255, 255, 0.06), transparent 26%);
  mix-blend-mode: screen;
}

.library-panel {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 26px 30px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 20%, rgba(117, 77, 255, 0.23), transparent 43%),
    linear-gradient(180deg, #11102a, #09081b);
}

.library-panel[hidden] { display: none; }

.library-panel::before {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  opacity: 0.22;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.035) 3px 4px);
}

.pixel-mark {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, 9px);
  gap: 4px;
  margin-bottom: 16px;
  transform: rotate(45deg);
}

.pixel-mark span {
  width: 9px;
  height: 9px;
  background: var(--cyan);
  box-shadow: 0 0 14px rgba(111, 247, 255, 0.55);
}

.screen-kicker { margin-bottom: 8px; font-size: 9px; }

.library-panel h2 {
  position: relative;
  margin: 0;
  font-size: clamp(25px, 3vw, 38px);
  letter-spacing: -0.04em;
}

.library-copy {
  position: relative;
  max-width: 430px;
  margin: 9px 0 15px;
  color: #aaa8c2;
  font-size: 12px;
  line-height: 1.5;
}

.library-state {
  position: relative;
  display: flex;
  min-height: 116px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 11px;
}

.library-state[hidden] { display: none; }

.library-message {
  max-width: 390px;
  margin: 0;
  color: #aaa8c2;
  font-size: 12px;
  line-height: 1.5;
}

.library-message.error,
.library-notice.error { color: #ff9bcf; }

.library-action,
.boot-action {
  position: relative;
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 10px 15px;
  border: 1px solid rgba(111, 247, 255, 0.25);
  border-radius: 13px;
  color: #dffeff;
  background: rgba(111, 247, 255, 0.08);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.library-action[hidden],
.boot-action[hidden] { display: none; }

.library-action:hover,
.library-action:focus-visible,
.boot-action:hover,
.boot-action:focus-visible {
  transform: translateY(-2px);
  border-color: var(--cyan);
  background: rgba(111, 247, 255, 0.14);
  outline: none;
}

.cartridge-grid {
  position: relative;
  display: grid;
  width: min(100%, 560px);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.cartridge-grid[hidden] { display: none; }

.cartridge-card {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 142px;
  flex-direction: column;
  align-items: flex-start;
  padding: 14px 15px;
  overflow: hidden;
  border: 1px solid rgba(174, 163, 255, 0.23);
  border-radius: 16px;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(111, 247, 255, 0.1), transparent 46%),
    rgba(255, 255, 255, 0.045);
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.cartridge-card > * {
  position: relative;
  z-index: 1;
}

.cartridge-card::after {
  position: absolute;
  width: 72px;
  height: 72px;
  right: -26px;
  bottom: -30px;
  border-radius: 50%;
  content: "";
  background: rgba(154, 123, 255, 0.18);
  filter: blur(2px);
}

.cartridge-card:hover,
.cartridge-card:focus-visible {
  z-index: 1;
  border-color: rgba(111, 247, 255, 0.7);
  background:
    linear-gradient(135deg, rgba(111, 247, 255, 0.17), transparent 50%),
    rgba(255, 255, 255, 0.07);
  transform: translateY(-2px);
  outline: none;
}

.cartridge-card:disabled {
  cursor: wait;
  opacity: 0.48;
  transform: none;
}

.cartridge-card.is-loading {
  border-color: var(--cyan);
  opacity: 1;
  box-shadow: 0 0 26px rgba(111, 247, 255, 0.14);
}

.cartridge-card.is-prefetching {
  border-color: rgba(111, 247, 255, 0.42);
}

.cartridge-card.is-cached {
  border-color: rgba(126, 255, 189, 0.38);
}

.cartridge-index {
  color: var(--cyan);
  font-size: 8px;
  font-weight: 850;
  letter-spacing: 0.16em;
}

.cartridge-cache-badge {
  position: absolute;
  top: 10px;
  right: 11px;
  padding: 3px 6px;
  border: 1px solid rgba(126, 255, 189, 0.25);
  border-radius: 999px;
  color: #9affca;
  background: rgba(35, 125, 89, 0.13);
  font-size: 7px;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.cartridge-cache-badge[hidden] { display: none; }

.cartridge-card strong {
  display: -webkit-box;
  max-width: 100%;
  margin-top: 8px;
  overflow: hidden;
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.cartridge-subtitle {
  display: block;
  max-width: 100%;
  margin-top: 5px;
  overflow: hidden;
  color: #8d8aa4;
  font-size: 9px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cartridge-play {
  margin-top: 7px;
  padding-top: 9px;
  color: #c4fbff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.cartridge-progress {
  display: grid;
  width: 100%;
  gap: 4px;
  margin-top: auto;
  padding-top: 8px;
}

.cartridge-progress[hidden] { display: none; }

.cartridge-progress-track {
  --progress: 0%;
  position: relative;
  display: block;
  width: 100%;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(111, 247, 255, 0.1);
  box-shadow: inset 0 0 0 1px rgba(111, 247, 255, 0.08);
}

.cartridge-progress-fill {
  display: block;
  width: var(--progress);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(100deg, #5cdde8 0%, #adfff0 42%, #7d6cff 58%, #5cdde8 100%);
  background-size: 240% 100%;
  box-shadow: 0 0 11px rgba(111, 247, 255, 0.5);
  animation: cartridge-shimmer 1150ms linear infinite;
  transition: width 130ms ease-out;
}

.cartridge-progress-track.is-indeterminate .cartridge-progress-fill {
  width: 38%;
  animation:
    cartridge-indeterminate 980ms ease-in-out infinite,
    cartridge-shimmer 780ms linear infinite;
}

.cartridge-progress-label {
  overflow: hidden;
  color: #76cdd3;
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes cartridge-shimmer {
  to { background-position: -240% 0; }
}

@keyframes cartridge-indeterminate {
  0% { transform: translateX(-115%); }
  50% { transform: translateX(82%); }
  100% { transform: translateX(280%); }
}

.library-notice {
  position: relative;
  min-height: 16px;
  margin: 10px 0 0;
  color: #77e5c2;
  font-size: 10px;
  line-height: 1.4;
}

.emulator-stage,
#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.emulator-stage[hidden] { display: none; }

.boot-status {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
  padding: 20px;
  color: #d9d5ef;
  background: #09081b;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-align: center;
}

.boot-status.is-ready { display: none; }

.boot-status.is-error .spinner { display: none; }

.boot-action { color: #f2efff; }

.spinner {
  width: 35px;
  height: 35px;
  border: 3px solid rgba(111, 247, 255, 0.14);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

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

.device-controls {
  position: relative;
  display: grid;
  height: 108px;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 14px 26px 0;
  touch-action: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.touch-dpad {
  display: grid;
  width: 78px;
  height: 78px;
  grid-template: repeat(3, 26px) / repeat(3, 26px);
  justify-self: start;
}

.touch-key {
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-shoulders { display: none; }

.dpad-key,
.dpad-center {
  display: grid;
  width: 26px;
  height: 26px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 4px;
  color: rgba(226, 222, 244, 0.68);
  background: #0f0c1d;
  box-shadow: inset 2px 2px 3px rgba(255, 255, 255, 0.06), 2px 3px 5px rgba(0, 0, 0, 0.35);
  font-size: 8px;
}

.dpad-up { grid-area: 1 / 2; }
.dpad-left { grid-area: 2 / 1; }
.dpad-center { grid-area: 2 / 2; border-radius: 1px; box-shadow: none; }
.dpad-right { grid-area: 2 / 3; }
.dpad-down { grid-area: 3 / 2; }

.control-center {
  display: flex;
  min-width: 126px;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  align-self: stretch;
  justify-content: center;
}

.speaker { display: flex; gap: 5px; transform: rotate(-14deg); }

.speaker i { width: 4px; height: 24px; border-radius: 4px; background: #151126; }

.touch-system { display: flex; gap: 9px; transform: rotate(-4deg); }

.system-key {
  min-width: 54px;
  min-height: 25px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  color: #a9a3bc;
  background: linear-gradient(180deg, #201b35, #0f0c1d);
  box-shadow: inset 1px 1px rgba(255, 255, 255, 0.06), 2px 3px 5px rgba(0, 0, 0, 0.28);
  font: 700 8px ui-monospace, monospace;
  letter-spacing: 0.08em;
}

.touch-actions {
  position: relative;
  width: 108px;
  height: 72px;
  justify-self: end;
  transform: rotate(-13deg);
}

.action-key {
  position: absolute;
  display: grid;
  width: 46px;
  height: 46px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #f8cef1;
  background: linear-gradient(145deg, #d34e9d, #7d285f);
  box-shadow: inset 1px 1px 2px rgba(255, 255, 255, 0.35), 3px 5px 8px rgba(0, 0, 0, 0.35);
  font: 800 12px ui-monospace, monospace;
}

.action-b { left: 0; bottom: 0; }
.action-a { right: 0; top: 0; }

.touch-key:not(:disabled) { cursor: pointer; }

.touch-key:disabled { cursor: default; opacity: 0.58; }

.touch-key:not(:disabled):focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.touch-key.is-pressed,
.touch-key:not(:disabled):active {
  filter: brightness(1.35);
  transform: translateY(2px) scale(0.96);
  box-shadow: inset 2px 3px 5px rgba(0, 0, 0, 0.48), 0 0 16px rgba(111, 247, 255, 0.18);
}

.device .ejs_virtualGamepad_parent,
#game .ejs_virtualGamepad_parent { display: none !important; }

.library-tools {
  display: flex;
  width: min(100%, 760px);
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 13px auto 0;
  padding: 10px 13px;
  border: 1px solid rgba(170, 159, 255, 0.16);
  border-radius: 13px;
  color: #77738f;
  background: rgba(9, 8, 27, 0.58);
  font-size: 9px;
  line-height: 1.4;
}

.library-tools[hidden] { display: none; }

.library-tools button {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid rgba(111, 247, 255, 0.2);
  border-radius: 9px;
  color: #b7edf1;
  background: rgba(111, 247, 255, 0.055);
  cursor: pointer;
  font: inherit;
  font-size: 9px;
  font-weight: 750;
}

.library-tools button:hover,
.library-tools button:focus-visible {
  border-color: rgba(111, 247, 255, 0.65);
  color: white;
  outline: none;
}

.library-tools button:disabled { cursor: wait; opacity: 0.52; }

.session-bar {
  display: flex;
  width: min(100%, 760px);
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin: 16px auto 0;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(11, 9, 30, 0.7);
  backdrop-filter: blur(14px);
}

.session-bar[hidden] { display: none; }

.session-label {
  display: block;
  margin-bottom: 3px;
  color: #77738f;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.session-bar strong {
  display: block;
  max-width: 350px;
  overflow: hidden;
  color: #e6e3f7;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-actions { display: flex; align-items: center; gap: 12px; }

.session-actions span { color: #77e5c2; font-size: 10px; }

.session-actions button {
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 9px;
  color: #d6d2e9;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
}

.session-actions button:hover,
.session-actions button:focus-visible { border-color: var(--cyan); color: white; outline: none; }

footer {
  display: flex;
  justify-content: space-between;
  padding: 14px 16px 0;
  color: #625e7b;
  font-size: 9px;
  letter-spacing: 0.13em;
}

footer a { color: #8d88a8; }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

body.auth-open { overflow: hidden; }

body.auth-open .page-shell {
  pointer-events: none;
  user-select: none;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  height: 100dvh;
  padding:
    max(20px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  overflow-y: auto;
  place-items: center;
}

.auth-modal[hidden] { display: none; }

.auth-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 3, 16, 0.82);
  backdrop-filter: blur(16px);
}

.auth-dialog {
  position: relative;
  width: min(100%, 430px);
  max-height: calc(100dvh - 40px);
  padding: clamp(28px, 6vw, 44px);
  overflow-y: auto;
  border: 1px solid rgba(182, 171, 255, 0.28);
  border-radius: 30px 30px 58px 30px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), transparent 28%),
    rgba(13, 10, 35, 0.96);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.13),
    0 30px 90px rgba(0, 0, 0, 0.58),
    0 0 70px rgba(111, 247, 255, 0.07);
}

.auth-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 13px;
  color: #bdb8d2;
  background: rgba(255, 255, 255, 0.045);
  cursor: pointer;
  font: 400 25px/1 ui-sans-serif, system-ui, sans-serif;
}

.auth-close:hover,
.auth-close:focus-visible {
  border-color: rgba(111, 247, 255, 0.55);
  color: white;
  background: rgba(111, 247, 255, 0.08);
  outline: none;
}

.auth-mark {
  display: grid;
  width: max-content;
  grid-template-columns: repeat(2, 9px);
  gap: 4px;
  margin: 0 auto 20px;
  transform: rotate(45deg);
}

.auth-mark span {
  width: 9px;
  height: 9px;
  background: var(--cyan);
  box-shadow: 0 0 14px rgba(111, 247, 255, 0.5);
}

.auth-eyebrow {
  margin: 0 0 11px;
  color: var(--cyan);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.18em;
  text-align: center;
}

.auth-dialog h2 {
  margin: 0;
  font-size: clamp(29px, 7vw, 40px);
  line-height: 1.08;
  letter-spacing: -0.045em;
  text-align: center;
}

.auth-copy {
  margin: 14px 0 24px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

.auth-form { display: grid; gap: 9px; }

.auth-form label {
  margin-top: 4px;
  color: #c5c1d8;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.04em;
}

.auth-form input {
  width: 100%;
  min-height: 49px;
  padding: 11px 14px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 13px;
  color: var(--ink);
  background: rgba(5, 5, 18, 0.65);
  caret-color: var(--cyan);
  font: inherit;
  font-size: 16px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.auth-form input:focus {
  border-color: rgba(111, 247, 255, 0.68);
  background: rgba(6, 10, 23, 0.78);
  box-shadow: 0 0 0 3px rgba(111, 247, 255, 0.08);
}

.auth-form input[aria-invalid="true"] {
  border-color: rgba(255, 117, 199, 0.72);
  box-shadow: 0 0 0 3px rgba(255, 117, 199, 0.08);
}

.auth-submit {
  display: flex;
  width: 100%;
  min-height: 51px;
  align-items: center;
  justify-content: space-between;
  margin-top: 13px;
  padding: 9px 11px 9px 17px;
  border: 0;
  border-radius: 14px;
  color: #080617;
  background: linear-gradient(110deg, var(--cyan), #a6ffe2);
  box-shadow: 0 14px 34px rgba(81, 230, 245, 0.18);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 850;
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.auth-submit b {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 9px;
  background: rgba(6, 9, 22, 0.12);
}

.auth-submit:hover,
.auth-submit:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(81, 230, 245, 0.27);
  outline: none;
}

.auth-submit:disabled { cursor: wait; opacity: 0.58; transform: none; }

.auth-status {
  min-height: 20px;
  margin: 2px 0 0;
  color: #8d89a4;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.auth-status.error { color: #ff9bcf; }
.auth-status.success { color: #7effbd; }

.auth-note {
  margin: 15px 0 0;
  color: #69657f;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-align: center;
}

@media (min-width: 1021px) and (max-width: 1240px) {
  .library-panel { padding: 14px 20px; }
  .library-panel .pixel-mark { display: none; }
  .library-copy { margin: 6px 0 9px; }
  .cartridge-card { min-height: 124px; padding: 11px 13px; }
  .cartridge-subtitle { display: none; }
  .cartridge-play { padding-top: 7px; }
  .library-notice { margin-top: 6px; }
}

@media (max-width: 1020px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 42px;
    padding-top: 52px;
  }

  .intro { max-width: 760px; margin: 0 auto; text-align: center; }
  .lead, .privacy-card { margin-left: auto; margin-right: auto; }
  .control-hint { justify-content: center; }
  .device-column { width: min(760px, 100%); margin: 0 auto; }
}

@media (max-width: 640px) {
  .page-shell { width: min(100% - 20px, 1440px); padding-top: 10px; }
  .topbar { min-height: 50px; padding: 6px 8px; border-radius: 14px; }
  .brand { font-size: 11px; }
  .brand img { width: 34px; height: 34px; }
  .topbar-actions { gap: 2px; }
  .logout-button { padding: 7px 6px; font-size: 9px; }
  .back-link { padding: 8px; font-size: 11px; }
  .hero { min-height: 0; gap: 32px; padding: 38px 0 52px; }
  h1 { font-size: clamp(43px, 14vw, 64px); }
  h1 em { margin-top: 10px; font-size: 0.42em; }
  .lead { margin-top: 22px; font-size: 14px; line-height: 1.75; }
  .privacy-card { align-items: flex-start; text-align: left; }
  .control-hint { display: none; }
  .device { padding: 14px 13px 17px; border-radius: 25px 25px 50px 25px; }
  .device-topline { padding: 0 5px 9px; font-size: 8px; }
  .screen-bezel { border-width: 6px; border-radius: 16px 16px 30px 16px; }
  .device.is-library .screen-bezel { min-height: 430px; aspect-ratio: auto; }
  .library-panel { padding: 22px 15px; }
  .pixel-mark { margin-bottom: 10px; transform: rotate(45deg) scale(0.75); }
  .screen-kicker { margin-bottom: 5px; }
  .library-panel h2 { font-size: 22px; }
  .library-copy { margin: 7px 0 12px; font-size: 10px; line-height: 1.45; }
  .library-state { min-height: 190px; }
  .cartridge-grid { grid-template-columns: 1fr; gap: 9px; }
  .cartridge-card { min-height: 130px; padding: 12px 14px; }
  .cartridge-card strong { margin-top: 6px; font-size: 15px; }
  .cartridge-play { padding-top: 7px; }
  .library-notice { margin-top: 7px; font-size: 9px; }
  .library-tools { align-items: flex-start; gap: 9px; padding: 9px 10px; }
  .library-tools button { max-width: 126px; }
  .device.is-library .device-controls { display: none; }
  .device.is-playing .device-controls {
    display: grid;
    height: 218px;
    grid-template-columns: auto minmax(48px, 1fr) auto;
    gap: clamp(3px, 1.5vw, 8px);
    padding: 58px 6px 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.055);
  }
  .touch-shoulders {
    position: absolute;
    top: 8px;
    left: 7px;
    right: 7px;
    display: flex;
    justify-content: space-between;
  }
  .shoulder-key {
    width: clamp(96px, 30vw, 126px);
    min-height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 13px 13px 8px 8px;
    color: #c8c2db;
    background: linear-gradient(180deg, #28213d, #100d1d);
    box-shadow: inset 1px 1px rgba(255, 255, 255, 0.08), 2px 4px 8px rgba(0, 0, 0, 0.3);
    font: 800 12px ui-monospace, monospace;
  }
  .touch-dpad {
    width: clamp(112px, 34vw, 132px);
    height: clamp(112px, 34vw, 132px);
    grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  }
  .dpad-key,
  .dpad-center { width: 100%; height: 100%; border-radius: 7px; font-size: 11px; }
  .control-center { min-width: 0; gap: 10px; align-self: center; }
  .speaker { display: none; }
  .touch-system { flex-direction: column; gap: 8px; transform: none; }
  .system-key {
    width: clamp(48px, 15vw, 60px);
    min-width: 0;
    min-height: 42px;
    padding: 4px;
    font-size: 7px;
  }
  .touch-actions { width: clamp(102px, 30vw, 116px); height: 116px; }
  .action-key { width: clamp(56px, 16vw, 62px); height: clamp(56px, 16vw, 62px); font-size: 16px; }
  body.game-active .hero { gap: 0; padding: 16px 0 32px; }
  body.game-active .intro { display: none; }
  body.game-active .device-column { width: 100%; }
  .session-bar { align-items: flex-start; padding: 11px; }
  .session-actions { flex-direction: column; align-items: flex-end; gap: 6px; }
  .session-actions span { display: none; }
  .session-bar strong { max-width: 55vw; }
  footer { flex-direction: column; gap: 8px; align-items: center; text-align: center; }
}

@media (max-width: 360px) {
  .brand span { display: none; }
  .auth-dialog { padding: 25px 22px; border-radius: 24px 24px 44px 24px; }
}

@media (max-height: 620px) {
  .auth-modal { place-items: start center; }
  .auth-dialog { max-height: calc(100dvh - 32px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation-duration: 1ms !important; }
}
