* { box-sizing: border-box; }
:root {
  color-scheme: dark;
  --bg: #07090d;
  --panel: #11151d;
  --panel-2: #181e28;
  --text: #f5f7fb;
  --muted: #9aa5b5;
  --line: #293140;
}
body {
  margin: 0;
  background: radial-gradient(circle at 30% -10%, #1d2636 0, #090c12 35%, #07090d 72%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.brand {
  font-size: 22px;
  font-weight: 850;
  letter-spacing: -.04em;
}
.brand span { color: #71a7ff; }
.brand.large { font-size: 34px; margin-bottom: 20px; }
.topbar {
  height: 68px;
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 32px;
  padding: 0 34px;
  background: rgba(7,9,13,.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.topbar nav { display: flex; gap: 8px; }
.account { display: flex; align-items: center; gap: 14px; color: var(--muted); }
button {
  color: #e9eef6;
  background: #202735;
  border: 1px solid #354052;
  border-radius: 7px;
  padding: 9px 13px;
}
button:hover { background: #2b3545; }
button:disabled { opacity: .55; cursor: wait; }
button.primary { background: #f5f7fb; color: #0b0e13; border-color: #f5f7fb; font-weight: 750; }
button.primary:hover { background: white; }
button.link-button { background: transparent; border-color: transparent; }
main { padding-bottom: 50px; }
.hero {
  --hero-accent: #3a6ea5;
  min-height: 390px;
  position: relative;
  display: flex;
  align-items: center;
  overflow: hidden;
  padding: 55px 6vw;
  background:
    linear-gradient(90deg, rgba(7,9,13,.98) 0%, rgba(7,9,13,.82) 48%, rgba(7,9,13,.18) 78%),
    radial-gradient(circle at 80% 50%, var(--hero-accent), #111722 52%, #090c12 76%);
}
.hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 90px;
  background: linear-gradient(transparent, var(--bg));
}
.hero-copy { max-width: 610px; position: relative; z-index: 2; }
.hero h1 { font-size: clamp(40px, 6vw, 72px); line-height: .95; margin: 8px 0 8px; letter-spacing: -.055em; }
.hero h3 { margin: 0 0 18px; color: #d0d8e5; font-weight: 550; }
.hero p { font-size: 17px; line-height: 1.6; color: #c3ccda; max-width: 570px; }
.kicker { color: #9ec3ff; font-size: 12px; font-weight: 800; letter-spacing: .18em; }
.hero-image {
  position: absolute;
  inset: 0 0 0 42%;
  width: 58%;
  height: 100%;
  object-fit: cover;
  opacity: .62;
  mask-image: linear-gradient(90deg, transparent 0%, rgba(0,0,0,.45) 20%, black 55%);
}
.hero-mark {
  position: absolute;
  right: 8vw;
  top: 50%;
  transform: translateY(-52%);
  font-size: min(20vw, 250px);
  font-weight: 950;
  letter-spacing: -.1em;
  color: rgba(255,255,255,.12);
  text-shadow: 0 20px 70px rgba(0,0,0,.5);
}
.hero-action { margin-top: 12px; min-width: 120px; }
.catalog-row { margin: 24px 0 38px; padding-left: 4vw; }
.row-heading { display: flex; gap: 14px; align-items: baseline; margin-bottom: 12px; padding-right: 4vw; }
.row-heading h2 { margin: 0; font-size: 21px; }
.row-heading span { color: var(--muted); font-size: 13px; }
/* Cards in each horizontal rail share a common vertical rhythm. */
.card-rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(260px, 278px);
  align-items: stretch;
  gap: 14px;
  overflow-x: auto;
  padding: 2px 4vw 14px 0;
  scroll-snap-type: x proximity;
}
.card-rail::-webkit-scrollbar { height: 7px; }
.card-rail::-webkit-scrollbar-thumb { background: #293140; border-radius: 8px; }
.game-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  min-height: 478px;
  scroll-snap-align: start;
  overflow: hidden;
  background: linear-gradient(180deg, #171c25, #10141b);
  border: 1px solid #272f3d;
  border-radius: 10px;
  box-shadow: 0 8px 25px rgba(0,0,0,.18);
  transition: transform .16s ease, border-color .16s ease;
}
.game-card:hover { transform: translateY(-3px); border-color: #46536a; }
.poster {
  --accent: #446;
  flex: 0 0 160px;
  height: 160px;
  width: 100%;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 75% 25%, color-mix(in srgb, var(--accent) 78%, white), transparent 36%),
    linear-gradient(135deg, var(--accent), #0e1117 82%);
}
.poster img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: saturate(.92) contrast(1.03);
}
.poster::after {
  content: "";
  position: absolute;
  inset: 45% 0 0;
  background: linear-gradient(transparent, rgba(0,0,0,.56));
  pointer-events: none;
}
.poster-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.055) 1px, transparent 1px),
    linear-gradient(90deg,rgba(255,255,255,.055) 1px,transparent 1px);
  background-size: 18px 18px;
  transform: perspective(300px) rotateX(55deg) scale(1.45);
  transform-origin: center bottom;
  opacity: .5;
}
.glyph {
  position: absolute;
  left: 17px; bottom: 8px;
  font-size: 60px;
  line-height: 1;
  font-weight: 950;
  letter-spacing: -.08em;
  color: white;
  text-shadow: 0 4px 20px rgba(0,0,0,.35);
}
.poster-year {
  position: absolute; right: 10px; top: 10px;
  padding: 3px 6px; border-radius: 4px;
  background: rgba(0,0,0,.45); font: 11px ui-monospace,monospace;
}
.poster-options {
  position: absolute;
  z-index: 2;
  top: 8px;
  left: 9px;
  width: 32px;
  height: 30px;
  padding: 0;
  border: 1px solid rgba(189,210,240,.45);
  border-radius: 7px;
  background: rgba(10,16,28,.85);
  color: #f1f5fa;
  font-size: 21px;
  line-height: 1;
  backdrop-filter: blur(4px);
}
.poster-options:hover {background: #20344f;}
.card-body {
  padding: 14px;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}
.card-body h3 {
  margin: 0;
  font-size: 17px;
  line-height: 20px;
  height: 40px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
.subtitle {
  color: #a9b4c4;
  margin: 3px 0 8px;
  line-height: 17px;
  height: 34px;
  font-size: 13px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
.badges {display: flex; gap: 5px; flex-wrap: wrap; align-content: start; min-height: 34px;}
.badge { font-size: 10px; padding: 3px 5px; border: 1px solid #3b4659; color: #b8c4d4; border-radius: 4px; }
.badge.shareware { border-color: #476d55; color: #9bd2aa; }
.description {
  color: #9ba9bb;
  line-height: 16px;
  font-size: 12px;
  margin: 8px 0 12px;
  max-height: 64px;
  min-height: 64px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4;
}
.card-actions {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  width: 100%;
  margin-top: auto;
}
.card-actions > .play, .card-actions > .install {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.3;
  white-space: normal;
  text-align: center;
}
.card-secondary-actions {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 6px;
  min-width: 0;
  width: 100%;
}
/* A game with only Shared Console gets one full-width secondary button. */
.card-secondary-actions button:only-child { grid-column: 1 / -1; }
.card-secondary-actions button {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 6px 7px;
  line-height: 1.22;
  font-size: 12px;
  white-space: normal;
  overflow-wrap: break-word;
  text-align: center;
}
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 30px;
  background:
    linear-gradient(rgba(4,6,9,.76), rgba(4,6,9,.94)),
    repeating-linear-gradient(90deg,#0f1722 0,#0f1722 1px,transparent 1px,transparent 36px),
    repeating-linear-gradient(#0f1722 0,#0f1722 1px,transparent 1px,transparent 36px);
}
.login-panel {
  width: min(510px, 100%);
  padding: 34px;
  border: 1px solid #2d3747;
  border-radius: 14px;
  background: rgba(15,19,26,.97);
  box-shadow: 0 30px 90px rgba(0,0,0,.45);
}
.login-panel h1 { font-size: 31px; margin: 0 0 10px; letter-spacing: -.03em; }
.login-panel > p { color: var(--muted); line-height: 1.55; }
.form-stack { display: grid; gap: 12px; margin: 24px 0; }
.form-stack.compact { margin: 12px 0; }
.sso-button { width: 100%; margin-top: 22px; padding: 12px 14px; }
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 0;
  color: #6f7d91;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: #2a3444;
}
label { display: grid; gap: 5px; color: #b5c0cf; font-size: 13px; }
input {
  width: 100%; color: white; background: #090c11; border: 1px solid #354052;
  border-radius: 7px; padding: 11px 12px;
}
details { color: var(--muted); }
summary { cursor: pointer; }
.error { color: #ff9f9f; min-height: 20px; margin-top: 9px; }
.toast {
  position: fixed; right: 25px; bottom: 25px; z-index: 50;
  max-width: 390px; padding: 12px 16px; border-radius: 8px;
  background: #e8edf5; color: #10141b; box-shadow: 0 15px 50px rgba(0,0,0,.4);
}
code { color: #d4e2f7; }
@media (max-width: 720px) {
  .topbar { grid-template-columns: auto 1fr; padding: 0 16px; gap: 12px; }
  .topbar nav { display: none; }
  .account { justify-self: end; }
  .hero { min-height: 330px; padding: 42px 22px; }
  .hero-mark { opacity: .4; }
  .catalog-row { padding-left: 20px; }
  .card-rail { padding-right: 20px; grid-auto-columns: minmax(250px, 270px); }
}
.badge.ipx { color: #a9d2ff; border-color: #365d87; background: rgba(47,93,140,.16); }
button.multiplayer { background: #132943; border-color: #315b87; color: #cfe5ff; }


body.modal-open { overflow: hidden; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 5, 10, .78);
  backdrop-filter: blur(8px);
}
.modal-card {
  position: relative;
  width: min(100%, 480px);
  padding: 28px;
  border: 1px solid #354052;
  border-radius: 14px;
  background: linear-gradient(180deg, #171d27, #0f141c);
  box-shadow: 0 28px 90px rgba(0,0,0,.58);
}
.modal-card h2 { margin: 6px 0 8px; font-size: 27px; letter-spacing: -.025em; }
.modal-copy { margin: 0 0 22px; color: #bac5d4; line-height: 1.55; }
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 24px;
  line-height: 1;
  background: transparent;
  border-color: transparent;
  color: #9eabbc;
}
.modal-close:hover { color: white; background: #252e3b; }
.join-code-form { display: grid; gap: 8px; }
.join-code-form label { font-size: 13px; font-weight: 750; letter-spacing: .03em; }
.join-code-form input {
  box-sizing: border-box;
  width: 100%;
  padding: 15px 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 25px;
  font-weight: 800;
  letter-spacing: .22em;
  text-transform: uppercase;
}
.join-code-form input::placeholder { color: #596579; }
.field-help { color: var(--muted); font-size: 12px; line-height: 1.45; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

#host-multiplayer-count { width:100%;background:#101b2a;border:1px solid #486486;padding:14px 16px;color:#e9effb;border-radius:8px;font-size:16px; }
/* Discovery controls for a larger, legally sourced DOS collection. */
.sr-only { position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0; }
.catalog-browser {padding:28px 4vw 4px;}
.browser-heading {display:flex;gap:14px;align-items:baseline;margin-bottom:12px;}
.browser-heading h2 {font-size:22px;margin:0;}
.browser-heading span {font-size:13px;color:#9eabba;}
.catalog-filterbar {display:flex;gap:10px;flex-wrap:wrap;}
.catalog-filterbar input,.catalog-filterbar select {
  border:1px solid #3a4a62;border-radius:8px;background:#151e2c;
  color:#e8f1fb;padding:12px 14px;font-size:14px;min-height:43px;
}
.catalog-filterbar input {flex:1 1 340px;min-width:0;}
.catalog-filterbar select {flex:0 1 180px;}
.catalog-filterbar input:focus-visible,.catalog-filterbar select:focus-visible {outline:2px solid #719dcc;outline-offset:1px;}
.catalog-grid-row .card-grid {
  display:grid;grid-template-columns:repeat(auto-fill,minmax(242px,1fr));
  grid-auto-flow:row;grid-auto-columns:auto;overflow:visible;align-items:stretch;
  gap:16px;padding:2px 4vw 14px 0;scroll-snap-type:none;
}
.catalog-grid-row .game-card {min-height:478px;}
.catalog-empty {padding:22px 4vw;color:#aab9cf;}
@media(max-width:620px){
  .catalog-browser{padding:18px 20px 4px;}
  .catalog-filterbar select{flex:1 1 45%;min-width:0;}
  .catalog-grid-row .card-grid{grid-template-columns:repeat(auto-fill,minmax(min(100%,242px),1fr));gap:12px;}
  .catalog-grid-row .game-card{min-height:462px;}
}
/* Badge wraps must not push descriptions/buttons out of alignment across a grid row. */
.game-card .badges {flex:0 0 52px;height:52px;min-height:52px;overflow:hidden;}


/* Keep the TOTP QR scannable and the longer enrollment form scrollable on phones. */
.authenticator-modal-card {
  box-sizing: border-box;
  max-height: min(90vh, 780px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.authenticator-qr-frame {
  width: fit-content;
  max-width: 100%;
  margin: 14px auto;
  padding: 10px;
  border-radius: 8px;
  background: #fff;
}
.authenticator-qr {
  display: block;
  width: min(70vw, 280px);
  height: auto;
  aspect-ratio: 1;
  image-rendering: pixelated;
}
.authenticator-modal-card input[readonly] {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  box-sizing: border-box;
  width: 100%;
}
@media (max-width: 520px) {
  .authenticator-modal-card { padding: 20px; }
  .modal-backdrop:has(.authenticator-modal-card) { padding: 12px; }
}

/* Profile settings incorporates TOTP enrollment rather than a standalone auth dialog. */
.profile-auth-section { margin-top: 18px; padding-top: 16px; border-top: 1px solid #354052; }
.profile-auth-section h3 { margin: 0 0 8px; font-size: 18px; }
.profile-auth-section p { color: #bac5d4; font-size: 13px; line-height: 1.5; }
#profile-editor-form { margin: 18px 0 0; }
#profile-editor-form .error { margin: 0; }
#profile-editor-email[disabled] { opacity: .72; }

.facebook-signin { width:100%; margin-top:12px; background:#1465cb; border-color:#2877d8; color:#fff; }
.facebook-signin:hover { background:#1877f2; }
#facebook-verify-notice { padding:12px; border-radius:8px; border:1px solid #30619d; background:#102844; }
