:root {
  --fliperama-accent: #ff5c35;
  --fliperama-accent-2: #7c3aed;
  --fliperama-bg: #090d18;
  --fliperama-panel: #121827;
  --fliperama-border: rgba(255, 255, 255, 0.09);
}

.fliperama-page {
  width: min(1180px, calc(100% - 32px));
  margin: 32px auto 48px;
}

body:has(.fliperama-page) {
  background:
    radial-gradient(circle at 100% 0%, rgba(124, 58, 237, 0.12), transparent 320px),
    #090d18;
}

body:has(.fliperama-page) #main-content {
  background: transparent;
}

.fliperama-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  padding: 24px 28px;
  border: 1px solid rgba(124, 58, 237, 0.15);
  border-radius: 20px;
  background:
    radial-gradient(circle at 85% 20%, rgba(124, 58, 237, 0.20), transparent 180px),
    linear-gradient(135deg, #111827, #0d1321);
  color: #fff;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
}

.fliperama-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #ff9b79;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.fliperama-hero h1 {
  margin: 8px 0 6px;
  font-size: clamp(1.8rem, 4vw, 3rem);
  letter-spacing: -0.04em;
}

.fliperama-hero p {
  margin: 0;
  color: #bdc7d9;
}

.fliperama-hero-status {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid var(--fliperama-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: #d8dee9;
  font-size: 0.82rem;
  font-weight: 700;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #94a3b8;
  box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.10);
}

.status-dot.connected {
  background: #34d399;
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.13), 0 0 14px #34d399;
}

.fliperama-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "loader loader"
    "screen screen"
    "controls controls";
  gap: 18px;
}

.fliperama-loader-bar {
  grid-area: loader;
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(360px, 1.5fr) 170px;
  align-items: end;
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: #111827;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.24);
}

.fliperama-controls,
.fliperama-screen-wrap {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: #111827;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
}

.fliperama-controls {
  grid-area: controls;
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  color: #9aa7ba;
  font-size: 0.76rem;
}

.fliperama-controls > strong {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: #e5eaf2;
}

.fliperama-controls div {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.fliperama-controls b {
  color: #f4f7fb;
  text-align: right;
}

.panel-label {
  display: block;
  margin-bottom: 7px;
  color: #bdc7d8;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.system-select {
  width: 100%;
  height: 44px;
  border: 1px solid #334155;
  border-radius: 10px;
  background: #0b1220;
  color: #e5eaf2;
  padding: 0 12px;
  font-weight: 700;
}

.rom-dropzone {
  display: flex;
  min-height: 58px;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 12px;
  border: 2px dashed #475569;
  border-radius: 12px;
  background: #0b1220;
  text-align: center;
  cursor: pointer;
  transition: 0.18s ease;
}

.rom-dropzone:hover,
.rom-dropzone.dragging {
  border-color: var(--fliperama-accent);
  background: #fff7f3;
}

.rom-dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.rom-dropzone-icon {
  color: var(--fliperama-accent);
  font-size: 22px;
}

.rom-dropzone strong {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #f1f5f9;
}

.rom-dropzone span {
  color: #94a3b8;
  font-size: 0.78rem;
}

.start-game,
.stop-game {
  width: 100%;
  height: 42px;
  border: 0;
  border-radius: 10px;
  font-weight: 800;
}

.start-game {
  background: linear-gradient(135deg, #ff6a3d, #ef4b2d);
  color: #fff;
  box-shadow: 0 9px 18px rgba(239, 75, 45, 0.22);
}

.start-game:disabled,
.stop-game:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
}

.stop-game {
  margin-top: 8px;
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #b91c1c;
}

.fliperama-screen-wrap {
  grid-area: screen;
  min-width: 0;
  overflow: hidden;
  background: var(--fliperama-bg);
  border-color: rgba(255, 255, 255, 0.05);
}

.screen-toolbar {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--fliperama-border);
  color: #fff;
}

.screen-toolbar > div:first-child {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.screen-toolbar strong {
  max-width: 520px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
}

.screen-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #94a3b8;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.screen-live span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff5c35;
  box-shadow: 0 0 10px #ff5c35;
}

.screen-action {
  width: 38px;
  height: 38px;
  border: 1px solid var(--fliperama-border);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.05);
  color: #dce4ef;
}

.screen-action:disabled {
  opacity: 0.35;
}

.fliperama-screen {
  position: relative;
  display: grid;
  width: 100%;
  height: 560px;
  max-height: 560px;
  overflow: hidden;
  place-items: center;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    radial-gradient(circle at center, #182136, #090d18 68%);
  background-size: 24px 24px, 24px 24px, auto;
}

.screen-empty {
  display: grid;
  max-width: 390px;
  justify-items: center;
  padding: 24px;
  text-align: center;
  color: #fff;
}

.screen-empty h2 {
  margin: 12px 0 6px;
  font-size: 1.35rem;
}

.screen-empty p {
  margin: 0;
  color: #94a3b8;
  line-height: 1.55;
}

.screen-console {
  display: grid;
  width: 92px;
  height: 92px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 24px;
  background: linear-gradient(145deg, #202a40, #101624);
  color: #ff6a3d;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  font-size: 44px;
}

#game {
  display: none;
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
}

#game.active {
  display: block;
}

#game canvas,
#game video,
#game iframe {
  display: block !important;
  width: auto !important;
  max-width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
  margin: 0 auto !important;
  object-fit: contain !important;
}

#game > div,
#game > canvas {
  max-width: 100% !important;
  max-height: 100% !important;
}

.fliperama-screen:fullscreen {
  width: 100vw;
  height: 100vh;
  max-height: none;
  background: #090d18;
}

.fliperama-screen:fullscreen #game {
  width: 100%;
  height: 100%;
}

.screen-footer {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  border-top: 1px solid var(--fliperama-border);
  color: #7f8da3;
  font-size: 0.72rem;
}

.screen-footer span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.rom-notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(251, 191, 36, 0.28);
  border-radius: 12px;
  background: #1c1a12;
  color: #fbbf24;
}

.rom-notice i {
  margin-top: 2px;
  color: #d97706;
}

.rom-notice strong {
  display: block;
}

.rom-notice p {
  margin: 3px 0 0;
  color: #d6b15f;
  font-size: 0.82rem;
}

@media (max-width: 900px) {
  .fliperama-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "loader"
      "screen"
      "controls";
  }

  .fliperama-controls {
    grid-template-columns: repeat(3, 1fr);
  }

  .fliperama-loader-bar {
    grid-template-columns: 1fr 1fr;
  }

  .loader-rom {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .loader-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .fliperama-screen,
  #game {
    height: 460px;
    max-height: 460px;
  }
}

@media (max-width: 600px) {
  .fliperama-page {
    width: min(100% - 20px, 1180px);
    margin-top: 16px;
  }

  .fliperama-hero {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  .fliperama-loader-bar {
    display: block;
  }

  .fliperama-controls {
    grid-template-columns: repeat(2, 1fr);
  }

  .fliperama-screen,
  #game {
    height: 330px;
    max-height: 330px;
  }

  .screen-toolbar strong {
    max-width: 180px;
  }

  .screen-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}
