:root {
  color-scheme: dark;
  --ink: #08100d;
  --surface: #17221f;
  --surface-raised: #202f2a;
  --border: #394b43;
  --accent: #6fe0a4;
  --accent-strong: #9cf0c0;
  --foreground: #f0f5f1;
  --muted: #b5c4ba;
  --danger: #ee8f77;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
*[hidden] { display: none !important; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
  color: var(--foreground);
}

button { font: inherit; }

#app-shell {
  width: 100%;
  height: 100%;
  min-width: 320px;
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
  background:
    radial-gradient(circle at 20% -20%, rgba(111, 224, 164, 0.14), transparent 38%),
    var(--ink);
}

#browser-header {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 10px max(18px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left));
  border-bottom: 1px solid rgba(111, 224, 164, 0.18);
  background: rgba(8, 16, 13, 0.92);
}

#browser-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
#browser-brand > span:last-child { display: flex; flex-direction: column; min-width: 0; }
#browser-brand strong { font-size: 14px; line-height: 1.2; letter-spacing: 0.12em; white-space: nowrap; }
#browser-brand small { margin-top: 4px; color: var(--muted); font-size: 10px; letter-spacing: 0.14em; white-space: nowrap; }

#browser-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(111, 224, 164, 0.68);
  border-radius: 11px;
  color: var(--accent);
  background: rgba(111, 224, 164, 0.08);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

#fullscreen-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--foreground);
  background: var(--surface);
  cursor: pointer;
}

#fullscreen-button:hover:not(:disabled), #fullscreen-button:focus-visible { border-color: var(--accent); background: var(--surface-raised); }
#fullscreen-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#fullscreen-button:disabled { opacity: 0.5; cursor: default; }

#game-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--ink); }
#unity-canvas { width: 100%; height: 100%; display: block; border: 0; background: var(--ink); outline: none; }
#unity-canvas:focus-visible { box-shadow: inset 0 0 0 2px rgba(111, 224, 164, 0.6); }

#startup-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, rgba(8, 16, 13, 0.88), rgba(8, 16, 13, 0.97));
}

#startup-panel[hidden] { display: none; }
#startup-card { width: min(460px, 100%); padding: 28px; border: 1px solid var(--border); border-radius: 18px; background: rgba(23, 34, 31, 0.96); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32); }
#startup-panel[data-mode="error"] #startup-card { border-left: 4px solid var(--danger); }
#startup-eyebrow { display: block; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: 0.14em; }
#startup-title { margin: 12px 0 0; font-size: clamp(25px, 4vw, 34px); line-height: 1.1; }
#startup-detail { min-height: 44px; margin: 12px 0 20px; color: var(--muted); font-size: 15px; line-height: 1.45; }
#progress-track { width: 100%; height: 8px; overflow: hidden; border-radius: 999px; background: #0d1713; }
#progress-value { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #42b77b, var(--accent-strong)); transition: width 120ms ease-out; }
#progress-label { display: block; margin-top: 9px; color: var(--muted); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }

#unity-warning { position: absolute; top: 16px; left: 50%; z-index: 4; width: min(680px, calc(100% - 32px)); transform: translateX(-50%); pointer-events: none; }
#unity-warning > div { margin-bottom: 8px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; color: var(--foreground); background: var(--surface-raised); box-shadow: 0 12px 36px rgba(0, 0, 0, 0.3); }
#unity-warning > .error { border-color: var(--danger); }

@media (max-width: 640px) {
  #app-shell { grid-template-rows: 54px minmax(0, 1fr); }
  #browser-header { padding-top: 8px; padding-bottom: 8px; }
  #browser-mark { width: 34px; height: 34px; border-radius: 9px; }
  #browser-brand strong { font-size: 12px; }
  #fullscreen-button > span:last-child { display: none; }
  #fullscreen-button { min-width: 38px; justify-content: center; padding: 0 10px; }
  #startup-panel { padding: 16px; }
  #startup-card { padding: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  #progress-value { transition: none; }
}
