:root {
  --bg: #101726;
  --bg-panel: #1b2743;
  --bg-panel-2: #223056;
  --accent: #e9b949;
  --accent-2: #6ea8fe;
  --text: #f4f6fb;
  --text-dim: #a8b3cf;
  --danger: #ff6b6b;
  --ok: #5ad19b;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans",
    "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", sans-serif;
  background: radial-gradient(circle at 50% -10%, #1c2b4d 0%, var(--bg) 55%) fixed;
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.7;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 18px
    max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ===== ヘッダー ===== */
.app__header {
  text-align: center;
  padding-top: 6px;
}

.app__title {
  font-size: 1.5rem;
  margin: 0;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.app__subtitle {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* ===== 進捗ドット ===== */
.progress {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.progress__dots {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}

.dot {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.1rem;
  background: var(--bg-panel-2);
  color: var(--text-dim);
  border: 2px dashed rgba(255, 255, 255, 0.15);
}

.dot--filled {
  background: linear-gradient(160deg, var(--accent-2), #4a7fe0);
  color: #fff;
  border: 2px solid transparent;
  box-shadow: 0 4px 14px rgba(110, 168, 254, 0.4);
}

.progress__label {
  text-align: center;
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-dim);
}

/* ===== メイン画面 ===== */
.screen {
  flex: 1;
}

.card {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 26px 22px;
  box-shadow: var(--shadow);
  text-align: center;
  animation: pop 0.35s ease;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.card__badge {
  display: inline-block;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  color: var(--bg);
  background: var(--accent);
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 700;
  margin-bottom: 14px;
}

.card__icon {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 8px;
}

.card__title {
  font-size: 1.4rem;
  margin: 0 0 12px;
}

.card__text {
  color: var(--text-dim);
  margin: 0;
  font-size: 0.95rem;
}

.card--error .card__title {
  color: var(--danger);
}

.card--waiting .card__title {
  color: var(--accent-2);
}

.trail {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 18px 0 4px;
  font-size: 1.4rem;
  font-weight: 700;
  flex-wrap: wrap;
}

.trail__item {
  min-width: 42px;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--bg-panel-2);
}

.trail__item--done {
  background: linear-gradient(160deg, var(--accent-2), #4a7fe0);
  color: #fff;
}

.trail__item--pending {
  color: var(--text-dim);
  border: 2px dashed rgba(255, 255, 255, 0.15);
  background: transparent;
}

.trail__arrow {
  color: var(--text-dim);
  font-size: 1rem;
}

/* ===== カメラ ===== */
.scanner {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

.scanner__reader {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
}

/* html5-qrcode が挿入するUIの微調整 */
#reader video {
  border-radius: 12px;
  width: 100% !important;
  height: auto !important;
  display: block;
}

#reader img[alt="Info icon"] {
  display: none;
}

.scanner__hint {
  text-align: center;
  margin: 12px 0 2px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.scanner__hint--ok {
  color: var(--ok);
  font-weight: 700;
}

/* ===== ボタン ===== */
.app__footer {
  padding-top: 4px;
}

.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 15px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.08s ease, opacity 0.2s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: linear-gradient(160deg, var(--accent), #d99a1f);
  color: #2a2000;
  margin-bottom: 10px;
  box-shadow: 0 6px 18px rgba(233, 185, 73, 0.35);
}

.btn--ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1.5px solid rgba(255, 255, 255, 0.18);
}

.btn--ghost:active {
  background: rgba(255, 255, 255, 0.05);
}

.btn--ai {
  background: linear-gradient(160deg, #7c5cff, #5a8dee);
  color: #fff;
  margin-bottom: 10px;
  box-shadow: 0 6px 18px rgba(124, 92, 255, 0.35);
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

/* ============================================================
   ミュージアム（展示室）画面
   ============================================================ */
.museum {
  animation: pop 0.35s ease;
}

.museum__head {
  text-align: center;
  margin-bottom: 16px;
}

.museum__badge {
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  color: var(--bg);
  background: var(--accent);
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 700;
  margin-bottom: 8px;
}

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

.museum__desc {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin: 0;
}

.museum__actions {
  margin: 16px 0 20px;
}

.museum__state {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 24px 8px;
}

/* ギャラリー（展示作品の一覧） */
.gallery {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.artwork {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.artwork__caption {
  margin-top: 12px;
}

.artwork__title {
  font-size: 1.05rem;
  margin: 0 0 6px;
  color: var(--text);
}

.artwork__text {
  font-size: 0.88rem;
  color: var(--text-dim);
  margin: 0 0 8px;
  white-space: pre-wrap;
}

.artwork__ai {
  font-size: 0.85rem;
  color: #cdd7f5;
  background: rgba(124, 92, 255, 0.12);
  border-left: 3px solid #7c5cff;
  padding: 10px 12px;
  border-radius: 8px;
  margin: 8px 0 0;
  white-space: pre-wrap;
}

.artwork__ai-label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: #a79bff;
  margin-bottom: 4px;
  font-weight: 700;
}

.artwork__date {
  font-size: 0.72rem;
  color: #79839e;
  margin-top: 10px;
  text-align: right;
}

/* ============================================================
   額装フレーム
   ============================================================ */
.frame {
  background: linear-gradient(145deg, #d9b26a, #b8863b 45%, #8a5f22);
  padding: 14px;
  border-radius: 6px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45),
    inset 0 0 0 2px rgba(255, 255, 255, 0.15);
}

.frame__inner {
  background: #12161f;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: inset 0 0 0 6px #f6f1e4, inset 0 0 22px rgba(0, 0, 0, 0.6);
  display: grid;
  place-items: center;
  min-height: 160px;
}

.frame__inner img {
  display: block;
  width: 100%;
  height: auto;
}

.frame--empty {
  background: linear-gradient(145deg, #6b6250, #4a4436);
  cursor: pointer;
}

.frame--empty .frame__inner {
  min-height: 190px;
}

.frame__placeholder {
  color: var(--text-dim);
  font-size: 0.95rem;
  font-weight: 700;
}

/* ============================================================
   投稿モーダル
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 20, 0.7);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

.modal[hidden] {
  display: none;
}

.modal__panel {
  background: var(--bg);
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  border-radius: 20px 20px 0 0;
  padding: 18px 18px max(20px, env(safe-area-inset-bottom));
  overflow-y: auto;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: none;
  }
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal__title {
  font-size: 1.15rem;
  margin: 0;
}

.modal__close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}

.picker {
  display: block;
}

.picker__hint {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin: 8px 0 16px;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field__label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.field__input {
  width: 100%;
  background: var(--bg-panel);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 12px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}

.field__input:focus {
  outline: none;
  border-color: var(--accent-2);
}

.field__input--area {
  resize: vertical;
  line-height: 1.6;
}

.ai-status,
.submit-status {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin: 0 0 10px;
}

.ai-status--err,
.submit-status--err {
  color: var(--danger);
}

.ai-status--ok {
  color: var(--ok);
}

/* ============================================================
   オーナーコード入力／満館表示
   ============================================================ */
.btn--sub {
  background: var(--accent-2);
  color: #10233f;
  width: auto;
  padding: 12px 18px;
  white-space: nowrap;
}

.owner-box {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.owner-box__text {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.owner-box__row {
  display: flex;
  gap: 8px;
}

.owner-box__row .field__input {
  flex: 1;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.owner-box__status {
  margin: 10px 0 0;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.owner-box__status--err {
  color: var(--danger);
}

.museum__full {
  text-align: center;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.95rem;
  background: rgba(233, 185, 73, 0.1);
  border: 1px solid rgba(233, 185, 73, 0.3);
  border-radius: 12px;
  padding: 14px;
  margin: 0;
}
