:root {
  --bg: #f3ede2;
  --paper: #fffdf8;
  --text: #2a2622;
  --muted: #7d746a;
  --line: #d9cfbf;
  --accent: #c8442f;
  --accent-dark: #9e3221;
  --ok: #2f7d4f;
  --sub: #c8442f;   /* 見出しの差し色 */
  --badge: #fff3cf; /* 見出し上のラベル */
  /* --bg 〜 --badge は event.json の theme で上書きできる(js/common.js の applyTheme) */
  --shadow: rgba(60, 40, 20, .1);
  --shadow: color-mix(in srgb, var(--text) 12%, transparent);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.6;
}
a { color: inherit; }
.muted { color: var(--muted); font-size: .88em; }
.error { color: var(--accent-dark); font-size: .9em; margin: .4em 0 0; }

/* ---- 台紙 ---- */
.sheet {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px calc(130px + env(safe-area-inset-bottom));
}
.event-head { text-align: center; padding-top: 16px; }
.event-image {
  display: block;
  width: 100%;
  aspect-ratio: 12 / 5;
  object-fit: cover;
  border-radius: 14px;
  background: var(--line);
}
/* 縦長のポスターは大きくなりすぎないよう幅を抑える */
.event-image.portrait {
  width: min(100%, 300px);
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 2px 10px var(--shadow);
}
.kicker {
  display: inline-block;
  margin: 1em 0 -.3em;
  padding: .15em 1em;
  border-radius: 999px;
  background: var(--badge);
  font-size: .82em;
  font-weight: 800;
  letter-spacing: .1em;
}
.event-head h1 { font-size: 1.3em; margin: .6em 0 .1em; line-height: 1.35; }
.period { color: var(--muted); font-size: .85em; margin: 0; }

.notice {
  margin: 1em 0 0;
  padding: .7em 1em;
  border-radius: 10px;
  background: #fff3cf;
  font-size: .9em;
}
.notice.error { background: #fde3dd; color: var(--accent-dark); }

.progress { margin: 1.2em 0 .6em; }
.progress-text { text-align: center; font-size: .95em; color: var(--muted); }
.progress-text strong { font-size: 2em; color: var(--accent); margin-right: .1em; }
.goal-hint { font-size: .85em; margin-left: .3em; }
.bar {
  position: relative;
  height: 10px;
  border-radius: 5px;
  background: var(--line);
  margin-top: .3em;
}
.bar-fill {
  height: 100%;
  border-radius: 5px;
  background: var(--accent);
  width: 0;
  transition: width .5s ease;
}
.bar-goal {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 3px;
  margin-left: -1.5px;
  background: var(--text);
  border-radius: 2px;
}

.goal-card {
  margin: 1em 0;
  padding: 1em 1.2em 1.2em;
  border-radius: 16px;
  background: var(--paper);
  border: 3px solid var(--accent);
  text-align: center;
}
.goal-badge {
  display: inline-block;
  font-weight: 900;
  font-size: 1.8em;
  letter-spacing: .08em;
  color: var(--accent);
  transform: rotate(-4deg);
}
.goal-message { margin: .4em 0; font-weight: 600; }
/* 達成日時と現在時刻を1行に並べる(狭い画面では折り返す) */
.goal-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 1.2em; margin: 0 0 .8em; color: var(--muted); font-size: .85em; }
.goal-clock { font-variant-numeric: tabular-nums; }
.claimed {
  display: inline-block;
  margin: 0;
  padding: .3em .9em;
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  font-weight: 700;
}

