/* ═══════════════════════════════════════════════════════════════════════════
   emulator.st — UI Refinements
   Autosave mini-dropdown, collapsible sections
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Autosave Mini Dropdown ────────────────────────────────────────────── */
.autosave-mini-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  z-index: 10;
}
.autosave-mini-btn {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 4px 7px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: .65rem; font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  line-height: 1;
}
.autosave-mini-btn:hover {
  border-color: var(--accent);
  color: var(--accent-bright);
}
.autosave-mini-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 14px; height: 14px;
  background: var(--accent);
  color: #fff;
  border-radius: 7px;
  font-size: .55rem; font-weight: 800;
  line-height: 1;
}
.autosave-mini-count:empty,
.autosave-mini-count[data-count="0"] { display: none; }

/* Dropdown panel */
.autosave-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  width: 280px;
  max-height: 0;
  overflow: hidden;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  opacity: 0;
  transform: translateY(-4px);
  transition: max-height .25s ease, opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
.autosave-dropdown.open {
  max-height: min(70vh, 420px);
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.autosave-dropdown.open::-webkit-scrollbar {
  width: 0;
  height: 0;
}
.autosave-kind-group {
  margin-bottom: 10px;
}
.autosave-kind-group:last-child {
  margin-bottom: 0;
}
.autosave-kind-label {
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--accent-bright);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 6px 0 4px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border);
}
.autosave-dropdown-header {
  padding: 8px 10px 4px;
  border-bottom: 1px solid var(--border);
}
.autosave-dropdown-body {
  padding: 4px 6px;
}

/* Autosave items inside mini dropdown */
.autosave-dropdown .autosave-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 6px;
  border-radius: 4px;
  font-size: .7rem;
  transition: background .12s;
}
.autosave-dropdown .autosave-item:hover { background: var(--bg-hover); }
.autosave-dropdown .autosave-time { font-size: .65rem; color: var(--text-dim); }
.autosave-dropdown .autosave-actions { display: flex; gap: 3px; }
.autosave-dropdown .autosave-actions .compact-btn {
  padding: 2px 6px; font-size: .58rem;
}
.autosave-dropdown .autosave-empty {
  text-align: center; padding: 10px;
  font-size: .68rem; color: var(--text-dim);
}
.autosave-dropdown .lkg-badge { font-size: .55rem; }

/* ─── Collapsible Sections ──────────────────────────────────────────────── */
.collapsible-section { }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.collapse-toggle {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  font-size: .75rem; font-weight: 700;
  cursor: pointer;
  transition: all .15s ease;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}
.collapse-toggle:hover {
  border-color: var(--accent);
  color: var(--accent-bright);
  background: rgba(108,92,231,.08);
}

.section-body {
  transition: opacity .2s ease;
}

/* ─── Onboarding steps ──────────────────────────────────────────────────── */
.onboard-steps {
  display: flex; flex-direction: column; gap: 14px;
  text-align: center;
}
.onboard-step p { font-size: .85rem; color: var(--text-dim); margin-top: 4px; }

/* Play page — player settings (grouped layout) */
.player-settings-panel {
  margin-top: 12px;
  padding: 16px 18px 18px;
  background: linear-gradient(165deg, var(--bg-panel) 0%, rgba(108, 92, 231, 0.06) 100%);
  border-color: rgba(108, 92, 231, 0.22);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}
