* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 1rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f5f7;
  color: #1c1c1e;
}

header {
  text-align: center;
  margin-bottom: 1.5rem;
}

h1 {
  margin: 0 0 0.25rem 0;
  font-size: 1.6rem;
}

.subtitle {
  margin: 0;
  color: #6b6b70;
  font-size: 0.95rem;
}

main {
  max-width: 480px;
  margin: 0 auto;
}

section {
  background: #ffffff;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.row {
  display: flex;
  gap: 0.5rem;
}

input[type="password"] {
  flex: 1;
  padding: 0.6rem 0.75rem;
  border: 1px solid #d0d0d5;
  border-radius: 8px;
  font-size: 1rem;
}

.hint {
  margin: 0.5rem 0 0 0;
  font-size: 0.8rem;
  color: #8a8a8e;
}

button {
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 8px;
  background: #0071e3;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

button:disabled {
  background: #b0c9e4;
  cursor: not-allowed;
}

.capture-btn {
  display: block;
  text-align: center;
  padding: 0.9rem 1rem;
  border-radius: 8px;
  background: #0071e3;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 0.75rem;
}

.capture-btn input {
  display: none;
}

#previewWrap {
  margin-bottom: 0.75rem;
  border-radius: 8px;
  overflow: hidden;
}

#preview {
  display: block;
  width: 100%;
  height: auto;
}

#status {
  text-align: center;
  font-size: 0.95rem;
  color: #6b6b70;
}

body.running header,
body.running #settings,
body.running #capture,
body.calibrating header,
body.calibrating #settings,
body.calibrating #capture {
  display: none;
}

body.running #status,
body.calibrating #status {
  position: fixed;
  top: 0.75rem;
  left: 0;
  right: 0;
  z-index: 20;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

#resultWrap,
#calibrateWrap {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #1c1c1e;
  padding: 1.5rem;
}

#calibrateWrap #camera {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#calibrateWrap #beginBtn {
  position: absolute;
  bottom: 2rem;
  left: 1.5rem;
  right: 1.5rem;
  padding: 1rem;
  font-size: 1.1rem;
}

#stopBtn,
.ghost-btn {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.ghost-btn {
  right: auto;
  left: 1rem;
}

#captureBar {
  position: absolute;
  top: 0.85rem;
  left: 0;
  right: 4.5rem;
  z-index: 11;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  color: #d0d0d5;
  font-size: 0.85rem;
}

.capture-icon {
  display: inline-block;
  font-size: 1rem;
}

.capture-icon.flash {
  animation: captureFlash 0.4s ease-out;
}

@keyframes captureFlash {
  0% {
    transform: scale(1.7);
    opacity: 0.35;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.question {
  margin: 0 0 1rem 0;
  max-width: 480px;
  font-size: 1rem;
  font-style: italic;
  color: #d0d0d5;
  text-align: center;
}

.swatch {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1.6 / 1;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #d0d0d5;
}

.swatch span {
  font-size: 6rem;
  font-weight: 700;
  color: #fff;
}

.swatch.answer-b span {
  color: #1c1c1e;
}

.answer-text {
  margin: 1rem 0 0 0;
  max-width: 480px;
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  text-align: center;
}

.detail {
  margin: 0.5rem 0 0 0;
  font-size: 0.9rem;
  color: #9a9a9e;
  text-align: center;
  max-width: 480px;
}

.hidden {
  display: none !important;
}

.error {
  color: #d70015;
}
