:root {
  color-scheme: dark;
  --bg: #0b1018;
  --panel: #131b27;
  --panel-2: #172130;
  --line: rgba(125, 190, 240, 0.16);
  --line-strong: rgba(125, 190, 240, 0.34);
  --text: #e5eef7;
  --muted: #8c9aab;
  --blue: #6ec3f4;
  --blue-2: #2377b6;
  --green: #a4cf4d;
  --red: #ff7373;
  --amber: #f5bd55;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 0%, rgba(35, 119, 182, 0.22), transparent 34rem),
    linear-gradient(145deg, #090d14 0%, #101826 50%, #0b1018 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

code {
  color: #9edcff;
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  overflow: hidden;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  border: 0;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.minimal-app {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px clamp(14px, 2.5vw, 32px) 36px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 58px;
  margin-bottom: 18px;
}

.brand,
.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  color: #d5f0ff;
  border: 1px solid rgba(110, 195, 244, 0.34);
  border-radius: 14px;
  background: linear-gradient(145deg, #1a2637, #0d141f);
  box-shadow: 0 10px 28px rgba(35, 119, 182, 0.24);
}

.brand-mark svg {
  width: 26px;
  height: 26px;
}

.brand strong,
.brand-title {
  display: block;
  color: #f5fbff;
  font-size: 0.98rem;
  font-weight: 850;
  letter-spacing: -0.02em;
}

.brand span,
.brand-kicker {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 12px currentColor;
}

.status-dot.status-ok {
  color: var(--green);
  background: var(--green);
}

.status-dot.status-warn {
  color: var(--amber);
}

.status-dot.status-bad {
  color: var(--red);
  background: var(--red);
}

.resume-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 13px;
  color: #eaf7ff;
  border: 1px solid rgba(110, 195, 244, 0.34);
  border-radius: 999px;
  background: rgba(35, 119, 182, 0.28);
  font-size: 0.78rem;
  font-weight: 850;
}

.resume-button svg {
  width: 15px;
  height: 15px;
}

.icon-button,
.control-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: #c7d5e4;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(14, 21, 31, 0.72);
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.icon-button:hover,
.control-button:hover {
  color: #fff;
  border-color: var(--line-strong);
  background: rgba(30, 43, 60, 0.86);
}

.icon-button svg,
.control-button svg {
  width: 19px;
  height: 19px;
}

.control-button.active {
  color: #e6f7d2;
  border-color: rgba(164, 207, 77, 0.48);
  background: rgba(91, 125, 32, 0.38);
}

.control-button.danger {
  color: #ffd5d5;
  border-color: rgba(255, 115, 115, 0.24);
}

.control-button.danger:hover {
  border-color: rgba(255, 115, 115, 0.46);
  background: rgba(100, 38, 44, 0.58);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 20px;
  color: white;
  border: 1px solid rgba(175, 224, 255, 0.52);
  border-radius: 13px;
  background: linear-gradient(90deg, #42a8de, #2377b6);
  box-shadow: 0 12px 32px rgba(35, 119, 182, 0.34);
  font-weight: 850;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 38px rgba(35, 119, 182, 0.44);
}

.primary-button svg {
  width: 18px;
  height: 18px;
}

.warning-banner {
  margin-bottom: 16px;
  padding: 11px 14px;
  color: #ffe4aa;
  border: 1px solid rgba(245, 189, 85, 0.32);
  border-radius: 12px;
  background: rgba(91, 64, 20, 0.34);
  font-size: 0.88rem;
}

.player-panel,
.library-panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(18, 26, 38, 0.72);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(16px);
}

.player-panel {
  overflow: hidden;
  margin-bottom: 24px;
}

.player-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
}

.player-head h1,
.library-head h2 {
  margin: 0;
  color: #f7fbff;
  font-size: 1.35rem;
  letter-spacing: -0.035em;
}

.player-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.quality-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.mini-select {
  height: 38px;
  min-width: 112px;
  padding: 0 34px 0 12px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: 0;
  background: #0d141f;
  text-transform: none;
}

.video-shell {
  position: relative;
  overflow: hidden;
  touch-action: none;
  margin: 0 20px 20px;
  border: 1px solid rgba(110, 195, 244, 0.2);
  border-radius: 18px;
  background: #04080d;
  aspect-ratio: 16 / 9;
  outline: none;
}

.video-shell:focus-visible {
  box-shadow: 0 0 0 3px rgba(110, 195, 244, 0.24);
}

.video-shell:fullscreen {
  margin: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  aspect-ratio: auto;
  background: #000;
}

.video-shell:fullscreen:focus-visible {
  box-shadow: none;
}

.video-shell video {
  display: block;
  touch-action: none;
  width: 100%;
  height: 100%;
  background: #04080d;
  object-fit: contain;
}

.stream-idle {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  place-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 25%, rgba(110, 195, 244, 0.13), transparent 34%),
    linear-gradient(180deg, rgba(5, 9, 14, 0.12), rgba(5, 9, 14, 0.9));
}