.player-settings-header {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.player-settings-header .eyebrow {
  margin-bottom: 6px;
}
.player-settings-lede {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.5;
  max-width: 42rem;
}
.player-settings-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
  align-items: stretch;
}
.player-settings-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
/* Match column heights: stretch the bottom card in each column */
.player-settings-col .player-settings-section:last-child {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.player-settings-col .player-settings-section:last-child .player-settings-fields {
  flex: 1;
}
@media (max-width: 720px) {
  .player-settings-body {
    grid-template-columns: 1fr;
  }
}
.player-settings-section {
  padding: 12px 14px 14px;
  border-radius: var(--radius, 8px);
  border: 1px solid var(--border);
  background: var(--bg-card, rgba(0, 0, 0, 0.2));
}
.player-settings-section-title {
  margin: 0 0 10px;
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-bright);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.player-settings-badge {
  font-size: 0.52rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(108, 92, 231, 0.2);
  color: var(--accent-bright);
  border: 1px solid rgba(108, 92, 231, 0.35);
}
.player-settings-section-hint {
  margin: -4px 0 10px;
  font-size: 0.68rem;
}
.player-settings-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.player-settings-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.player-settings-field--row {
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
}
.player-settings-field--row input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--accent, #6c5ce7);
  width: 15px;
  height: 15px;
}
.player-settings-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text, #e8e6f0);
  line-height: 1.35;
}
.player-settings-sublabel {
  display: block;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-top: 2px;
}
.player-settings-field--row .player-settings-label .player-settings-sublabel {
  display: inline;
  margin-left: 4px;
  font-weight: 500;
}
.player-settings-select {
  width: 100%;
  max-width: 100%;
  padding: 8px 10px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius, 6px);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.player-settings-select:hover {
  border-color: rgba(108, 92, 231, 0.45);
}
.player-settings-select:focus {
  outline: none;
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 2px rgba(108, 92, 231, 0.25);
}
.player-settings-select--narrow {
  max-width: 11rem;
}
.player-settings-field--volume .player-settings-volume-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.player-settings-field--volume input[type="range"] {
  flex: 1;
  min-width: 0;
  height: 6px;
  accent-color: var(--accent-bright);
  border-radius: 3px;
}
.player-settings-volume-val {
  min-width: 2.2ch;
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-bright);
}
.player-settings-hotkeys {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.player-settings-hotkeys summary {
  cursor: pointer;
  user-select: none;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.player-settings-hotkeys summary::-webkit-details-marker {
  display: none;
}
.player-settings-hotkeys summary::before {
  content: "";
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 6px solid var(--accent-bright);
  transition: transform 0.15s ease;
  opacity: 0.85;
}
.player-settings-hotkeys[open] summary::before {
  transform: rotate(90deg);
}
.player-settings-hotkeys-body {
  margin-top: 10px;
}
.player-settings-hotkeys-body ul {
  margin: 0;
  padding-left: 1.15rem;
  line-height: 1.55;
  max-width: 40rem;
  font-size: 0.74rem;
}
.player-settings-hotkeys-body li + li {
  margin-top: 6px;
}
.player-settings-hotkeys-body kbd {
  font: 0.72rem ui-monospace, monospace;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.28);
}

.emu-screen-frame {
  position: relative;
}
.v5-fps-overlay {
  position: absolute;
  top: 6px;
  right: 8px;
  z-index: 12;
  font: 11px/1.25 ui-monospace, monospace;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 0 6px #000, 0 1px 2px #000;
  pointer-events: none;
  max-width: 70%;
  text-align: right;
}

.emu-screen-frame.v5-scanlines-light::after,
.emu-screen-frame.v5-scanlines-heavy::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 1px,
    rgba(0, 0, 0, 0.22) 1px,
    rgba(0, 0, 0, 0.22) 2px
  );
}
.emu-screen-frame.v5-scanlines-heavy::after {
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 1px,
    rgba(0, 0, 0, 0.38) 1px,
    rgba(0, 0, 0, 0.38) 2px
  );
}

html.v5-play-reduce-motion .emu-bezel-indicator {
  animation: none !important;
}

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .autosave-dropdown { width: 240px; }
  .autosave-mini-btn { padding: 3px 5px; }
  .player-settings-panel {
    padding: 14px 12px 16px;
  }
}

