:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #182033;
  --muted: #64748b;
  --line: #d9e2ef;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --danger: #b91c1c;
  --success: #166534;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

input,
textarea,
button {
  font: inherit;
}

label {
  display: grid;
  gap: 8px;
  color: #334155;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--ink);
  background: #fff;
}

textarea {
  resize: vertical;
}

button,
.primary {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  padding: 12px 16px;
  font-weight: 800;
  cursor: pointer;
  text-align: center;
}

button:hover,
.primary:hover {
  background: var(--accent-strong);
}

.secondary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-strong);
  padding: 12px 16px;
  font-weight: 900;
  cursor: pointer;
  text-align: center;
}

.secondary:hover {
  background: #ecfeff;
}

.compact {
  padding: 10px 14px;
}

.muted {
  color: var(--muted);
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.auth-body {
  background:
    linear-gradient(rgba(13, 24, 36, .58), rgba(13, 24, 36, .7)),
    url("https://images.unsplash.com/photo-1550745165-9bc0b252726f?auto=format&fit=crop&w=1800&q=80") center/cover;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(430px, 100%);
  background: rgba(255, 255, 255, .94);
  border: 1px solid rgba(255, 255, 255, .4);
  border-radius: 8px;
  padding: 32px;
  box-shadow: 0 20px 55px rgba(15, 23, 42, .28);
}

.auth-panel h1,
.page-header h1 {
  margin: 0;
  line-height: 1.05;
}

.stack,
.creator-form {
  display: grid;
  gap: 16px;
}

.switch {
  margin: 20px 0 0;
  color: var(--muted);
}

.switch a,
.nav-actions a {
  color: var(--accent-strong);
  font-weight: 800;
}

.notice {
  border-radius: 8px;
  padding: 12px 14px;
  margin: 18px 0;
  font-weight: 700;
}

.notice.error {
  color: var(--danger);
  background: #fee2e2;
}

.notice.success {
  color: var(--success);
  background: #dcfce7;
}

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 28px;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.brand {
  font-size: 20px;
  font-weight: 900;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.profile-trigger,
.icon-button {
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  width: auto;
  font-weight: 900;
  cursor: pointer;
}

.profile-trigger:hover {
  color: var(--accent-strong);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  font-weight: 900;
  font-size: 13px;
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 56px;
}

.page.narrow {
  width: min(720px, calc(100% - 32px));
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  margin-bottom: 24px;
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.game-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
}

.game-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 40px rgba(15, 23, 42, .12);
}

.game-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #0f172a;
}

.game-card div {
  padding: 16px;
}

.game-card h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.game-card p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.45;
}

.game-card span {
  font-size: 13px;
  color: #475569;
  font-weight: 800;
}

.creator-form {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

.viewer-body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #030712;
}

.game-frame {
  width: 100vw;
  height: 100vh;
  border: 0;
  display: block;
}

.sidebar-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 30;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 8px;
  background: rgba(15, 23, 42, .82);
}

.settings-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: min(300px, 86vw);
  height: 100vh;
  z-index: 20;
  background: rgba(248, 250, 252, .96);
  border-left: 1px solid var(--line);
  padding: 74px 20px 20px;
  transform: translateX(100%);
  transition: transform .2s ease;
  display: grid;
  align-content: start;
  gap: 12px;
}

.sidebar-open .settings-sidebar {
  transform: translateX(0);
}

.settings-sidebar h2 {
  margin: 0;
}

.settings-sidebar a {
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 800;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, .54);
}

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

.modal-card {
  width: min(560px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
}

.modal-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.modal-header h2 {
  margin: 0;
}

.icon-button {
  font-size: 28px;
  line-height: 1;
}

.toggle-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.toggle-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.texture-list {
  max-height: 150px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.texture-option {
  min-height: 78px;
  border: 2px solid transparent;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  color: white;
  display: grid;
  align-items: end;
  padding: 8px;
  text-shadow: 0 1px 3px rgba(0,0,0,.55);
}

.texture-option.selected {
  border-color: var(--accent);
}

.face-preview {
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
}

@media (max-width: 720px) {
  .topbar,
  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    height: auto;
    padding: 16px;
  }

  .nav-actions {
    justify-content: flex-start;
  }

  .auth-panel {
    padding: 24px;
  }
}