.loading-ring {
  width: 54px;
  height: 54px;
  border: 3px solid rgba(110, 195, 244, 0.18);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.stream-idle h2 {
  margin: 0;
  color: #f7fbff;
  font-size: 1.55rem;
  letter-spacing: -0.04em;
}

.stream-idle p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.stream-overlay,
.connection-stats,
.video-controls {
  position: absolute;
  z-index: 3;
}

.local-cursor {
  position: absolute;
  z-index: 6;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.8), inset 0 0 3px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.local-cursor::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3px;
  height: 3px;
  margin: -1.5px 0 0 -1.5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
}

.video-shell.capture-hover {
  cursor: none;
}

.remote-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.video-shell.upscaled #remoteVideo {
  visibility: hidden;
}

.remote-cursor {
  position: absolute;
  z-index: 7;
  width: 20px;
  height: 20px;
  pointer-events: none;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.8));
  transition: left 60ms linear, top 60ms linear;
}

.remote-cursor svg {
  display: block;
  width: 100%;
  height: 100%;
}

.stream-overlay {
  top: 12px;
  right: 12px;
  padding: 7px 10px;
  color: #d8e4ef;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(4, 8, 13, 0.68);
  font-size: 0.74rem;
  font-weight: 850;
  backdrop-filter: blur(10px);
}

.stream-overlay.input-live {
  color: #ddf0c5;
  border-color: rgba(164, 207, 77, 0.36);
}

.connection-stats {
  top: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 220px);
  padding: 7px 10px;
  color: #d8e4ef;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(4, 8, 13, 0.68);
  font-size: 0.74rem;
  font-weight: 800;
  white-space: nowrap;
  opacity: 0;
  transition: 160ms ease;
  backdrop-filter: blur(10px);
}

.video-shell:not(:fullscreen).streaming .connection-stats,
.video-shell.streaming:hover .connection-stats {
  opacity: 1;
}

.connection-stats span:not(:first-child)::before {
  margin-right: 8px;
  color: rgba(255, 255, 255, 0.25);
  content: "•";
}

.video-controls {
  right: 12px;
  bottom: 12px;
  display: flex;
  gap: 8px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 15px;
  background: rgba(4, 8, 13, 0.64);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: 160ms ease;
  backdrop-filter: blur(12px);
}

.video-shell:not(:fullscreen).streaming .video-controls,
.video-shell.streaming:hover .video-controls,
.video-shell.streaming:focus-within .video-controls {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.library-panel {
  padding: 18px 20px 20px;
}

.library-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.library-head span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.library-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(320px, 38vw);
  height: 40px;
  padding: 0 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(8, 13, 20, 0.7);
}

.search-box:focus-within {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(110, 195, 244, 0.08);
}

.search-box svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.search-box input {
  width: 100%;
  color: var(--text);
  border: 0;
  outline: 0;
  background: transparent;
}

.search-box input::placeholder {
  color: #6f7d8e;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: 15px;
}

.game-card {
  overflow: hidden;
  cursor: pointer;
  border: 1px solid rgba(110, 195, 244, 0.1);
  border-radius: 16px;
  background: rgba(10, 16, 24, 0.72);
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.game-card:hover {
  transform: translateY(-2px);
  border-color: rgba(110, 195, 244, 0.32);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.3);
}

.game-card:focus-visible {
  outline: 2px solid rgba(110, 195, 244, 0.72);
  outline-offset: 2px;
}

.art-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 2 / 3;
  background:
    radial-gradient(circle at 35% 18%, rgba(110, 195, 244, 0.2), transparent 45%),
    linear-gradient(145deg, #172235, #0b111b);
}

.game-art {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 200ms ease, transform 240ms ease;
}

.game-art.loaded {
  opacity: 1;
}

.game-card:hover .game-art {
  transform: scale(1.025);
}

.art-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  place-content: center;
  gap: 10px;
  padding: 16px;
  color: rgba(110, 195, 244, 0.62);
  text-align: center;
}

.art-fallback svg {
  width: 46px;
  height: 46px;
}

.fallback-initials {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  color: #fff;
  border-radius: 18px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.38);
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.game-art.icon-art {
  padding: 26px;
  object-fit: contain;
}

.mode-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0d141f;
}

.mode-tab {
  height: 32px;
  padding: 0 16px;
  color: var(--muted);
  border: 0;
  border-radius: 9px;
  background: transparent;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: color 120ms ease, background 120ms ease;
}

.mode-tab:hover {
  color: var(--text);
}

.mode-tab.active {
  color: #f7fbff;
  background: rgba(110, 195, 244, 0.18);
}

.library-subhead {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}

