/* ============================================================
   MiniGame Arcade — ретро-раздел
   Библиотека ROM карточками и полноэкранный эмулятор.
   Базовые токены и оболочка — в /css/site.css.
   ============================================================ */

/* ============================ БИБЛИОТЕКА ============================ */
.rom-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.rom-card {
  --sys: #2f6fed;
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.rom-card:hover,
.rom-card:focus-within {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--sys) 55%, var(--line));
  box-shadow: var(--shadow-md);
}

.rom-card.is-md { --sys: #2f6fed; }
.rom-card.is-ms { --sys: #dd4b3f; }
.rom-card.is-gg { --sys: #1f9d68; }

.rom-art {
  position: relative;
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  color: #fff;
  background:
    radial-gradient(120% 130% at 18% 0%,
      color-mix(in srgb, var(--sys) 58%, #0b0d13),
      #0b0d13 72%);
  overflow: hidden;
}

.rom-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.045) 0,
    rgba(255, 255, 255, 0.045) 1px,
    transparent 1px,
    transparent 3px);
  opacity: 0.7;
  pointer-events: none;
}

.rom-cart {
  width: 54px;
  height: 54px;
  opacity: 0.92;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.35));
  transition: transform 0.3s ease;
}

.rom-card:hover .rom-cart { transform: translateY(-2px) scale(1.04); }

.rom-system {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  padding: 4px 9px;
  border-radius: 6px;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #fff;
  background: rgba(11, 13, 19, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.22);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.rom-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  padding: 14px 16px 15px;
}

.rom-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rom-file {
  margin: 0;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rom-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 10px;
}

.rom-saves {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--muted);
}

.rom-saves.is-on { color: #1f9d68; }

.rom-saves .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.rom-play {
  padding: 0;
  border: 0;
  background: none;
  color: var(--sys);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.rom-play::after {
  content: "→";
  display: inline-block;
  margin-left: 6px;
  transition: transform 0.18s ease;
}

.rom-card:hover .rom-play::after { transform: translateX(4px); }

.rom-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 48px 22px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
  color: var(--muted);
  text-align: center;
}

.rom-empty b { color: var(--text); font-size: 16px; }
.rom-empty code {
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 0.92em;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
}

/* ============================ ДОБАВЛЕНИЕ ROM ============================ */
.retro-help {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
}

.retro-help summary {
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.retro-help summary::-webkit-details-marker { display: none; }

.retro-help summary::before {
  content: "+";
  display: inline-block;
  width: 16px;
  color: var(--accent);
  font-weight: 800;
}

.retro-help[open] summary::before { content: "–"; }

.retro-help p { margin: 10px 0 0; max-width: 820px; }

.retro-help code {
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 0.92em;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
}

.retro-help-note { font-style: italic; }

/* ============================ ЭМУЛЯТОР ============================ */
.retro .player-bar {
  flex-wrap: wrap;
  row-gap: 8px;
}

.save-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.slot-pick {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 33px;
  padding: 0 8px 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.slot-pick select {
  max-width: 190px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
  cursor: pointer;
}

.btn-ghost:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-ghost:disabled:hover {
  background: var(--panel-soft);
  border-color: var(--line);
  color: var(--text);
}

.btn-ghost.is-danger { color: #c0392b; }

.btn-ghost.is-danger:hover:not(:disabled) {
  background: rgba(192, 57, 43, 0.09);
  border-color: #c0392b;
  color: #c0392b;
}

/* ============================ УВЕДОМЛЕНИЯ ============================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 90;
  transform: translateX(-50%);
  max-width: min(420px, calc(100% - 32px));
  padding: 11px 18px;
  border-radius: 10px;
  background: rgba(24, 26, 38, 0.94);
  color: #fff;
  font-size: 13.5px;
  box-shadow: 0 14px 34px rgba(16, 20, 34, 0.35);
  animation: toast-in 0.18s ease;
  pointer-events: none;
}

.toast[hidden] { display: none; }

.toast.is-error { background: rgba(165, 44, 34, 0.96); }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============================ АДАПТИВ ============================ */
@media (max-width: 720px) {
  .save-bar { order: 3; width: 100%; }
  .slot-pick { flex: 1; }
  .slot-pick select { max-width: none; width: 100%; }
  .save-bar .btn-ghost { flex: 1; justify-content: center; }
}

@media (max-width: 560px) {
  .rom-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
  .rom-body { padding: 12px 13px 13px; }
  .rom-title { font-size: 14.5px; }
  .rom-cart { width: 44px; height: 44px; }
}
