:root {
  --ink: #2b2620;
  --paper: #fbf6ea;
  --accent: #e9a23b;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #f3d9a4;
  font-family: "Noto Sans TC", sans-serif;
  color: var(--ink);
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.pg-speed {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.pg-bar {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}

.pg-bar > * {
  pointer-events: auto;
}

.is-camera .pg-bar {
  z-index: 2;
}

.pg-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.pg-feedback {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.pg-feedback svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linejoin: round;
}

.pg-sound {
  position: fixed;
  top: 14px;
  right: 14px;
  padding: 4px;
  border: 0;
  background: none;
  color: #fff;
  cursor: pointer;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.pg-sound svg {
  display: block;
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pg-sound[aria-pressed="false"] .pg-sound-on,
.pg-sound[aria-pressed="true"] .pg-sound-off {
  display: none;
}

.pg-fb {
  width: min(420px, calc(100% - 32px));
  padding: 18px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
}

.pg-fb::backdrop {
  background: rgba(43, 38, 32, 0.45);
}

.pg-fb-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pg-fb h2 {
  margin: 0;
  font-size: 1.1rem;
}

.pg-fb textarea,
.pg-fb input {
  width: 100%;
  padding: 8px 10px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: #fffaf0;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

.pg-fb textarea {
  resize: vertical;
}

.pg-fb .pg-fb-trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.pg-fb-status {
  min-height: 1.4em;
  margin: 0;
  font-size: 0.9rem;
}

.pg-fb-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.pg-fb-actions button {
  padding: 6px 16px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fffaf0;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.pg-fb-actions .pg-fb-send {
  background: var(--ink);
  color: var(--paper);
}

.pg-fb-send:disabled {
  opacity: 0.5;
}

.pg-back,
.pg-view,
.pg-camera,
.pg-progress {
  padding: 6px 14px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  margin: 0;
}

.pg-view,
.pg-camera {
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.pg-view {
  margin-left: auto;
}

.pg-camera.is-on {
  background: var(--ink);
  color: var(--paper);
}

.pg-progress {
  margin-left: 0;
}

.pg-intro {
  position: fixed;
  left: 12px;
  bottom: 96px;
  max-width: min(420px, calc(100% - 24px));
  margin: 0;
  padding: 10px 14px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--paper);
  font-size: 0.9rem;
  line-height: 1.6;
  transition: opacity 0.6s;
}

.pg-keys {
  display: block;
  width: 300px;
  max-width: 100%;
  height: auto;
}

.pg-keys .k-edge {
  fill: var(--ink);
}

.pg-keys .k-cap {
  fill: #fffaf0;
  stroke: var(--ink);
  stroke-width: 2.5;
}

.pg-keys text {
  font: 800 17px "Noto Sans TC", sans-serif;
  fill: var(--ink);
  text-anchor: middle;
}

.pg-keys .k-icon,
.pg-keys .k-mouse {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pg-keys .k-icon circle:first-child {
  fill: var(--ink);
}

.pg-keys .k-mouse > rect:first-child {
  fill: #fffaf0;
}

.pg-keys .k-wheel {
  fill: var(--accent);
  stroke: none;
}

.pg-intro.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.pg-dex {
  position: fixed;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 8px;
  list-style: none;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  max-width: calc(100% - 24px);
  overflow-x: auto;
}

.pg-dex-item img {
  display: block;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  filter: brightness(0) opacity(0.25);
  transition: filter 0.4s;
}

.pg-dex-item.is-found img {
  filter: none;
}

.pg-toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px 10px 10px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  box-shadow: 0 6px 0 var(--ink);
  animation: pop 0.35s ease-out;
}

.pg-toast[hidden] {
  display: none;
}

.pg-toast-avatar {
  border-radius: 50%;
}

.pg-toast p {
  margin: 0;
}

.pg-toast-label {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 700;
}

.pg-toast-name {
  font-size: 1.3rem;
  font-weight: 700;
}

.pg-toast-latin {
  font-style: italic;
  font-size: 0.85rem;
  opacity: 0.7;
}

.pg-toast-link {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
}

.pg-loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #f3d9a4;
  transition: opacity 0.5s;
}

.pg-loading span {
  width: 48px;
  height: 48px;
  border: 5px solid var(--ink);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

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

@keyframes pop {
  from {
    transform: translateX(-50%) scale(0.8);
    opacity: 0;
  }
}

@media (max-width: 600px) {
  .pg-feedback span {
    display: none;
  }

  .pg-dex-item img {
    width: 40px;
    height: 40px;
  }

  .pg-intro {
    bottom: 76px;
  }
}

.is-camera .pg-intro,
.is-camera .pg-dex,
.is-camera .pg-toast,
.is-camera .pg-progress,
.is-camera .pg-back,
.is-camera .pg-view,
.is-camera .pg-feedback {
  display: none;
}

.is-camera .pg-camera {
  margin-left: auto;
  position: relative;
  z-index: 1;
}

.pg-cam {
  position: fixed;
  inset: 0;
  pointer-events: none;
  font-family: "Helvetica Neue", Arial, "Noto Sans TC", sans-serif;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.pg-cam[hidden] {
  display: none;
}

.pg-cam-frame {
  position: absolute;
  box-shadow: 0 0 0 100vmax #000;
}

.pg-cam-grid {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to right, transparent calc(33.33% - 0.5px), rgba(255, 255, 255, 0.35) calc(33.33% - 0.5px), rgba(255, 255, 255, 0.35) calc(33.33% + 0.5px), transparent calc(33.33% + 0.5px), transparent calc(66.67% - 0.5px), rgba(255, 255, 255, 0.35) calc(66.67% - 0.5px), rgba(255, 255, 255, 0.35) calc(66.67% + 0.5px), transparent calc(66.67% + 0.5px)),
    linear-gradient(to bottom, transparent calc(33.33% - 0.5px), rgba(255, 255, 255, 0.35) calc(33.33% - 0.5px), rgba(255, 255, 255, 0.35) calc(33.33% + 0.5px), transparent calc(33.33% + 0.5px), transparent calc(66.67% - 0.5px), rgba(255, 255, 255, 0.35) calc(66.67% - 0.5px), rgba(255, 255, 255, 0.35) calc(66.67% + 0.5px), transparent calc(66.67% + 0.5px));
}

.pg-cam-af {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7%;
  aspect-ratio: 1.25;
  transform: translate(-50%, -50%);
  --c: rgba(255, 255, 255, 0.9);
  background:
    linear-gradient(var(--c), var(--c)) top left / 22% 2px no-repeat,
    linear-gradient(var(--c), var(--c)) top left / 2px 26% no-repeat,
    linear-gradient(var(--c), var(--c)) top right / 22% 2px no-repeat,
    linear-gradient(var(--c), var(--c)) top right / 2px 26% no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / 22% 2px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / 2px 26% no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / 22% 2px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / 2px 26% no-repeat;
}

.pg-cam-af.is-hunting {
  --c: rgba(255, 255, 255, 0.55);
}

.pg-cam-af.is-locked {
  --c: #4cff6a;
  width: 5.5%;
}

.pg-cam-top,
.pg-cam-bottom {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 1.4em;
  padding: 0.6em 1em;
  font-size: clamp(11px, 1.15vw, 16px);
  letter-spacing: 0.02em;
}

.pg-cam-top {
  top: 0;
}

.pg-cam-bottom {
  bottom: 0;
  font-size: clamp(12px, 1.35vw, 19px);
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.45));
}

.pg-cam-spacer {
  flex: 1;
}

.pg-cam-mode {
  padding: 0 0.35em;
  border: 1.5px solid #fff;
  border-radius: 3px;
}

.pg-cam-battery {
  position: relative;
  width: 1.9em;
  height: 0.9em;
  border: 1.5px solid #fff;
  border-radius: 2px;
}

.pg-cam-battery::after {
  content: "";
  position: absolute;
  right: -0.3em;
  top: 25%;
  width: 0.18em;
  height: 50%;
  background: #fff;
}

.pg-cam-battery i {
  position: absolute;
  inset: 2px;
  background: #fff;
}

.pg-cam-flash {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
}

.pg-cam-flash.is-on {
  animation: pg-shutter 0.18s ease-out;
}

@keyframes pg-hint {
  0%,
  85% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes pg-shutter {
  0%,
  45% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.pg-cam-hint {
  position: absolute;
  left: 50%;
  bottom: 56px;
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 12px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.45);
  animation: pg-hint 7s forwards;
  max-width: calc(100% - 32px);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.75);
  text-align: center;
}

.pg-cam-controls {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  pointer-events: auto;
}

.pg-cam-afbtn,
.pg-cam-shutter {
  border: 3px solid #fff;
  border-radius: 50%;
  cursor: pointer;
  touch-action: none;
}

.pg-cam-afbtn {
  width: 52px;
  height: 52px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-weight: 700;
}

.pg-cam-shutter {
  width: 68px;
  height: 68px;
  background: radial-gradient(circle, #fff 0 56%, transparent 58%);
}

.pg-cam-roll {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  pointer-events: auto;
}

.pg-cam-roll img {
  display: block;
  width: 96px;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border: 2px solid #fff;
  border-radius: 3px;
}

@media (max-width: 640px) {
  .pg-cam-roll img {
    width: 64px;
  }

  .pg-cam-hint {
    display: none;
  }
}

.pg-sit {
  position: fixed;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 16px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  font-weight: 700;
  pointer-events: none;
}

.pg-sit[hidden] {
  display: none;
}

.pg-crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: rgba(255, 250, 240, 0.85);
  box-shadow: 0 0 0 1.5px rgba(43, 38, 32, 0.6);
  pointer-events: none;
}

.pg-stick {
  position: fixed;
  width: 112px;
  height: 112px;
  margin: -56px 0 0 -56px;
  border: 3px solid rgba(251, 246, 234, 0.75);
  border-radius: 50%;
  background: rgba(43, 38, 32, 0.18);
  pointer-events: none;
  z-index: 5;
}

.pg-stick[hidden] {
  display: none;
}

.pg-stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  border-radius: 50%;
  background: rgba(251, 246, 234, 0.9);
  box-shadow: 0 2px 6px rgba(43, 38, 32, 0.35);
}

.is-touch,
.is-touch * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body.is-touch {
  overscroll-behavior: none;
}

.pg-touch-buttons {
  display: none;
}

.is-touch .pg-touch-buttons {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  z-index: 4;
}

.is-touch.is-camera .pg-touch-buttons {
  right: 112px;
  flex-direction: row;
}

.pg-touch-buttons button {
  min-width: 56px;
  height: 56px;
  padding: 0 14px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: rgba(251, 246, 234, 0.92);
  color: var(--ink);
  font: 700 15px "Noto Sans TC", sans-serif;
  touch-action: manipulation;
}

.pg-touch-buttons button[aria-pressed="true"] {
  background: var(--accent);
}

.is-touch .pg-sit {
  bottom: 200px;
  pointer-events: auto;
  padding: 8px 18px;
  font-size: 14px;
}

.is-touch .pg-intro {
  max-width: min(280px, calc(100% - 24px));
  padding: 6px 10px;
  border-width: 2px;
  font-size: 12px;
  line-height: 1.45;
}

.is-touch .pg-cam-hint {
  font-size: 11px;
}
