:root {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: #f6f6f6;
  color: #111;
}

body.is-face {
  overflow: hidden;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.header {
  margin-bottom: 16px;
}

.title {
  margin: 0;
  font-size: 24px;
}

.subtitle {
  margin: 6px 0 0;
  color: #444;
}

.panel {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 16px;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
}

.sample-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.sample-card {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid #ddd;
  border-radius: 12px;
  background: #fafafa;
  cursor: pointer;
  overflow: hidden;
}

.sample-card img {
  display: block;
  width: 100%;
  height: 200px;
  object-fit: cover;
  object-position: top;
}

.sample-card .sample-label {
  padding: 10px 12px;
  color: #111;
  font-size: 14px;
}

.file-input-hidden {
  position: absolute;
  left: -99999px;
  top: -99999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.sample-card.sample-upload {
  display: flex;
  flex-direction: column;
}

.sample-card.sample-upload .upload-box {
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  color: #444;
  text-align: center;
}

.topbar {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 12px;
  margin-bottom: 12px;
}

.controls {
  display: flex;
  flex: 1;
  flex-wrap: nowrap;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 0;
}

.control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 10px;
  background: #fafafa;
}

.btn {
  border: 1px solid #ddd;
  background: #fafafa;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

@media (max-width: 480px) {
  .topbar {
    gap: 8px;
  }

  .controls {
    gap: 8px;
  }

  .btn {
    padding: 8px 10px;
    font-size: 13px;
  }

  .control {
    padding: 6px 8px;
    font-size: 12px;
    gap: 6px;
  }

  #screenFace.is-active .topbar {
    left: 8px;
    right: 8px;
    top: 8px;
  }
}

.btn[disabled] {
  cursor: not-allowed;
  opacity: 0.6;
}

.stage {
  position: relative;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  background: #111;
  border-radius: 12px;
  overflow: hidden;
}

/* 顔はめ画面では黒キャンバスを画面高いっぱいに */
#screenFace.is-active {
  position: fixed;
  inset: 0;
  z-index: 10;
}

#screenFace.is-active .topbar {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 12px;
  z-index: 2;
  margin-bottom: 0;
}

#screenFace.is-active .stage {
  width: 100vw;
  height: 100vh;
  max-width: none;
  margin: 0;
  aspect-ratio: auto;
  border-radius: 0;
}

#canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#video {
  position: absolute;
  left: -99999px;
  top: -99999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.hint {
  margin: 12px 0 0;
  color: #444;
}

.footer {
  margin-top: 14px;
  color: #666;
}

code {
  background: #f2f2f2;
  padding: 0 6px;
  border-radius: 6px;
}
