:root {
  --bg: #120a1f;
  --bg2: #1a1330;
  --panel: #261b45;
  --panel2: #1a1231;
  --text: #f8f5de;
  --muted: #c6c1a0;
  --green: #c7f07b;
  --cyan: #77d9ff;
  --pink: #ff7ab6;
  --orange: #ffb24d;
  --gold: #ffe08a;
  --line: #5b4c85;
  --shadow: rgba(0,0,0,.38);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  font-family: "Trebuchet MS", "Verdana", system-ui, sans-serif;
  background:
    linear-gradient(180deg, rgba(255,255,255,.03) 0 1px, transparent 1px 4px),
    radial-gradient(circle at 15% 10%, rgba(255,122,182,.18), transparent 18%),
    radial-gradient(circle at 80% 15%, rgba(119,217,255,.14), transparent 20%),
    linear-gradient(180deg, #0d0820, #17102b 45%, #0f0a20 100%);
  min-height: 100vh;
}

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

.container {
  width: min(1400px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 36px;
}

.plex-shell {
  width: min(1500px, calc(100% - 40px));
  margin: 0 auto;
  padding: 18px 0 36px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(8px);
  background: rgba(13, 8, 32, 0.72);
  border-bottom: 1px solid rgba(255,255,255,.05);
}

.brand-wrap, .hero-actions, .header-links, .slot-controls, .slot-status {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.brand {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: .08em;
}
.subbrand {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .14em;
}
.brand-badge {
  min-width: 58px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 2px solid rgba(119,217,255,.35);
  background: rgba(119,217,255,.08);
  color: var(--cyan);
  font-weight: 900;
  text-align: center;
}

.ghost-btn, .play-btn, .pill, button, input, select {
  border: 2px solid rgba(119,217,255,.25);
  border-radius: 10px;
  background: rgba(255,255,255,.03);
  color: var(--text);
  font: inherit;
}

.ghost-btn, .play-btn, button {
  padding: 10px 14px;
  min-height: 42px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}
.ghost-btn:hover, .play-btn:hover, button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(0,0,0,.22);
}
.play-btn {
  border-color: rgba(199,240,123,.45);
  color: var(--green);
}

.pill {
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

input, select {
  width: 100%;
  padding: 10px 12px;
}

.panel {
  background: linear-gradient(180deg, rgba(38,27,69,.95), rgba(26,18,49,.96));
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 18px;
  box-shadow: 0 16px 32px var(--shadow);
  padding: 16px;
}

.hero {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 20px;
  align-items: center;
}

.eyebrow {
  color: var(--orange);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .14em;
  margin-bottom: 6px;
}

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

.dash-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-item {
  cursor: pointer;
  transition: all .15s ease;
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: linear-gradient(180deg, var(--panel), var(--panel2));
}
.list-item:hover {
  transform: translateY(-2px) scale(1.01);
  border-color: var(--cyan);
  background: linear-gradient(180deg, #2a1f4f, #1c1436);
  box-shadow: 0 0 12px rgba(119,217,255,.35), 0 0 24px rgba(119,217,255,.15), 0 6px 18px rgba(0,0,0,.4);
}
.list-item:hover strong { color: var(--cyan); }
.list-item:hover span { color: #e6faff; }
.muted { color: var(--muted); }

.account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 16px;
}
.stack-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.plex-home {
  background:
    radial-gradient(circle at 10% 10%, rgba(119,217,255,.10), transparent 18%),
    radial-gradient(circle at 80% 10%, rgba(255,122,182,.10), transparent 18%),
    linear-gradient(180deg, #0b0913 0%, #100d1e 50%, #0d0b17 100%);
}
.plex-hero {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 20px;
  align-items: center;
  padding: 18px 0 10px;
}
.plex-title {
  font-size: clamp(2.4rem, 5vw, 4.8rem);
  line-height: .9;
  margin: 0 0 10px;
}
.plex-subtitle {
  color: var(--muted);
  font-size: 1rem;
  max-width: 720px;
}
.plex-hero-art {
  display: flex;
  justify-content: center;
  align-items: center;
}
.plex-art-card {
  position: relative;
  width: 280px;
  height: 280px;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}
.plex-art-glow {
  position: absolute;
  width: 180px;
  height: 180px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(119,217,255,.22), transparent 70%);
  filter: blur(10px);
}
.plex-art-inner {
  position: relative;
  font-size: 72px;
}
.plex-controls {
  margin-bottom: 18px;
}
.plex-filter { min-width: 220px; flex: 0 0 220px; }
.plex-search { flex: 1 1 auto; }
.toolbar-row {
  display: flex;
  gap: 14px;
  align-items: end;
  flex-wrap: wrap;
}
.plex-row-wrap { margin-bottom: 24px; }
.plex-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.small-btn {
  padding: 8px 12px !important;
  min-height: auto !important;
  font-size: 12px !important;
}
.plex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
}
.plex-card { min-width: 0; }
.plex-card-link { display: block; color: inherit; text-decoration: none; }
.plex-cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.015));
}
.plex-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.plex-cover-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 46px;
  color: var(--muted);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
}
.plex-card-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8,16,29,.78);
  color: var(--cyan);
  font-weight: 900;
  letter-spacing: .08em;
  opacity: 0;
  transition: opacity .15s ease;
  pointer-events: none;
}
.plex-card-link:hover .plex-card-overlay { opacity: 1; }
.plex-card-copy { padding: 10px 4px 0; }
.plex-rom-title {
  display: block;
  font-size: .95rem;
  line-height: 1.2;
  max-height: 2.4em;
  overflow: hidden;
}
.plex-rom-meta {
  display: block;
  color: var(--muted);
  font-size: .82rem;
  margin-top: 4px;
}

