/* シナリオプレイヤー・ジェネレータ共通テーマ */
:root {
  --accent: #10a37f;
  --accent-light: #e6f7f1;
  --accent-text: #0d8a6a;
  --player-bg: #f7f7f8;
  --card-bg: #ffffff;
  --text-primary: #0d0d0d;
  --text-muted: #6e6e80;
  --border: rgba(0, 0, 0, 0.1);
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --bubble-style: 1;
  --font: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Yu Gothic UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-force-light]) {
    --accent: #10a37f;
    --accent-light: #1a3d32;
    --accent-text: #7dd3b0;
    --player-bg: #212121;
    --card-bg: #2f2f2f;
    --text-primary: #ececec;
    --text-muted: #b4b4b4;
    --border: rgba(255, 255, 255, 0.1);
    --shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 15px;
  background: var(--player-bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Player shell ── */
.player-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.player-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.player-card.is-entering { opacity: 0; transform: translateY(12px); }
.player-card.is-exiting { opacity: 0; transform: translateY(-8px); }

.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 16px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.35s ease;
}

.scene-kicker {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.scene-heading {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.scene-heading.title-xl {
  font-size: 26px;
  text-align: center;
  margin-top: 8px;
}

.scene-body {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.75;
  margin-bottom: 16px;
  white-space: pre-wrap;
}

.scene-body.bubble {
  background: var(--accent-light);
  color: var(--text-primary);
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.scene-media {
  margin-bottom: 16px;
  border-radius: var(--radius);
  overflow: hidden;
}
.scene-media img,
.scene-media video {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  display: block;
}
.scene-media iframe {
  width: 100%;
  height: 220px;
  border: none;
  display: block;
}

.scene-actions {
  margin-top: auto;
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-primary);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { background: var(--accent-light); border-color: var(--accent); }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  opacity: 0.92;
  background: var(--accent);
}

.btn-opt {
  text-align: left;
  width: 100%;
  padding: 14px 16px;
}

.btn-ghost {
  background: transparent;
  font-size: 13px;
  color: var(--text-muted);
  border: none;
  padding: 8px;
}

.result-badge {
  display: inline-block;
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 99px;
  background: var(--accent-light);
  color: var(--accent-text);
  font-weight: 600;
  margin-bottom: 10px;
}

/* ── Generator shell ── */
.app-shell { max-width: 900px; margin: 0 auto; padding: 16px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.topbar h1 {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  flex: 1;
}

.main-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--player-bg);
}
.tab {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  border: none;
  background: transparent;
  font-family: inherit;
}
.tab.active {
  background: var(--accent-light);
  color: var(--accent-text);
  font-weight: 600;
}

.panel { display: none; padding: 16px; }
.panel.active { display: block; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.field input[type="text"],
.field input[type="url"],
.field textarea,
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--card-bg);
  color: var(--text-primary);
}
.field textarea { min-height: 80px; resize: vertical; }

.scene-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.scene-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: var(--card-bg);
}
.scene-item.selected { border-color: var(--accent); background: var(--accent-light); }
.scene-item .type-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--player-bg);
  color: var(--text-muted);
  flex-shrink: 0;
}
.scene-item .scene-label { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.row-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text-primary);
  color: var(--card-bg);
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 13px;
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  z-index: 100;
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

.preview-frame {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 420px;
  background: var(--player-bg);
}
.preview-frame iframe { width: 100%; height: 480px; border: none; display: block; }

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; line-height: 1.5; }

.option-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  align-items: center;
}
.option-row input { flex: 1; }
.option-row select { width: 140px; flex-shrink: 0; }

.error-box {
  padding: 16px;
  color: #a32d2d;
  text-align: center;
  font-size: 14px;
}

/* ── Theme custom editor ── */
.theme-custom-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.theme-swatch {
  display: flex;
  align-items: center;
  gap: 8px;
}
.theme-swatch input[type="color"] {
  width: 40px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  cursor: pointer;
}
.theme-swatch span { font-size: 12px; color: var(--text-muted); }

/* ── Menu pick ── */
.menu-pick-counter {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-text);
  margin-bottom: 10px;
}
.menu-group-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.menu-group-tab {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  cursor: pointer;
  font-family: inherit;
  color: var(--text-muted);
}
.menu-group-tab.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 12px;
  padding-right: 2px;
}
.menu-card {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: var(--card-bg);
  transition: border-color 0.15s, transform 0.1s;
  text-align: left;
}
.menu-card:hover { border-color: var(--accent); }
.menu-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}
.menu-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  background: var(--player-bg);
}
.menu-card .menu-name {
  font-size: 11px;
  line-height: 1.35;
  padding: 6px 8px;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.menu-card .menu-check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  display: none;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.menu-card.selected .menu-check { display: flex; }
.menu-card.text-only { padding: 12px; min-height: 64px; }
.menu-card.text-only .menu-name { padding: 0; font-size: 13px; }

.player-shell.wide { max-width: 560px; }
.player-shell.vs-mode { max-width: 420px; }

/* ── VS choice ── */
.vs-compare {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 8px 0 4px;
  flex: 1;
  min-height: 360px;
}
.vs-card {
  position: relative;
  flex: 1;
  min-height: 148px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  background: var(--player-bg);
  font: inherit;
  color: inherit;
  text-align: left;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.vs-card:hover { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }
.vs-card:active { transform: scale(0.99); }
.vs-card__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.vs-card__name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  padding: 28px 14px 12px;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  line-height: 1.35;
  color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.3) 55%, transparent 100%);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}
.vs-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 0;
  flex-shrink: 0;
}
.vs-divider__line {
  flex: 1;
  height: 1px;
  background: var(--border);
}
.vs-divider__badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--card-bg);
}

/* ── Image choice grid (STEP3) ── */
.image-choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 8px 0 12px;
}
.image-choice-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card-bg);
  cursor: pointer;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  transition: border-color 0.15s, transform 0.1s;
}
.image-choice-card:hover { border-color: var(--accent); }
.image-choice-card:active { transform: scale(0.98); }
.image-choice-card img,
.image-choice-card__placeholder {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: var(--player-bg);
}
.image-choice-card__label {
  display: block;
  padding: 10px 10px 12px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
}

/* ── Campus Producer Pass ── */
.producer-pass {
  border: 1.5px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(16, 163, 127, 0.08) 0%, transparent 42%),
    var(--card-bg);
  box-shadow: var(--shadow);
  margin-bottom: 8px;
}
.pass-header {
  padding: 18px 16px 14px;
  background: linear-gradient(120deg, #0f766e 0%, #14b8a6 55%, #5eead4 100%);
  color: #fff;
  text-align: center;
}
.pass-eyebrow {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
}
.pass-univ {
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: 0.08em;
  opacity: 0.9;
}
.pass-section {
  padding: 14px 16px 4px;
}
.pass-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent-text);
  margin-bottom: 6px;
}
.pass-cafeteria {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.35;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.pass-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.pass-menus {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.pass-menu {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--player-bg);
}
.pass-menu img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}
.pass-menu span {
  display: block;
  padding: 6px;
  font-size: 10px;
  line-height: 1.35;
  font-weight: 600;
  color: var(--text-primary);
  min-height: 2.7em;
}
.pass-comments {
  list-style: none;
  margin: 0 0 12px;
  padding: 0 16px 12px;
}
.pass-comments li {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
  padding: 8px 12px;
  margin-bottom: 6px;
  background: var(--accent-light);
  border-radius: 10px;
  color: var(--text-primary);
}

@media (max-width: 420px) {
  .pass-menus { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .vs-compare { min-height: 320px; }
}
