:root {
  color-scheme: light dark;
  --bg: #0f172a;
  --card: #1e293b;
  --accent: #38bdf8;
  --text: #e2e8f0;
  --muted: #94a3b8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 16px;
}

.card {
  width: 100%;
  max-width: 480px;
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

h1 {
  margin: 0 0 4px;
  font-size: 1.4rem;
}

.subtitle {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}

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

.rec-dot {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #ef4444;
  color: white;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.hidden {
  display: none !important;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

select,
button {
  flex: 1 1 auto;
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

select {
  background: #0f172a;
  color: var(--text);
  border: 1px solid #334155;
  flex-basis: 100%;
}

button {
  background: var(--accent);
  color: #04121f;
}

button:disabled {
  background: #334155;
  color: var(--muted);
  cursor: not-allowed;
}

.status {
  margin-top: 12px;
  min-height: 1.2em;
  font-size: 0.9rem;
  color: var(--muted);
}

.result {
  margin-top: 16px;
  padding: 16px;
  border-radius: 12px;
  background: #0f172a;
  border: 1px solid #334155;
}

.result h2 {
  margin: 0 0 4px;
  color: var(--accent);
}

.message {
  color: var(--muted);
  font-size: 0.85rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 1.6rem;
  line-height: 1;
  padding: 4px 8px;
}

.modal-close:hover {
  color: var(--text);
}

.modal-image {
  width: 100%;
  max-height: 45vh;
  object-fit: contain;
  border-radius: 12px;
  background: #000;
  margin-bottom: 12px;
}

.capture-again-btn {
  margin-top: 16px;
  width: 100%;
}

.frames-section,
.logic-section {
  margin-top: 16px;
  text-align: left;
}

.frames-section h3,
.logic-section h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: var(--text);
}

.frames-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.frame-item {
  width: 76px;
  text-align: center;
}

.frame-item img {
  width: 76px;
  height: 76px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #000;
}

.frame-item .frame-label {
  display: block;
  margin-top: 4px;
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.2;
}

.frame-item .frame-emotion {
  color: var(--accent);
  font-weight: 600;
}

.logic-text {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}