/* Rules page — minimal chrome when embedded in Social tab (iframe) */
body.rules-embed-body {
  margin: 0;
  min-height: 100%;
  background: var(--bg, #0d0d12);
}
main.rules-embed-main.container {
  padding: 10px 12px 16px;
  max-width: 720px;
  margin: 0 auto;
}

/* ═══ Mobile Play UX ═══ */
@media (max-width: 768px) {
  /* Compact header on mobile play page */
  body .topbar { padding: 4px 8px; }
  body .brand-wrap { gap: 6px; }
  body .brand-badge { width: 28px; height: 28px; font-size: .55rem; }
  body .brand { font-size: .75rem; }
  body .subbrand { font-size: .55rem; }

  /* Full-width emulator on mobile */
  .compact-container { padding: 0 !important; max-width: 100% !important; }
  .compact-panel { padding: 6px !important; border-radius: 0 !important; }
  .emu-bezel { border-radius: 0 !important; margin: 0 -6px !important; }
  .emu-screen-frame { border-radius: 0 !important; }
  #game { width: 100% !important; }
  #game canvas { width: 100% !important; height: auto !important; }

  /* Hide non-essential elements on mobile play */
  .play-title { font-size: .9rem !important; }
  .compact-hint { font-size: .65rem !important; }
  #gameInfoBar { flex-direction: column; gap: 4px; }
  .save-button-grid { gap: 3px !important; }
  .save-button-grid .ghost-btn { font-size: .55rem !important; padding: 4px 6px !important; }

  /* Stack save controls vertically */
  .save-row-wrap { flex-direction: column; gap: 6px; }
  .save-side-controls { justify-content: center; }

  /* Live stream panel compact */
  .live-stream-panel { padding: 8px !important; }
  .live-stream-title-input { font-size: .7rem !important; }
  .live-stream-actions { flex-wrap: wrap; }

  /* Similar games scroll horizontally */
  .continue-grid { display: flex !important; overflow-x: auto !important; gap: 8px !important; padding-bottom: 8px; }
  .continue-grid .rom-card { min-width: 120px; flex-shrink: 0; }

  /* Touch-friendly buttons */
  .ghost-btn, .play-btn { min-height: 36px; }
  .compact-btn { min-height: 32px; font-size: .65rem !important; }
}

/* Landscape mobile: maximize game area */
@media (max-width: 768px) and (orientation: landscape) {
  .topbar { display: none !important; }
  .compact-container { padding: 0 !important; }
  .compact-panel { padding: 0 !important; }
  #game { width: 100vw !important; height: 100vh !important; position: fixed; top: 0; left: 0; z-index: 100; }
  #game canvas { width: 100% !important; height: 100% !important; object-fit: contain; }
  .emu-bezel { display: none !important; }
  .panel:not(:has(#game)) { display: none !important; }
  /* Show a small "exit fullscreen" hint */
  body::after {
    content: "Rotate to portrait to see controls";
    position: fixed; bottom: 4px; left: 50%; transform: translateX(-50%);
    font-size: .55rem; color: rgba(255,255,255,.3); z-index: 101;
    pointer-events: none;
  }
}

/* ═══ Mobile Play UX ═══ */
@media (max-width: 768px) {
  /* Compact header on mobile play page */
  body .topbar { padding: 4px 8px; }
  body .brand-wrap { gap: 6px; }
  body .brand-badge { width: 28px; height: 28px; font-size: .55rem; }
  body .brand { font-size: .75rem; }
  body .subbrand { font-size: .55rem; }

  /* Full-width emulator on mobile */
  .compact-container { padding: 0 !important; max-width: 100% !important; }
  .compact-panel { padding: 6px !important; border-radius: 0 !important; }
  .emu-bezel { border-radius: 0 !important; margin: 0 -6px !important; }
  .emu-screen-frame { border-radius: 0 !important; }
  #game { width: 100% !important; }
  #game canvas { width: 100% !important; height: auto !important; }

  /* Hide non-essential elements on mobile play */
  .play-title { font-size: .9rem !important; }
  .compact-hint { font-size: .65rem !important; }
  #gameInfoBar { flex-direction: column; gap: 4px; }
  .save-button-grid { gap: 3px !important; }
  .save-button-grid .ghost-btn { font-size: .55rem !important; padding: 4px 6px !important; }

  /* Stack save controls vertically */
  .save-row-wrap { flex-direction: column; gap: 6px; }
  .save-side-controls { justify-content: center; }

  /* Live stream panel compact */
  .live-stream-panel { padding: 8px !important; }
  .live-stream-title-input { font-size: .7rem !important; }
  .live-stream-actions { flex-wrap: wrap; }

  /* Similar games scroll horizontally */
  .continue-grid { display: flex !important; overflow-x: auto !important; gap: 8px !important; padding-bottom: 8px; }
  .continue-grid .rom-card { min-width: 120px; flex-shrink: 0; }

  /* Touch-friendly buttons */
  .ghost-btn, .play-btn { min-height: 36px; }
  .compact-btn { min-height: 32px; font-size: .65rem !important; }
}

/* Landscape mobile: maximize game area */
@media (max-width: 768px) and (orientation: landscape) {
  .topbar { display: none !important; }
  .compact-container { padding: 0 !important; }
  .compact-panel { padding: 0 !important; }
  #game { width: 100vw !important; height: 100vh !important; position: fixed; top: 0; left: 0; z-index: 100; }
  #game canvas { width: 100% !important; height: 100% !important; object-fit: contain; }
  .emu-bezel { display: none !important; }
  .panel:not(:has(#game)) { display: none !important; }
  /* Show a small "exit fullscreen" hint */
  body::after {
    content: "Rotate to portrait to see controls";
    position: fixed; bottom: 4px; left: 50%; transform: translateX(-50%);
    font-size: .55rem; color: rgba(255,255,255,.3); z-index: 101;
    pointer-events: none;
  }
}

/* Fix save button line artifact */
.save-button-grid .ghost-btn.active,
.save-button-grid .ghost-btn:active,
.save-button-grid .ghost-btn[aria-pressed="true"] {
  box-shadow: none !important;
  border-bottom: none !important;
  text-decoration: none !important;
}
.save-button-grid .ghost-btn {
  box-shadow: none !important;
  text-decoration: none !important;
}

/* Favorite heart styling */
.card-fav-btn.fav-active { color: #e55; }
.card-fav-btn { transition: color 0.2s; cursor: pointer; }
.card-fav-btn:hover { color: #e88; }

/* Force both inner panels to fill container height + match padding */

/* Recent Saves: use panel styling to match Continue Playing */

/* Recent saves chip: no extra chrome, just a header */

/* When expanded, the panel grid */

/* Shrink cards in both sides */

/* Resume banner: slim down */

/* Minimal card style inside both sections */

/* Resume banner: compact */


/* Continue Playing: shrink the resume banner */
.home-hero-grid #resumeBanner .resume-inner {
  gap: 10px !important;
}

.home-hero-grid #resumeBanner .eyebrow {
  font-size: 0.6rem !important;
  margin-bottom: 2px !important;
}
.home-hero-grid #resumeBanner h2,
.home-hero-grid #resumeBanner #resumeTitle {
  font-size: 0.95rem !important;
  margin: 0 0 3px !important;
  line-height: 1.2;
}
.home-hero-grid #resumeBanner #resumeMeta,
.home-hero-grid #resumeBanner .hint {
  font-size: 0.65rem !important;
  margin: 0 0 6px !important;
}
.home-hero-grid #resumeBanner .play-btn,
.home-hero-grid #resumeBanner #resumeBtn {
  font-size: 0.7rem !important;
  padding: 4px 10px !important;
}

/* Recent Saves: shrink cards */
.home-hero-grid #recentSavesSimple .eyebrow {
  font-size: 0.6rem !important;
  margin-bottom: 6px !important;
}
.home-hero-grid #recentSavesSimple .continue-grid {
  gap: 6px !important;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)) !important;
}
.home-hero-grid #recentSavesSimple .continue-card {
  padding: 4px !important;
}
.home-hero-grid #recentSavesSimple .continue-card img,
.home-hero-grid #recentSavesSimple .continue-card-art {
  width: 100% !important;
  max-height: 80px !important;
  object-fit: cover;
  border-radius: 3px;
}
.home-hero-grid #recentSavesSimple .continue-card-title {
  font-size: 0.65rem !important;
  line-height: 1.15;
  margin-top: 3px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.home-hero-grid #recentSavesSimple .continue-card-meta,
