:root {
  color-scheme: dark;
  --black: #000;
  --panel: #0b0b0b;
  --line: #252525;
  --text: #777;
  --text-active: #fff;
  --accent: #ff6257;
}

* { box-sizing: border-box; }

html,
body { min-height: 100%; }

body {
  margin: 0;
  background: var(--black);
  color: var(--text-active);
  font-family: Inter, "Noto Sans TC", system-ui, sans-serif;
  overflow: hidden;
}

button { font: inherit; }

.preview-layout {
  min-height: 100svh;
  display: grid;
  grid-template-columns: clamp(176px, 17vw, 236px) minmax(0, 1fr);
  background: var(--black);
}

.scene-menu {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 28px 22px;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.scene-menu button {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: color .16s ease, border-color .16s ease, background .16s ease;
}

.scene-menu button:hover {
  color: #cfcfcf;
  border-color: var(--line);
}

.scene-menu button.active {
  color: var(--text-active);
  border-color: #3b3b3b;
  background: #151515;
}

.scene-menu button.active::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 78%, transparent);
}

.screen-stage {
  min-width: 0;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(20px, 5vw, 72px);
}

.screen-frame {
  width: min(320px, calc(100vw - clamp(176px, 17vw, 236px) - 48px));
  aspect-ratio: 128 / 160;
  overflow: hidden;
  border: 1px solid #242424;
  background: #000;
  box-shadow: 0 18px 48px #000, 0 0 0 7px #080808;
}

.screen-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.loading {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: var(--black);
  color: #777;
  font-size: 13px;
  transition: opacity .22s ease;
}

.loading.done {
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 680px) {
  body { overflow: auto; }

  .preview-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .scene-menu {
    position: sticky;
    top: 0;
    flex-direction: row;
    justify-content: flex-start;
    padding: 12px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .scene-menu button {
    flex: 0 0 auto;
    width: auto;
    min-height: 42px;
    white-space: nowrap;
  }

  .screen-stage {
    min-height: calc(100svh - 67px);
    padding: 28px 18px;
  }

  .screen-frame {
    width: min(280px, calc(100vw - 44px));
    box-shadow: 0 18px 48px #000, 0 0 0 6px #080808;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scene-menu button,
  .loading { transition: none; }
}
