:root {
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --jc-blue: #0ab9e6;
  --jc-red: #ff3c28;
  --switch-cyan: #00d2ff;
  --switch-teal: #18e2b8;
  --radius-tile: 14px;
}

[data-theme="dark"] {
  --bg-main: #232327;
  --bg-elev: #2e2e34;
  --bg-card: #18181c;
  --bg-pill: rgba(255, 255, 255, 0.08);
  --bg-pill-hover: rgba(255, 255, 255, 0.14);
  --border-subtle: rgba(255, 255, 255, 0.12);
  --text-primary: #f5f5f7;
  --text-secondary: #b7b8c0;
  --text-muted: #8a8c96;
  --accent-title: #4de1ff;
  --dock-bg: #323238;
  --dock-icon: #e5e7eb;
  --shadow-tile: 0 14px 32px rgba(0, 0, 0, 0.45);
  --kbd-bg: #f5f5f7;
  --kbd-fg: #18181c;
}

[data-theme="light"] {
  --bg-main: #ebebee;
  --bg-elev: #ffffff;
  --bg-card: #f7f7fa;
  --bg-pill: rgba(0, 0, 0, 0.06);
  --bg-pill-hover: rgba(0, 0, 0, 0.11);
  --border-subtle: rgba(0, 0, 0, 0.12);
  --text-primary: #1f2024;
  --text-secondary: #4e515c;
  --text-muted: #6c707d;
  --accent-title: #008bb8;
  --dock-bg: #ffffff;
  --dock-icon: #2d2f36;
  --shadow-tile: 0 14px 28px rgba(0, 0, 0, 0.14);
  --kbd-bg: #26272c;
  --kbd-fg: #ffffff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-main);
  color: var(--text-primary);
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 220ms var(--ease-out), color 220ms var(--ease-out);
}

.hidden {
  display: none !important;
}

/* Joy-Con decorative side rails */
.joycon-rail {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 10px;
  z-index: 2;
  pointer-events: none;
}

.joycon-rail-left {
  left: 0;
  background: linear-gradient(180deg, #0ab9e6 0%, #008bb8 100%);
  box-shadow: 2px 0 18px rgba(10, 185, 230, 0.25);
}

.joycon-rail-right {
  right: 0;
  background: linear-gradient(180deg, #ff3c28 0%, #d42414 100%);
  box-shadow: -2px 0 18px rgba(255, 60, 40, 0.25);
}

.switch-shell {
  min-height: 100dvh;
  max-width: 1220px;
  margin: 0 auto;
  padding: 20px 32px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

/* Top Status Bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.profile-cluster {
  display: flex;
  align-items: center;
  gap: 11px;
}

.profile-avatar {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 2px solid var(--border-subtle);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.22);
  flex-shrink: 0;
}

.avatar-half {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
}

.avatar-half.left {
  left: 0;
  background: var(--jc-blue);
}

.avatar-half.right {
  right: 0;
  background: var(--jc-red);
}

.avatar-initial {
  position: relative;
  z-index: 1;
  font-size: 13px;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
  letter-spacing: -0.02em;
}

.profile-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.profile-name {
  font-size: 14px;
  font-weight: 700;
}

.profile-sub {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.status-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--bg-pill);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.7);
}

.status-pill.xr-no .status-dot {
  background: var(--jc-blue);
  box-shadow: 0 0 8px rgba(10, 185, 230, 0.6);
}

.clock-text {
  font-family: "JetBrains Mono", monospace;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.wifi-icon {
  display: grid;
  place-items: center;
  color: var(--text-primary);
}

.battery-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  font-weight: 700;
}

.battery-body {
  position: relative;
  width: 24px;
  height: 12px;
  border-radius: 3px;
  border: 1.8px solid var(--text-primary);
  padding: 1.5px;
  display: flex;
  align-items: center;
}

.battery-body::after {
  content: "";
  position: absolute;
  right: -4px;
  top: 2.5px;
  width: 2px;
  height: 5px;
  border-radius: 0 1px 1px 0;
  background: var(--text-primary);
}

.battery-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 1px;
  background: #22c55e;
}

/* Main Stage */
.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  margin: auto 0;
}

.active-title-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.genre-tag {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.game-title {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.35rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--accent-title);
}

/* Horizontal Game Carousel */
.carousel-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.carousel-arrow {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elev);
  color: var(--text-primary);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 160ms var(--ease-out), background-color 160ms var(--ease-out);
}

.carousel-arrow:hover {
  background: var(--bg-pill-hover);
  transform: scale(1.06);
}

.carousel-arrow:active {
  transform: scale(0.94);
}

.game-carousel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 12px 6px;
}

.game-tile {
  position: relative;
  width: 268px;
  height: 268px;
  padding: 0;
  border: none;
  border-radius: var(--radius-tile);
  background: var(--bg-card);
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  box-shadow: var(--shadow-tile);
  transform: scale(0.93);
  opacity: 0.78;
  transition:
    transform 240ms var(--ease-out),
    opacity 220ms var(--ease-out),
    box-shadow 240ms var(--ease-out);
}

.game-tile:hover {
  opacity: 0.96;
  transform: scale(0.97);
}

.game-tile.active {
  transform: scale(1.04);
  opacity: 1;
  box-shadow:
    0 0 0 4px var(--switch-cyan),
    0 0 26px rgba(0, 210, 255, 0.36),
    var(--shadow-tile);
  animation: switchPulse 1.8s ease-in-out infinite;
}