.library-subhead h2 {
  margin: 0;
  color: #f7fbff;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.library-subhead span {
  color: var(--muted);
  font-size: 0.78rem;
}

.app-card .art-wrap {
  aspect-ratio: 16 / 10;
}

.app-icon-wrap {
  display: grid;
  place-items: center;
  color: rgba(110, 195, 244, 0.72);
}

.app-icon-wrap svg {
  width: 56px;
  height: 56px;
}

.fallback-title {
  display: -webkit-box;
  overflow: hidden;
  color: #c7d5e4;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.play-hint {
  position: absolute;
  z-index: 3;
  right: 10px;
  bottom: 10px;
  padding: 7px 13px;
  color: white;
  border: 1px solid rgba(175, 224, 255, 0.42);
  border-radius: 999px;
  background: rgba(14, 23, 34, 0.78);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.36);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transform: translateY(5px);
  opacity: 0;
  transition: 150ms ease;
  backdrop-filter: blur(8px);
}

.game-card:hover .play-hint,
.game-card:focus-visible .play-hint,
.game-card.launching .play-hint {
  transform: translateY(0);
  opacity: 1;
}

.game-card.launching {
  border-color: rgba(164, 207, 77, 0.42);
}

.game-card.running {
  border-color: rgba(76, 217, 123, 0.55);
  box-shadow: 0 0 0 1px rgba(76, 217, 123, 0.25), 0 0 26px rgba(76, 217, 123, 0.2);
}

.game-card.running .art-wrap::after {
  content: '';
  position: absolute;
  z-index: 4;
  top: 10px;
  left: 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4cd97b;
  box-shadow: 0 0 12px rgba(76, 217, 123, 0.95);
  animation: pulse-dot 1.6s ease-in-out infinite;
}

.game-card.running .play-hint {
  transform: translateY(0);
  opacity: 1;
  border-color: rgba(76, 217, 123, 0.65);
  background: rgba(21, 61, 34, 0.85);
  color: #9ff0b8;
}

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

.game-info {
  padding: 11px 12px 12px;
}

.game-name {
  overflow: hidden;
  margin: 0;
  color: #f2f8fe;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-meta {
  overflow: hidden;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  display: grid;
  place-items: center;
  padding: 46px 20px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 52px;
  height: 52px;
  color: rgba(110, 195, 244, 0.48);
}

.empty-state h3 {
  margin: 12px 0 4px;
  color: #f2f8fe;
}

.empty-state p {
  margin: 0;
}

.skeleton-card {
  overflow: hidden;
  border: 1px solid rgba(110, 195, 244, 0.08);
  border-radius: 16px;
  background: rgba(10, 16, 24, 0.6);
}

.skeleton-art,
.skeleton-line {
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.055);
}

.skeleton-art {
  aspect-ratio: 2 / 3;
}

.skeleton-line {
  height: 13px;
  margin: 13px 11px;
  border-radius: 999px;
}

.skeleton-line.short {
  width: 55%;
}

.skeleton-art::after,
.skeleton-line::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  animation: shimmer 1.4s infinite;
  transform: translateX(-100%);
}

.toast {
  position: fixed;
  z-index: 50;
  right: 20px;
  bottom: 20px;
  max-width: min(400px, calc(100vw - 40px));
  padding: 13px 15px;
  color: #f2f8fe;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: rgba(12, 19, 29, 0.95);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(14px);
}

.toast.error {
  color: #ffd5d5;
  border-color: rgba(255, 115, 115, 0.4);
}

.toast.success {
  color: #e3f3cf;
  border-color: rgba(164, 207, 77, 0.4);
}

@media (hover: none) {
  .play-hint {
    transform: none;
    opacity: 0.92;
  }
}

@media (pointer: coarse) {
  .stream-overlay {
    display: none;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

@media (max-width: 760px) {
  .minimal-app {
    padding: 12px 10px 28px;
  }

  .host-status {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-right {
    gap: 6px;
  }

  .resume-button {
    height: 34px;
    padding: 0 10px;
    font-size: 0.72rem;
  }

  .connection-stats {
    max-width: calc(100% - 150px);
    overflow: hidden;
  }

  .player-head,
  .library-head {
    align-items: stretch;
    flex-direction: column;
  }

  .quality-label {
    justify-content: space-between;
  }

  .library-actions {
    align-items: stretch;
  }

  .search-box {
    width: 100%;
    flex: 1;
  }

  .video-shell {
    margin: 0 12px 12px;
  }

  .library-panel {
    padding: 14px;
  }

  .games-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 11px;
  }

  .connection-stats {
    max-width: calc(100% - 24px);
    font-size: 0.68rem;
  }

  .video-controls {
    right: 8px;
    bottom: 8px;
    gap: 5px;
    padding: 5px;
  }

  .control-button {
    width: 36px;
    height: 36px;
  }
}