.booths {
  list-style: none;
  padding: 18px 10px;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px 8px;
  background: var(--paper);
  border-radius: 16px;
  box-shadow: 0 1px 3px var(--shadow);
}
.booth-btn {
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.circle {
  position: relative;
  width: min(92px, 24vw);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px dashed var(--line);
  display: grid;
  place-items: center;
  background: #faf6ee;
}
.circle img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}
.circle .no { font-size: 1.6em; font-weight: 800; color: var(--line); }
.booth.stamped .circle { border: 2px solid var(--accent); }
.booth-title {
  margin-top: .4em;
  font-size: .75em;
  line-height: 1.35;
  text-align: center;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.booth:not(.stamped) .booth-title { color: var(--muted); }

/* 朱色の「済」印 */
.seal {
  position: absolute;
  right: -6px;
  bottom: -4px;
  width: 42%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: rgba(255, 253, 248, .85);
  color: var(--accent);
  display: grid;
  place-items: center;
  align-content: center;
  font-weight: 900;
  transform: rotate(-14deg);
  line-height: 1;
}
.seal span { font-size: clamp(12px, 4vw, 17px); }
.seal small { font-size: .55em; font-weight: 700; margin-top: 2px; }
.seal.big { width: 38%; border-width: 4px; right: -4%; bottom: -2%; }
.seal.big span { font-size: 2.2em; }
.seal.big small { font-size: .9em; }
.seal.press { animation: press .45s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes press {
  0% { transform: scale(2.6) rotate(-30deg); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: scale(1) rotate(-14deg); opacity: 1; }
}

/* ---- テストモード(?test=1) ---- */
.test-banner {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0;
  padding: .5em 16px;
  background: repeating-linear-gradient(-45deg, #222 0 12px, #3a3a3a 12px 24px);
  color: #ffe14d;
  font-size: .8em;
  font-weight: 700;
  text-align: center;
}
/* ゴール画面の写真を引換に使い回せないよう、大きく「テスト」と重ねる */
.test-mode .goal-card { position: relative; overflow: hidden; }
.test-mode .goal-card::after {
  content: "テスト";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 4em;
  font-weight: 900;
  color: rgba(0, 0, 0, .22);
  transform: rotate(-12deg);
  pointer-events: none;
}

/* ---- 遊び方・イベント情報(event.json の sections / organizer) ---- */
.about {
  margin-top: 1.2em;
  padding: 1em 1.2em;
  background: var(--paper);
  border-radius: 16px;
  box-shadow: 0 1px 3px var(--shadow);
  font-size: .9em;
}
.about h2 {
  font-size: 1.05em;
  margin: 0 0 .6em;
  padding-left: .6em;
  border-left: 5px solid var(--sub);
  line-height: 1.3;
}
.about p { margin: .6em 0; }
.about-image { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; }
.steps { margin: 0; padding-left: 1.4em; }
.steps li { margin: .3em 0; }
.steps li::marker { color: var(--accent); font-weight: 800; }
.info-list { display: grid; grid-template-columns: 6.5em 1fr; gap: .45em .6em; margin: 1em 0; }
.info-list dt { font-weight: 700; color: var(--accent); }
.info-list dd { margin: 0; }
.links a { color: var(--sub); font-weight: 600; }
.org { display: flex; align-items: center; gap: 1em; }
.org img { width: 72px; height: 72px; object-fit: contain; flex-shrink: 0; }
.org p { margin: 0; color: var(--muted); }

.foot { margin-top: 1.5em; color: var(--muted); font-size: .78em; }
.foot p { margin: .5em 0; }

/* ---- 下部ボタン ---- */
.actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 30%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.btn {
  font: inherit;
  border: 0;
  border-radius: 999px;
  padding: .65em 1.4em;
  cursor: pointer;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); color: #fff; font-weight: 700; }
.btn.primary:active:not(:disabled) { background: var(--accent-dark); }
.btn.big { width: 100%; max-width: 528px; font-size: 1.1em; padding: .85em; box-shadow: 0 4px 12px rgba(158, 50, 33, .3); box-shadow: 0 4px 12px color-mix(in srgb, var(--accent-dark) 30%, transparent); }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); color: var(--text); }
.btn.small { font-size: .82em; padding: .45em 1em; }
.btn.link { background: none; color: var(--muted); text-decoration: underline; font-size: .85em; padding: .3em; }
.btn.ghost-dark { background: rgba(255, 255, 255, .15); color: #fff; border: 1.5px solid rgba(255, 255, 255, .6); }

/* ---- ダイアログ ---- */
dialog { border: 0; padding: 0; color: var(--text); }
dialog::backdrop { background: rgba(30, 20, 10, .55); }
.sheet-dialog {
  width: min(92vw, 420px);
  border-radius: 18px;
  background: var(--paper);
  padding: 1.4em 1.3em 1.3em;
}
.sheet-dialog h2 { margin: 0 0 .3em; font-size: 1.2em; }
.sheet-dialog .row { display: flex; gap: .6em; justify-content: flex-end; margin-top: 1em; }
#code-input {
  width: 100%;
  font: inherit;
  font-size: 1.5em;
  letter-spacing: .12em;
  text-align: center;
  text-transform: uppercase;
  padding: .4em;
  border: 2px solid var(--line);
  border-radius: 10px;
  font-family: ui-monospace, Menlo, monospace;
}
#code-input:focus { outline: none; border-color: var(--accent); }

.booth-detail { text-align: center; }
.bd-lead { margin: 0 0 .6em; font-weight: 800; color: var(--accent); font-size: 1.1em; }
.bd-stamp { position: relative; width: 70%; margin: 0 auto; aspect-ratio: 1; }
.bd-stamp img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; border: 3px solid var(--accent); }
.not-yet .bd-stamp img { filter: grayscale(1) opacity(.35); border: 3px dashed var(--line); }
.not-yet .bd-lead { color: var(--muted); }
.booth-detail h2 { margin: .7em 0 .1em; }
.booth-detail .btn { margin-top: .8em; min-width: 10em; }

.scan-dialog {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  background: #000;
}
.scan-wrap { position: relative; width: 100%; height: 100%; }
#scan-video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame {
  position: absolute;
  left: 50%;
  top: 45%;
  width: min(68vw, 300px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 18px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .45);
  border: 3px solid #fff;
}
.scan-status {
  position: absolute;
  left: 16px;
  right: 16px;
  top: calc(45% + min(34vw, 150px) + 18px);
  margin: 0;
  text-align: center;
  color: #fff;
  font-weight: 600;
  text-shadow: 0 1px 3px #000;
}
#scan-close {
  position: absolute;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  min-width: 10em;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(120px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  background: rgba(30, 25, 20, .9);
  color: #fff;
  padding: .6em 1.2em;
  border-radius: 999px;
  font-size: .9em;
  z-index: 10;
}