.home-hero-grid #recentSavesSimple .continue-card-sub {
  font-size: 0.55rem !important;
  line-height: 1.1;
  opacity: 0.7;
}

@media (max-width: 900px) {
  .home-hero-grid {
    grid-template-columns: 1fr;
  }
}

/* Home hero panel: Continue Playing + Recent Saves in ONE shared box */
.home-hero-panel {
  margin-bottom: 12px !important;
  padding: 12px !important;
}

.home-hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

/* Left column: Continue Playing — strip its own styling since the parent panel has it */
.home-hero-col--continue #resumeBanner {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
  box-shadow: none !important;
}

.home-hero-col--continue .resume-inner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.home-hero-col--continue .resume-art {
  flex-shrink: 0;
  width: 70px;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: 4px;
  background: rgba(0,0,0,0.2);
}

.home-hero-col--continue #resumeArt,
.home-hero-col--continue .resume-art img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
  display: block;
}

.home-hero-col--continue .resume-copy {
  flex: 1;
  min-width: 0;
}

.home-hero-col--continue .eyebrow {
  font-size: 0.6rem !important;
  margin: 0 0 3px !important;
}

.home-hero-col--continue h2,
.home-hero-col--continue #resumeTitle {
  font-size: 0.95rem !important;
  margin: 0 0 3px !important;
  line-height: 1.2;
}

