:root {
  color-scheme: dark;
  --bg: #020617;
  --panel: rgba(15, 23, 42, .78);
  --panel2: rgba(30, 41, 59, .72);
  --line: rgba(148, 163, 184, .18);
  --text: #e5eef8;
  --muted: #94a3b8;
  --accent: #0ea5e9;
  --accent2: #38bdf8;
  --danger: #fb7185;
  --ok: #86efac;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
  background: radial-gradient(circle at 50% -20%, #1e293b 0%, #020617 78%);
  min-height: 100vh;
}
button, input { font: inherit; }
.stars {
  position: fixed; inset: 0; pointer-events: none; opacity: .25;
  background-image:
    radial-gradient(circle, #fff 1px, transparent 1px),
    radial-gradient(circle, #fff 1px, transparent 1px);
  background-size: 83px 83px, 127px 127px;
  background-position: 0 0, 37px 51px;
}
.shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 60px; position: relative; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 22px; }
.eyebrow { font-size: 11px; letter-spacing: .22em; color: var(--accent2); font-weight: 800; }
h1 { margin: 4px 0 0; font-size: clamp(30px, 5vw, 54px); letter-spacing: -.05em; }
h2 { margin: 0; font-size: clamp(26px, 4vw, 44px); letter-spacing: -.04em; }
h3 { margin: 0 0 10px; }
p { color: var(--muted); line-height: 1.65; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 28px 70px rgba(0,0,0,.28);
  backdrop-filter: blur(24px);
}
.hero { padding: clamp(22px, 4vw, 42px); }
.hero-copy { max-width: 800px; }
.status-pill {
  border: 1px solid var(--line); background: rgba(15,23,42,.72);
  border-radius: 999px; padding: 9px 13px; color: var(--muted); font-size: 13px;
}
.status-pill.ok { color: var(--ok); border-color: rgba(134,239,172,.3); }
.status-pill.bad { color: #fecdd3; border-color: rgba(251,113,133,.35); }
.privacy-row {
  margin: 28px 0; display: grid; grid-template-columns: repeat(3, auto 1fr);
  gap: 8px 12px; padding: 15px; border-radius: 16px; background: rgba(2,6,23,.45);
  border: 1px solid var(--line); font-size: 13px;
}
.privacy-row span { color: var(--muted); }
.privacy-row strong { color: var(--ok); }
.engine-card {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
}
.engine-card > div { background: rgba(2,6,23,.56); padding: 17px; }
.label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.drop {
  display: grid; place-items: center; text-align: center; min-height: 170px;
  margin-top: 22px; border: 1px dashed rgba(56,189,248,.45); border-radius: 20px;
  background: rgba(14,165,233,.05); cursor: pointer; transition: .18s ease;
}
.drop:hover, .drop.drag { border-color: var(--accent2); background: rgba(14,165,233,.10); transform: translateY(-1px); }
.drop input { display: none; }
.drop-title { font-weight: 800; font-size: 19px; }
.drop-sub { margin-top: 8px; color: var(--muted); font-size: 13px; }
.disc-info {
  margin-top: 18px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
}
.disc-info > div { padding: 14px; background: rgba(2,6,23,.48); border: 1px solid var(--line); border-radius: 14px; }
.disc-info span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.progress-wrap { margin-top: 20px; }
.progress-head { display: flex; justify-content: space-between; gap: 15px; font-size: 13px; }
.progress { height: 10px; overflow: hidden; background: rgba(148,163,184,.12); border-radius: 999px; margin-top: 9px; }
.progress > div { width: 0%; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .12s linear; }
.progress-detail { margin-top: 7px; color: var(--muted); font-size: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.actions.compact { margin-top: 0; }
button {
  border: 1px solid var(--line); color: var(--text); background: var(--panel2);
  border-radius: 12px; padding: 11px 15px; cursor: pointer;
}
button:hover:not(:disabled) { border-color: rgba(56,189,248,.45); }
button.primary { background: linear-gradient(135deg, #0284c7, #0ea5e9); border-color: rgba(56,189,248,.4); font-weight: 800; }
button.danger { color: #fecdd3; }
button.ghost { background: transparent; }
button:disabled { opacity: .42; cursor: not-allowed; }
.notice { margin: 17px 0 0; font-size: 13px; }
.game { padding: 14px; }
.game-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 6px 5px 14px; }
.fps-toggle { color: var(--muted); font-size: 12px; user-select: none; margin-right: 10px; }
.fps-toggle input { accent-color: #38bdf8; }
/* Keep the 16:9 WebGL canvas intact; engine outputs a centered 4:3 image with bars. */
.canvas-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  max-width: 1100px;
  height: auto;
  margin-inline: auto;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  line-height: 0;
}
#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  outline: none;
  background: #000;
}
.fps-counter { position: absolute; z-index: 20; top: 12px; left: 12px; padding: 5px 8px; border-radius: 6px; background: rgba(0,0,0,.82); color: #86efac; font: 700 12px ui-monospace, monospace; pointer-events: none; }
/* Fullscreen is requested on #game-panel (an ID, not a .game-panel class). */
#game-panel:fullscreen {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  max-width: none;
  padding: 8px;
  border: 0;
  border-radius: 0;
  background: #000;
}
#game-panel:fullscreen .canvas-wrap {
  width: min(100%, calc((100dvh - 16px) * 16 / 9));
  max-width: none;
  flex: 0 0 auto;
  border: 0;
  border-radius: 0;
}
#game-panel:fullscreen .game-help,
#game-panel:fullscreen .game-toolbar > div:first-child,
#game-panel:fullscreen .fps-toggle { display: none; }
#game-panel:fullscreen .game-toolbar {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 30;
  padding: 0;
  margin: 0;
}
#game-panel:fullscreen #fullscreen-btn {
  opacity: .65;
  background: rgba(0,0,0,.65);
}
#game-panel:fullscreen #fullscreen-btn:hover,
#game-panel:fullscreen #fullscreen-btn:focus-visible { opacity: 1; }
.game-help { display: none; }
.game-help { color: var(--muted); font-size: 12px; padding: 10px 4px 2px; }
.tech { margin-top: 18px; padding: 24px; }
.tech p { margin-bottom: 0; }
.hidden { display: none !important; }
@media (max-width: 760px) {
  .shell { width: min(100% - 20px, 1180px); padding-top: 20px; }
  .topbar { align-items: flex-start; }
  .status-pill { max-width: 48%; text-align: right; }
  .privacy-row { grid-template-columns: auto 1fr; }
  .engine-card, .disc-info { grid-template-columns: 1fr 1fr; }
  .game-toolbar { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 480px) {
  .engine-card, .disc-info { grid-template-columns: 1fr; }
}

/* Native graphics options are configured before the WASM engine starts. */
.graphics-settings { display:flex; gap:10px 18px; align-items:center; flex-wrap:wrap; margin:4px 4px 12px; padding:10px 12px; border:1px solid var(--line); border-radius:12px; }
.graphics-settings label { display:flex; gap:7px; align-items:center; font-size:12px; color:var(--muted); }
.graphics-settings input[type="number"] { width:64px; background:var(--panel2); border:1px solid var(--line); color:var(--text); border-radius:6px; padding:5px; }
.graphics-settings select { background:var(--panel2); border:1px solid var(--line); color:var(--text); border-radius:6px; padding:6px; }
.graphics-settings small { flex-basis:100%; font-size:11px; color:var(--muted); }
.graphics-settings.locked { opacity:.7; }


/* Browser Edition header and native information dialogs (v0.4). */
.brand-lockup { min-width: 0; }
.brand-subtitle { margin: 8px 0 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.eyebrow-sep { color: #64748b; margin: 0 5px; }
.topbar { align-items: flex-start; }
.topbar-side { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.header-nav { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 7px; }
.nav-button { white-space: nowrap; background: rgba(15,23,42,.74); border: 1px solid rgba(148,163,184,.24); border-radius: 999px; padding: 9px 12px; font-size: 12px; font-weight: 650; transition: background .15s ease, border-color .15s ease; }
.nav-button:hover:not(:disabled), .nav-button:focus-visible { background: rgba(14,165,233,.13); border-color: rgba(56,189,248,.65); }
.nav-button-subtle { color: #bae6fd; }
.topbar-side .status-pill { font-size: 11px; padding: 7px 11px; }
.tech-headline { display: flex; justify-content: space-between; align-items: center; gap: 15px; }
.tech-headline p { margin: 0; }
.tech-details { flex: none; font-size: 12px; color: var(--accent2); }
:focus-visible { outline: 2px solid #7dd3fc; outline-offset: 3px; }

.info-dialog {
  color: var(--text); background: #0d1729; border: 1px solid rgba(148,163,184,.26);
  padding: 0; width: min(590px, calc(100% - 30px)); max-height: min(83vh, 780px);
  border-radius: 20px; box-shadow: 0 36px 100px rgba(0,0,0,.75);
  overflow: auto; overscroll-behavior: contain;
}
.info-dialog::backdrop { background: rgba(0,4,13,.78); backdrop-filter: blur(7px); }
.dialog-inner { padding: clamp(20px,4vw,32px); }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; border-bottom: 1px solid var(--line); padding-bottom: 18px; margin-bottom: 20px; }
.dialog-heading h2 { font-size: clamp(23px,4vw,31px); margin: 4px 0 0; line-height: 1.2; }
.dialog-kicker { color: #38bdf8; font-size: 10px; font-weight: 800; letter-spacing: .15em; }
.dialog-close { display: grid; place-items: center; flex: none; border-radius: 50%; width: 36px; height: 36px; padding: 0; font-size: 26px; line-height: 1; background: rgba(148,163,184,.12); }
.info-dialog p { font-size: 14px; margin: 0 0 15px; }
.info-dialog h3 { color: var(--text); font-size: 15px; margin: 22px 0 7px; }
.dialog-lead { font-size: 16px !important; color: #cbd5e1; }
.dialog-lead strong { color: #fff; }
.dialog-note { background: rgba(14,165,233,.08); border: 1px solid rgba(56,189,248,.16); border-radius: 12px; padding: 12px 14px; margin: 18px 0 0 !important; color: #cbd5e1; }
.dialog-feature-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.dialog-feature-grid > div { display: flex; flex-direction: column; gap: 5px; padding: 14px; background: rgba(30,41,59,.6); border-radius: 12px; border: 1px solid var(--line); }
.dialog-feature-grid strong { font-size: 14px; }
.dialog-feature-grid span { color: var(--muted); font-size: 12px; line-height: 1.55; }
.dialog-steps { list-style: none; margin: 0; padding: 0; counter-reset: step; display: grid; gap: 15px; }
.dialog-steps li { position: relative; padding-left: 44px; counter-increment: step; display: flex; flex-direction: column; gap: 5px; }
.dialog-steps li::before { content: counter(step); position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: rgba(14,165,233,.18); color: #7dd3fc; font-weight: 800; }
.dialog-steps li strong { font-size: 14px; }
.dialog-steps li span { font-size: 13px; line-height: 1.65; color: var(--muted); }
.info-dialog code { background: rgba(148,163,184,.13); color: #bae6fd; border-radius: 4px; padding: 1px 4px; overflow-wrap: anywhere; }
.control-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.control-grid > div { display: flex; flex-direction: column; gap: 10px; padding: 14px; background: rgba(30,41,59,.5); border: 1px solid var(--line); border-radius: 12px; }
.control-grid > div > span { color: var(--muted); font-size: 12px; }
.control-grid strong { font-size: 13px; line-height: 2.1; }
.control-grid kbd { display: inline-block; border-radius: 6px; border: 1px solid #526076; background: #253247; padding: 0px 7px; box-shadow: 0 2px 0 #101827; font: 600 12px ui-monospace, SFMono-Regular, Consolas, monospace; }
.key-or { font-weight: 400; color: var(--muted); }
.compat-list { display: grid; gap: 0; }
.compat-list > div { display: grid; grid-template-columns: 132px 1fr; gap: 18px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.compat-list > div:last-child { border-bottom: none; }
.compat-list strong { font-size: 13px; }
.compat-list span { color: var(--muted); font-size: 13px; line-height: 1.6; }
@media (max-width: 1000px) {
  .topbar { flex-direction: column; }
  .topbar-side { align-items: flex-start; width: 100%; }
  .header-nav { justify-content: flex-start; }
}
@media (max-width: 520px) {
  .header-nav { gap: 6px; }
  .nav-button { font-size: 11px; padding: 8px 10px; }
  .topbar-side .status-pill { max-width: 100%; }
  .dialog-feature-grid, .control-grid { grid-template-columns: 1fr; }
  .compat-list > div { grid-template-columns: 1fr; gap: 4px; }
  .tech-headline { flex-direction: column; align-items: flex-start; }
}