.achievement-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px,1fr));
  gap: 10px;
}
.achievement-pill {
  border: 2px solid rgba(255,178,77,.35);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255,178,77,.07);
}
.achievement-pill strong {
  display: block;
  color: var(--gold);
}
.achievement-pill span {
  color: var(--muted);
  font-size: .92rem;
}

.rom-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.rom-cover-wrap {
  flex: 0 0 44px;
  width: 44px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rom-cover {
  width: 44px;
  height: 58px;
  object-fit: cover;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.03);
}
.rom-cover-placeholder {
  width: 44px;
  height: 58px;
  border: 2px solid var(--line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  color: var(--muted);
}
.rom-meta {
  min-width: 0;
  flex: 1 1 auto;
}
.rom-meta strong { display: block; }
.rom-meta span { color: var(--muted); }
.rom-list-scroll {
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 6px;
}
.rom-list-scroll::-webkit-scrollbar { width: 10px; }
.rom-list-scroll::-webkit-scrollbar-track {
  background: rgba(255,255,255,.04);
  border-radius: 10px;
}
.rom-list-scroll::-webkit-scrollbar-thumb {
  background: rgba(119,217,255,.35);
  border-radius: 10px;
}
.rom-list-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(119,217,255,.55);
}

.play-page .compact-panel { padding: 14px; }
.play-title {
  font-size: clamp(1.6rem, 3vw, 3rem);
  line-height: .96;
}
.compact-hint {
  color: var(--muted);
}
.compact-toolbar {
  padding: 10px;
  margin-bottom: 10px;
}
.save-row-wrap {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 12px;
  align-items: center;
}
.save-button-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.save-select-btn {
  position: relative;
  overflow: visible !important;
  min-width: 0 !important;
  width: 100% !important;
  min-height: 46px !important;
  height: 46px !important;
  padding: 10px 14px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
}
.save-select-btn .slot-main-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  color: #111;
  font-weight: 900;
}
.save-select-btn .slot-hover-ts {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  display: none;
  white-space: nowrap;
  z-index: 500;
  pointer-events: none;
  padding: 8px 12px;
  border-radius: 8px;
  border: 2px solid rgba(255,178,77,.45);
  background: #111;
  color: #fff2c7;
  font-size: 12px;
  line-height: 1;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.save-select-btn:hover .slot-hover-ts { display: block; }
.save-select-btn.is-active {
  background: var(--green) !important;
  border-color: rgba(125,255,137,.55) !important;
  box-shadow: 0 0 0 3px rgba(125,255,137,.14) !important;
}
.save-side-controls {
  display: flex;
  gap: 8px;
  min-width: 240px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.side-action-btn {
  min-width: 96px !important;
  min-height: 46px !important;
  height: 46px !important;
  padding: 10px 14px !important;
  font-weight: 900 !important;
}
.compact-pill {
  min-width: 86px !important;
  min-height: 38px !important;
  padding: 9px 12px !important;
  font-size: 12px !important;
  font-weight: 900 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.screen-wrap {
  margin-top: 12px;
}
.emulator-mock {
  min-height: 420px;
  border: 2px dashed rgba(119,217,255,.22);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.01));
  display: flex;
  align-items: center;
  justify-content: center;
}
.emulator-overlay {
  text-align: center;
  max-width: 620px;
  padding: 20px;
}
.emulator-logo {
  font-size: 2rem;
  font-weight: 900;
  margin-bottom: 10px;
}
.emulator-sub {
  color: var(--muted);
}
.emulator-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
  flex-wrap: wrap;
}

@media (max-width: 980px) {
  .plex-hero, .hero, .grid, .account-grid {
    grid-template-columns: 1fr;
  }
  .save-row-wrap {
    grid-template-columns: 1fr;
  }
  .save-side-controls {
    justify-content: flex-start;
    min-width: 0;
  }
  .save-button-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 640px) {
  .save-button-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .container, .plex-shell {
    width: min(100% - 20px, 1500px);
  }
}