.home-hero-col--continue #resumeMeta,
.home-hero-col--continue .hint {
  font-size: 0.65rem !important;
  margin: 0 0 6px !important;
}

.home-hero-col--continue .play-btn,
.home-hero-col--continue #resumeBtn {
  font-size: 0.7rem !important;
  padding: 4px 10px !important;
}

/* Right column: Recent Saves */
.home-hero-col--recent .eyebrow {
  font-size: 0.6rem !important;
  margin: 0 0 6px !important;
}

.home-hero-col--recent .continue-grid {
  gap: 6px !important;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)) !important;
}

.home-hero-col--recent .continue-card {
  padding: 4px !important;
}

.home-hero-col--recent .continue-card img,
.home-hero-col--recent .continue-card-art {
  width: 100% !important;
  aspect-ratio: 1 / 1;
  max-height: 70px !important;
  object-fit: cover;
  border-radius: 3px;
}

.home-hero-col--recent .continue-card-title {
  font-size: 0.62rem !important;
  line-height: 1.15;
  margin-top: 3px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.home-hero-col--recent .continue-card-meta,
.home-hero-col--recent .continue-card-sub {
  font-size: 0.52rem !important;
  line-height: 1.1;
  opacity: 0.65;
}

@media (max-width: 900px) {
  .home-hero-grid {
    grid-template-columns: 1fr;
  }
}


/* Best Of cards — with boxart */
.best-of-card {
  display: flex;
  flex-direction: column;
  text-align: center;
}
.best-of-card .continue-card-art {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  background: rgba(0,0,0,0.25);
  border-radius: 4px;
  margin-bottom: 4px;
}
.best-of-card.no-art {
  min-height: 100px;
}
#bestOfGrid.continue-grid {
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)) !important;
  gap: 8px !important;
}