@keyframes switchPulse {
  0%,
  100% {
    box-shadow:
      0 0 0 4px var(--switch-cyan),
      0 0 24px rgba(0, 210, 255, 0.35),
      var(--shadow-tile);
  }
  50% {
    box-shadow:
      0 0 0 4px var(--switch-teal),
      0 0 34px rgba(24, 226, 184, 0.52),
      var(--shadow-tile);
  }
}

.tile-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 360ms var(--ease-out);
}

.game-tile.active .tile-cover {
  transform: scale(1.03);
}

.tile-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.14) 0%,
    rgba(0, 0, 0, 0.18) 45%,
    rgba(10, 10, 14, 0.9) 100%
  );
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 13px;
}

.tile-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.tile-badge {
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(14, 15, 20, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f8fafc;
  font-family: "JetBrains Mono", monospace;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.tile-index {
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(14, 15, 20, 0.78);
  color: #e2e8f0;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  font-weight: 700;
}

.tile-bottom {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.tile-title {
  font-size: 18px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}

.tile-subtitle {
  font-size: 12px;
  font-weight: 500;
  color: #cbd5e1;
}

/* Detail & Quick Launch Strip */
.detail-strip {
  width: min(820px, 100%);
  padding: 16px 20px;
  border-radius: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}

.detail-copy {
  flex: 1;
  min-width: 0;
}

.game-desc {
  margin: 0 0 10px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.feature-badge {
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--bg-pill);
  border: 1px solid var(--border-subtle);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.detail-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.btn-switch {
  height: 44px;
  padding: 0 18px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  transition: transform 140ms var(--ease-out), filter 140ms var(--ease-out), background-color 140ms var(--ease-out);
}

.btn-switch:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, #0ab9e6 0%, #008bb8 100%);
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(10, 185, 230, 0.32);
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-secondary {
  background: var(--bg-pill);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-pill-hover);
}

.btn-cap {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #14161a;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

/* Circular Nintendo Switch System Dock */
.system-dock {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 2px;
}

.dock-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-secondary);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: inherit;
}

.dock-circle {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--dock-bg);
  border: 1px solid var(--border-subtle);
  color: var(--dock-icon);
  display: grid;
  place-items: center;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.16);
  transition: transform 180ms var(--ease-out), border-color 180ms var(--ease-out), color 180ms var(--ease-out);
}

.dock-btn:hover .dock-circle {
  transform: translateY(-3px) scale(1.06);
  border-color: var(--switch-cyan);
  color: var(--switch-cyan);
}

.dock-circle.icon-album {
  color: #38bdf8;
}

.dock-circle.icon-controls {
  color: #f43f5e;
}

.dock-circle.icon-sound {
  color: #f59e0b;
}

.dock-circle.icon-theme {
  color: #a855f7;
}

.dock-label {
  font-size: 11.5px;
  font-weight: 600;
}

/* Bottom Footer Legend */
.bottom-bar {
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.legend-left,
.legend-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.legend-item,
.legend-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  padding: 4px 6px;
  border-radius: 6px;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  font-weight: 600;
  cursor: pointer;
}

.legend-btn:hover {
  background: var(--bg-pill);
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--kbd-bg);
  color: var(--kbd-fg);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 700;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(8, 10, 14, 0.76);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-card {
  width: min(860px, 100%);
  max-height: min(88dvh, 760px);
  overflow-y: auto;
  border-radius: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  padding: 22px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px;
}

.modal-kicker {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-title);
  letter-spacing: 0.08em;
}

.modal-title {
  margin: 2px 0 0;
  font-size: 20px;
  font-weight: 800;
}

.modal-close {
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-pill);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.modal-close:hover {
  background: var(--bg-pill-hover);
}

.modal-body {
  display: grid;
  gap: 16px;
}

.modal-section-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.feature-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 13.5px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.gallery-item {
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
}

.gallery-item img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  display: block;
}

.gallery-caption {
  padding: 6px 8px;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.control-box {
  padding: 14px;
  border-radius: 12px;
  background: var(--bg-pill);
  border: 1px solid var(--border-subtle);
}

.control-box h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--accent-title);
}

.control-box ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 5px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Launch Splash */
.launch-splash {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(12, 13, 17, 0.92);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 20px;
}

.launch-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 22px;
  border-radius: 16px;
  background: #1e2026;
  border: 2px solid var(--switch-cyan);
  box-shadow: 0 0 40px rgba(0, 210, 255, 0.35);
  color: #ffffff;
}

.launch-card img {
  width: 68px;
  height: 68px;
  border-radius: 10px;
  object-fit: cover;
}

.launch-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.launch-kicker {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--switch-cyan);
  letter-spacing: 0.08em;
}

.launch-meta strong {
  font-size: 18px;
}

button:focus-visible,
a:focus-visible {
  outline: 2.5px solid var(--switch-cyan);
  outline-offset: 3px;
}

@media (max-width: 768px) {
  .joycon-rail {
    display: none;
  }

  .switch-shell {
    padding: 14px 16px;
    gap: 14px;
  }

  .carousel-arrow {
    display: none;
  }

  .game-carousel {
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
    scroll-snap-type: x mandatory;
    padding: 12px 14px;
    gap: 14px;
  }

  .game-tile {
    flex: 0 0 220px;
    width: 220px;
    height: 220px;
    scroll-snap-align: center;
  }

  .detail-strip {
    flex-direction: column;
    align-items: stretch;
    padding: 14px 16px;
  }

  .detail-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .detail-actions .btn-switch {
    flex: 1 1 140px;
    padding: 0 12px;
    font-size: 13px;
  }

  .system-dock {
    gap: 12px;
  }

  .dock-circle {
    width: 46px;
    height: 46px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}
