:root {
  color-scheme: dark;
  --bg: #071117;
  --surface: rgba(7, 20, 26, 0.92);
  --surface-2: rgba(9, 30, 38, 0.96);
  --line: rgba(164, 231, 211, 0.16);
  --ink: #edf6f4;
  --muted: rgba(237, 246, 244, 0.72);
  --accent: #82ffd3;
  --accent-2: #62d7ff;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #020508; color: var(--ink); font-family: "Avenir Next", "Segoe UI", sans-serif; }
body { overflow: hidden; }
a { color: inherit; }

.app-shell {
  position: relative;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(130, 255, 211, 0.1), transparent 26%),
    radial-gradient(circle at top right, rgba(98, 215, 255, 0.12), transparent 22%),
    linear-gradient(180deg, #031017 0%, #02070a 44%, #010305 100%);
}

#player-frame {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #020406;
}

.hud {
  position: fixed;
  inset: 18px 18px auto 18px;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.brand-lockup,
.hud-actions,
.library-card,
.upload-card,
.rom-card button {
  pointer-events: auto;
}

.hud-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(6, 18, 24, 0.72);
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  backdrop-filter: blur(16px);
}

.back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(6, 18, 24, 0.72);
  color: var(--muted);
  text-decoration: none;
  backdrop-filter: blur(12px);
  flex-shrink: 0;
  align-self: center;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  pointer-events: auto;
}

.back-button:hover {
  color: var(--accent);
  border-color: rgba(130, 255, 211, 0.4);
  background: rgba(130, 255, 211, 0.08);
}

.brand-lockup {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  max-width: min(720px, calc(100vw - 140px));
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(5, 14, 18, 0.72);
  backdrop-filter: blur(16px);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

.brand-pill,
.upload-badge,
.section-kicker,
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(130, 255, 211, 0.2);
  background: rgba(130, 255, 211, 0.12);
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.74rem;
  font-weight: 800;
}

.brand-lockup h1,
.library-head h2 {
  margin: 2px 0 6px;
  font-size: clamp(1.3rem, 3vw, 2rem);
}

.brand-lockup p,
.library-copy,
.status-line,
.rom-meta,
.current-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.hud-button,
.rom-actions button,
.close-button,
.slot-actions button,
.profile-pill {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(6, 18, 24, 0.78);
  color: var(--ink);
  border-radius: 999px;
  min-height: 48px;
  padding: 0 18px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  backdrop-filter: blur(16px);
}

.hud-button:hover,
.rom-actions button:hover,
.close-button:hover,
.slot-actions button:hover,
.profile-pill:hover {
  border-color: rgba(130, 255, 211, 0.34);
}

.primary-button {
  background: rgba(130, 255, 211, 0.14);
  color: var(--accent);
}

.mini-button {
  min-height: 38px;
  padding: 0 14px;
  font-size: 0.88rem;
}

.library-panel {
  position: fixed;
  top: 18px;
  right: 18px;
  bottom: 18px;
  width: min(420px, calc(100vw - 36px));
  z-index: 12;
  display: grid;
  transform: translateX(calc(100% + 24px));
  transition: transform 180ms ease;
}

.library-panel.is-open {
  transform: translateX(0);
}

.library-card {
  display: grid;
  grid-template-rows: auto auto auto auto auto auto minmax(0, 1fr);
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface-2);
  backdrop-filter: blur(18px);
  box-shadow: 0 30px 120px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.library-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.close-button {
  width: 48px;
  padding: 0;
  font-size: 1.5rem;
}

.upload-card {
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px dashed rgba(130, 255, 211, 0.28);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(130, 255, 211, 0.08), rgba(255,255,255,0.02));
  cursor: pointer;
}

.upload-card strong {
  font-size: 1.02rem;
}

.status-line {
  min-height: 1.4em;
}

.current-card {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255,255,255,0.03);
}

.library-section {
  display: grid;
  gap: 12px;
}

.slot-grid,
.profile-list {
  display: grid;
  gap: 10px;
}

.slot-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.025);
}

.slot-card strong,
.profile-editor-head strong {
  font-size: 0.98rem;
}

.slot-card span {
  color: var(--muted);
  font-size: 0.88rem;
}

.slot-actions,
.profile-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.slot-actions button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.85rem;
}

.profile-pill {
  justify-content: flex-start;
  min-height: 40px;
  padding: 0 14px;
  font-size: 0.9rem;
}

.profile-pill.is-active {
  border-color: rgba(130, 255, 211, 0.32);
  color: var(--accent);
  background: rgba(130, 255, 211, 0.1);
}

.profile-editor,
.login-form {
  display: grid;
  gap: 12px;
}

.profile-editor-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.profile-editor label,
.login-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.profile-editor input,
.login-form input {
  width: 100%;
  min-height: 42px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--ink);
  padding: 0 12px;
  font: inherit;
}

.binding-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.login-body {
  overflow: auto;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top, rgba(130, 255, 211, 0.12), transparent 32%),
    linear-gradient(180deg, #031017 0%, #02070a 44%, #010305 100%);
}

.login-card {
  width: min(100%, 460px);
  display: grid;
  gap: 16px;
  padding: 28px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: rgba(7, 20, 26, 0.88);
  box-shadow: 0 28px 120px rgba(0,0,0,0.42);
}

.login-card h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
}

.login-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.login-error {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 115, 135, 0.32);
  background: rgba(255, 115, 135, 0.1);
  color: #ffd0d8;
}

.rom-list {
  display: grid;
  gap: 12px;
  overflow: auto;
  padding-right: 4px;
}

.rom-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(0, 0, 0, 0.18);
}

.rom-card.is-current {
  border-color: rgba(130, 255, 211, 0.28);
  background: rgba(130, 255, 211, 0.08);
}

.rom-card h3 {
  margin: 0;
  font-size: 1rem;
}

.rom-meta {
  font-size: 0.88rem;
}

.rom-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.rom-actions button {
  min-height: 40px;
  padding: 0 14px;
  font-size: 0.92rem;
}

.rom-actions .primary {
  background: rgba(130, 255, 211, 0.14);
  color: var(--accent);
}

@media (max-width: 767px) {
  .hud {
    inset: 12px 12px auto 12px;
  }

  .brand-lockup {
    max-width: calc(100vw - 108px);
    padding: 12px 14px;
  }

  .brand-lockup p {
    display: none;
  }

  .library-panel {
    inset: auto 12px 12px 12px;
    width: auto;
    height: min(66vh, 560px);
    transform: translateY(calc(100% + 24px));
  }

  .library-panel.is-open {
    transform: translateY(0);
  }

  .library-card {
    grid-template-rows: auto auto auto auto auto auto minmax(0, 1fr);
    border-radius: 24px;
  }

  .binding-grid {
    grid-template-columns: 1fr;
  }
}
