:root {
  color-scheme: dark;
  font-family: Arial, Helvetica, sans-serif;
  background: #101214;
  color: #f4f4f2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #101214;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: #e8c468;
  color: #141414;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 24px;
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 0;
  align-items: center;
}

.capture-panel,
.result-panel {
  display: grid;
  gap: 16px;
}

.camera-stage {
  display: block;
}

.camera-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  background: #1c2024;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.35);
}

video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scaleX(-1);
}

.face-guide {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transform: translateY(-7%);
  pointer-events: none;
}

.face-oval {
  width: min(52%, 340px);
  aspect-ratio: 0.72;
  border: 3px solid rgba(232, 196, 104, 0.95);
  border-radius: 50%;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.22);
}

.center-line {
  position: absolute;
  background: rgba(255, 255, 255, 0.24);
}

.center-line.horizontal {
  width: 26%;
  height: 1px;
}

.center-line.vertical {
  width: 1px;
  height: 24%;
}

.movement-arrow {
  position: absolute;
  z-index: 3;
  width: 132px;
  height: 132px;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 1;
  transition: opacity 150ms ease;
}

.movement-arrow.is-hidden {
  opacity: 0;
}

.arrow-shape {
  position: relative;
  width: 82px;
  height: 26px;
  border-radius: 999px;
  background: #e8c468;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.5));
}

.arrow-shape::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -25px;
  width: 0;
  height: 0;
  border-top: 27px solid transparent;
  border-bottom: 27px solid transparent;
  border-left: 36px solid #e8c468;
  transform: translateY(-50%);
}

.movement-arrow.right {
  top: 50%;
  right: 7%;
  transform: translateY(-50%);
}

.movement-arrow.left {
  top: 50%;
  left: 7%;
  transform: translateY(-50%);
}

.movement-arrow.up {
  top: 5%;
  left: 50%;
  transform: translateX(-50%);
}

.movement-arrow.down {
  bottom: 5%;
  left: 50%;
  transform: translateX(-50%);
}

.movement-arrow.right .arrow-shape {
  animation: arrow-right 800ms ease-in-out infinite;
}

.movement-arrow.left .arrow-shape {
  transform: rotate(180deg);
  animation: arrow-left 800ms ease-in-out infinite;
}

.movement-arrow.up .arrow-shape {
  transform: rotate(-90deg);
  animation: arrow-up 800ms ease-in-out infinite;
}

.movement-arrow.down .arrow-shape {
  transform: rotate(90deg);
  animation: arrow-down 800ms ease-in-out infinite;
}

@keyframes arrow-right {
  0%, 100% { translate: -10px 0; }
  50% { translate: 10px 0; }
}

@keyframes arrow-left {
  0%, 100% { translate: 10px 0; }
  50% { translate: -10px 0; }
}

@keyframes arrow-up {
  0%, 100% { translate: 0 10px; }
  50% { translate: 0 -10px; }
}

@keyframes arrow-down {
  0%, 100% { translate: 0 -10px; }
  50% { translate: 0 10px; }
}

.notice {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  padding: 12px 14px;
  border-radius: 6px;
  background: rgba(16, 18, 20, 0.86);
  color: #f4f4f2;
}

.controls {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.step-label {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
}

.step-help,
.result-header p {
  margin: 0;
  color: #bfc4c8;
  line-height: 1.45;
}

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #2a2f34;
}

#progressBar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #e8c468;
  transition: width 180ms ease;
}

.motion-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.motion-meter {
  display: grid;
  gap: 8px;
}

.motion-meter span {
  color: #bfc4c8;
  font-size: 14px;
}

.meter-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #2a2f34;
}

.meter-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #7fd1b9;
  transition: width 120ms linear;
}

.review-panel {
  display: grid;
  gap: 14px;
}

.capture-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding: 4px;
}

.capture-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #30363d;
  background: #181b1f;
}

#generateBtn {
  justify-self: end;
}

.result-header h1 {
  margin: 0 0 6px;
  font-size: 28px;
}

.result-frame {
  display: grid;
  place-items: center;
  min-height: 360px;
  aspect-ratio: 1;
  border: 1px solid #30363d;
  border-radius: 8px;
  background: #181b1f;
  overflow: hidden;
}

.result-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#resultPlaceholder {
  color: #8c959f;
}

@media (max-width: 840px) {
  .app-shell {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .camera-stage {
    display: block;
  }

  .camera-wrap {
    aspect-ratio: 3 / 4;
  }

  .movement-arrow {
    width: 104px;
    height: 104px;
  }

  .arrow-shape {
    width: 62px;
    height: 21px;
  }

  .arrow-shape::after {
    right: -21px;
    border-top-width: 22px;
    border-bottom-width: 22px;
    border-left-width: 30px;
  }

  .controls {
    display: grid;
  }

  .motion-panel {
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
  }
}
