/* ═══════════════════════════════════════════════════════════════════════════
   emulator.st — Extension Styles
   Autosave panel, sync indicator, offline banner, gamepad, wrapped page
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Sync Status Indicator ─────────────────────────────────────────────── */
.sync-indicator {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: .65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  cursor: default;
  transition: all .2s ease;
}
.sync-indicator::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  display: inline-block;
}
.sync-saved { color: var(--green, #00b894); background: rgba(0,184,148,.1); }
.sync-saved::before { background: var(--green, #00b894); }
.sync-saving { color: var(--gold, #f1c40f); background: rgba(241,196,15,.1); }
.sync-saving::before { background: var(--gold, #f1c40f); animation: pulse-dot .8s ease-in-out infinite; }
.sync-failed { color: var(--red, #e74c3c); background: rgba(231,76,60,.1); cursor: pointer; }
.sync-failed::before { background: var(--red, #e74c3c); }
.sync-offline { color: #888; background: rgba(136,136,136,.1); }
.sync-offline::before { background: #888; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; } 50% { opacity: .3; }
}

/* ─── Autosave Panel ────────────────────────────────────────────────────── */
.autosave-section {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.autosave-section .eyebrow { margin-bottom: 8px; }

.autosave-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background .15s ease;
}
.autosave-item:hover { background: var(--bg-hover); }

.autosave-info { flex: 1; min-width: 0; }
.autosave-time { font-size: .72rem; color: var(--text-dim); }
.lkg-badge {
  font-size: .6rem; color: var(--green, #00b894);
  font-weight: 700; margin-left: 6px;
}

.autosave-actions { display: flex; gap: 4px; flex-shrink: 0; }
.autosave-actions .compact-btn { padding: 3px 8px; font-size: .62rem; }

.autosave-empty {
  text-align: center; padding: 12px;
  font-size: .75rem; color: var(--text-dim);
}

/* ─── Offline Banner ────────────────────────────────────────────────────── */
.offline-banner {
  position: fixed; top: var(--topbar-h, 56px); left: 0; right: 0;
  padding: 8px 16px;
  background: rgba(231,76,60,.15);
  border-bottom: 1px solid rgba(231,76,60,.3);
  color: #e74c3c;
  font-size: .75rem; font-weight: 600;
  text-align: center;
  z-index: 99;
  transform: translateY(-100%);
  transition: transform .3s ease;
}
.offline-banner.visible { transform: translateY(0); }

/* ─── Gamepad Indicator ─────────────────────────────────────────────────── */
.gamepad-indicator {
  position: fixed; bottom: 80px; right: 20px;
  padding: 8px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: .72rem; font-weight: 600;
  color: var(--text-dim);
  opacity: 0; transform: translateY(10px);
  transition: all .3s ease;
  z-index: 500; pointer-events: none;
}
.gamepad-indicator.visible { opacity: 1; transform: translateY(0); }
.gamepad-indicator.connected { border-color: var(--green, #00b894); color: var(--green, #00b894); }

/* ─── Keyboard Shortcut Overlay ─────────────────────────────────────────── */
.shortcut-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.7);
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.shortcut-modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  max-width: 360px; width: 90%;
  box-shadow: 0 16px 48px rgba(0,0,0,.6);
}
.shortcut-modal h3 {
  font-size: .85rem; font-weight: 700;
  color: var(--accent-bright);
  margin-bottom: 10px;
  text-transform: uppercase; letter-spacing: .08em;
}
.shortcut-grid {
  display: grid; grid-template-columns: auto 1fr;
  gap: 6px 12px; align-items: center;
}
.shortcut-grid kbd {
  display: inline-block; padding: 2px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono, monospace);
  font-size: .72rem; font-weight: 600;
  color: var(--accent-bright);
}
.shortcut-grid span { font-size: .75rem; color: var(--text-dim); }

/* ─── Continue Playing Row ──────────────────────────────────────────────── */
.continue-row { margin-bottom: 16px; }
.continue-grid {
  display: flex; gap: 12px;
  overflow-x: auto; padding: 8px 0;
  scrollbar-width: none;
}
.continue-grid::-webkit-scrollbar { display: none; }

.continue-card {
  flex-shrink: 0; width: 160px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .2s ease, transform .2s ease;
  text-decoration: none; color: inherit;
}
.continue-card:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.continue-card-art { height: 100px; background: var(--bg-hover); overflow: hidden; }
.continue-card-art img { width: 100%; height: 100%; object-fit: cover; }
.continue-card-info { padding: 8px 10px; }
.continue-card-title {
  font-size: .72rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.continue-card-meta {
  font-size: .62rem; color: var(--text-dim); margin-top: 2px;
}
.continue-card-resume {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 6px;
  padding: 3px 8px;
  background: var(--accent);
  color: #fff; font-size: .6rem; font-weight: 700;
  border-radius: 4px; text-transform: uppercase;
}

/* ─── Save Export/Import Buttons ────────────────────────────────────────── */
.save-export-row {
  display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap;
}

/* ─── Storage Quota Display ─────────────────────────────────────────────── */
.quota-display {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .72rem; color: var(--text-dim);
  margin-top: 8px;
}
.quota-bar {
  flex: 1; height: 4px;
  background: rgba(255,255,255,.08);
  border-radius: 2px; overflow: hidden;
}
.quota-bar-fill { height: 100%; border-radius: 2px; transition: width .3s ease; }
.quota-bar-fill.ok { background: var(--green, #00b894); }
.quota-bar-fill.warn { background: var(--gold, #f1c40f); }
.quota-bar-fill.critical { background: var(--red, #e74c3c); }

/* ─── Wrapped Page ──────────────────────────────────────────────────────── */
.wrapped-page { max-width: 700px; margin: 0 auto; }

.wrapped-hero { text-align: center; padding: 20px 0 24px; }
.wrapped-title { font-size: 2rem; font-weight: 800; margin-top: 8px; }

.wrapped-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px; margin-bottom: 24px;
}
.wrapped-stat {
  text-align: center; padding: 16px 12px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.wrapped-stat-big {
  grid-column: 1 / -1;
  padding: 24px;
  background: linear-gradient(135deg, var(--bg-card), rgba(108,92,231,.1));
  border-color: var(--accent);
}
.wrapped-stat-val {
  font-size: 1.8rem; font-weight: 800;
  color: var(--accent-bright);
}
.wrapped-stat-big .wrapped-stat-val { font-size: 2.8rem; }
.wrapped-stat-label {
  font-size: .65rem; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .08em;
  margin-top: 4px;
}

.wrapped-section { margin-bottom: 20px; }
.wrapped-highlight {
  padding: 16px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 8px;
}
.wrapped-highlight h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.wrapped-highlight p { font-size: .82rem; color: var(--text-dim); }

.wrapped-list { margin-top: 8px; }
.wrapped-list-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.wrapped-list-item:last-child { border-bottom: none; }
.wrapped-rank { font-size: .8rem; font-weight: 800; color: var(--accent-bright); width: 28px; }
.wrapped-game { flex: 1; font-size: .82rem; font-weight: 600; }
.wrapped-system { font-size: .65rem; color: var(--text-dim); text-transform: uppercase; }
.wrapped-time { font-size: .72rem; color: var(--accent-bright); font-weight: 700; }

.wrapped-bars { margin-top: 8px; }
.wrapped-bar-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0;
}
.wrapped-bar-label { width: 60px; font-size: .65rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; }
.wrapped-bar-track { flex: 1; height: 8px; background: rgba(255,255,255,.06); border-radius: 4px; overflow: hidden; }
.wrapped-bar-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .5s ease; }
.wrapped-bar-time { width: 48px; text-align: right; font-size: .65rem; color: var(--text-dim); }

.wrapped-footer { text-align: center; padding: 24px 0; }
.wrapped-loading { text-align: center; padding: 40px; color: var(--text-dim); }

/* ─── Play page: game stats + touch overlay ─────────────────────────────── */
.game-stats-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px;
  margin: 6px 0 10px;
}
.game-stats-wrap .game-stats-bar {
  margin: 0;
  flex: 1 1 14rem;
  min-width: 0;
}
.game-stats-bar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin: 6px 0 10px; font-size: .72rem; color: var(--text-dim);
}
.game-stats-line { margin-right: 4px; }
.game-stats-badge {
  padding: 2px 8px; border-radius: 4px;
  background: var(--bg-hover); border: 1px solid var(--border);
  font-size: .62rem; color: var(--text);
}
.v5-emu-frame-wrap { position: relative; }
.v5-touch-overlay-root {
  position: absolute; left: 0; right: 0; bottom: 0;
  pointer-events: none; z-index: 20; padding: 6px 8px 10px;
}
.v5-touch-inner {
  pointer-events: auto;
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 10px; max-width: 100%;
}
.v5-touch-dpad {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.v5-touch-up { min-width: 48px; }
.v5-touch-dpad-mid { display: flex; gap: 4px; align-items: center; }
.v5-touch-actions {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end;
  max-width: 58%;
}
.v5-touch-btn {
  min-width: 44px; min-height: 44px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(0,0,0,.5); color: var(--text);
  font-size: 1rem; touch-action: none; cursor: pointer;
}
.v5-touch-face {
  min-width: 50px; min-height: 50px; border-radius: 50%;
  font-weight: 700; font-size: .95rem;
}

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .autosave-item { flex-direction: column; align-items: flex-start; gap: 4px; }
  .autosave-actions { width: 100%; }
  .continue-card { width: 130px; }
  .continue-card-art { height: 80px; }
  .wrapped-title { font-size: 1.5rem; }
  .wrapped-stat-big .wrapped-stat-val { font-size: 2rem; }
  .shortcut-modal { padding: 16px 20px; }
}

/* ─── Save slot labels (secondary line under SAVE n) ─────────────────────── */
.save-select-btn .slot-sub-label {
  font-size: 0.55rem;
  font-weight: 500;
  color: var(--text-dim, #888);
  max-width: 5.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.save-select-btn .slot-sub-empty {
  opacity: 0.35;
}

/* ─── Per-game notes ───────────────────────────────────────────────────── */
.game-notes-panel .game-notes-field {
  width: 100%;
  max-width: 36rem;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card, rgba(0,0,0,.25));
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1.45;
  resize: vertical;
  min-height: 5rem;
}

/* ─── Home: compact “recent saves” chip + expandable panel ─────────────── */
.continue-more-shell {
  margin: 4px 20px 14px;
  max-width: 100%;
  box-sizing: border-box;
}
.continue-more-trigger-row {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}
.continue-more-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 8px 14px 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card, rgba(0, 0, 0, 0.28));
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}
.continue-more-chip:hover {
  border-color: var(--accent, rgba(108, 92, 231, 0.55));
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
}
.continue-more-chip:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
}
.continue-more-shell.continue-more-is-open .continue-more-chip {
  border-color: var(--accent, rgba(108, 92, 231, 0.65));
  background: rgba(108, 92, 231, 0.08);
}
.continue-more-chip-icon {
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
  opacity: 0.95;
}
.continue-more-chip-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-width: 0;
}
.continue-more-chip-label {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-bright, #c8f542);
}
.continue-more-chip-hint {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-dim);
  line-height: 1.25;
}
.continue-more-badge {
  flex-shrink: 0;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1.35rem;
  text-align: center;
  background: var(--accent, #6c5ce7);
  color: #0a0a0a;
}
.continue-more-chevron {
  flex-shrink: 0;
  font-size: 0.65rem;
  opacity: 0.75;
  margin-left: 2px;
}
.continue-more-panel {
  margin-top: 12px;
  padding: 14px 16px 16px;
  border-radius: var(--radius-lg, 12px);
  border: 1px solid var(--border);
  background: var(--bg-panel);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}
.continue-more-panel-hint {
  margin: 0 0 12px;
  font-size: 0.72rem;
  line-height: 1.35;
  max-width: 36rem;
}

@media (max-width: 768px) {
  .continue-more-shell {
    margin-left: 12px;
    margin-right: 12px;
  }
  .continue-more-chip {
    min-height: 44px;
    padding-top: 10px;
    padding-bottom: 10px;
  }
}

.friends-playing-section .continue-card-meta {
  font-size: 0.65rem;
}

/* —— Watch-only live streaming —— */
.live-stream-panel {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(108, 92, 231, 0.25);
  background: rgba(0, 0, 0, 0.2);
}
.live-stream-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 8px;
}
.live-stream-title-label {
  flex: 1 1 180px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.live-stream-title-input {
  max-width: 100%;
}
.live-stream-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.live-stream-golive {
  border-color: rgba(200, 245, 66, 0.45);
  color: var(--accent-bright, #c8f542);
}
.live-stream-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.live-badge {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 4px 8px;
  border-radius: 4px;
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: #fff;
  animation: livePulse 2s ease-in-out infinite;
}
@keyframes livePulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.75;
  }
}

.home-live-section .home-live-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.live-home-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.live-directory-hero {
  margin-bottom: 16px;
}
.live-directory-title {
  margin: 4px 0 8px;
  font-size: 1.5rem;
}
.live-directory-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-top: 10px;
}
.live-directory-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.live-directory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.live-stream-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px);
  overflow: hidden;
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
}
.live-stream-card-poster {
  aspect-ratio: 16 / 9;
  background: linear-gradient(145deg, #1a1a24, #12121a);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.live-pulse {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #ff6b6b;
  text-shadow: 0 0 12px rgba(255, 107, 107, 0.5);
}
.live-stream-card-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.live-stream-card-title {
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.3;
}
.live-stream-card-meta {
  font-size: 0.72rem;
}
.live-stream-card-host {
  font-size: 0.7rem;
  color: var(--text-dim);
}
.live-stream-card-foot {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}
.live-directory-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 32px 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg, 12px);
}
.live-directory-empty-title {
  font-weight: 700;
  margin: 0 0 8px;
}

.watch-page .watch-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 16px;
}
@media (min-width: 900px) {
  .watch-page .watch-main {
    grid-template-columns: 1fr 280px;
    align-items: start;
  }
}
.watch-disclaimer {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.85rem;
}
.watch-player-wrap {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px);
  overflow: hidden;
}
.watch-player-wrap.watch-theater {
  max-width: 100%;
}
.watch-video-shell {
  position: relative;
  width: 100%;
  background: #000;
  aspect-ratio: 16 / 9;
}
/* Absolute fill: height:100% on <video> is unreliable in iOS/WebKit when parent only has aspect-ratio */
.watch-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}
.watch-live-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 4px 8px;
  border-radius: 4px;
  background: #c0392b;
  color: #fff;
}
.watch-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  align-items: center;
}
.watch-vol-label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.watch-meta-title {
  font-size: 1.15rem;
  margin: 4px 0;
}
.watch-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  font-size: 0.82rem;
  margin: 12px 0;
}
.watch-dl dt {
  color: var(--text-dim);
  margin: 0;
}
.watch-dl dd {
  margin: 0;
}
.watch-status-line {
  margin: 0;
}

/* ─── Watch Chat ────────────────────────────────────────────────────────── */
.watch-chat {
  display: flex;
  flex-direction: column;
  height: 400px;
  max-height: 60vh;
}
.watch-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
  margin: 8px 0;
  font-size: 0.8rem;
}
.watch-chat-message {
  margin: 4px 0;
  padding: 4px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.05);
}
.watch-chat-message-host {
  background: rgba(124,58,237,0.15);
}
.watch-chat-username {
  font-weight: 600;
  color: var(--accent, #7c3aed);
  font-size: 0.75rem;
}
.watch-chat-text {
  color: var(--text);
  word-break: break-word;
}
.watch-chat-input-wrap {
  display: flex;
  gap: 8px;
}
.watch-chat-input-wrap input {
  flex: 1;
}
