:root {
  --bg: #0e1424;
  --panel: #182038;
  --line: #2b3557;
  --text: #f2f4fa;
  --muted: #9aa6c4;
  --accent: #ffd77a;
  --accent-ink: #3a2700;
  --ok: #5cf2c0;
  --danger: #ff8a8a;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(circle at 50% -10%, #23305a 0, var(--bg) 60%) fixed;
  color: var(--text);
  font-family: 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
main { max-width: 520px; margin: 0 auto; padding: 16px 16px 48px; }
h1 { font-size: 22px; margin: 8px 0 12px; }
h2 { font-size: 17px; margin: 24px 0 8px; color: var(--accent); }
p { margin: 8px 0; }
a { color: var(--accent); }
.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 12px 0; }
.error { background: #3a1820; border: 1px solid #6a2a36; color: var(--danger); border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.notice { background: #13352c; border: 1px solid #1f6b54; color: var(--ok); border-radius: 10px; padding: 10px 12px; margin: 10px 0; }

canvas.card { width: 100%; height: auto; display: block; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
canvas.card-small { width: 100%; height: auto; display: block; border-radius: 10px; }

label { display: block; font-size: 14px; margin: 14px 0 6px; color: var(--muted); }
input[type=text], input[type=password], input[type=number], select {
  width: 100%; font-size: 20px; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: #0b1020; color: var(--text);
}
input.pin { letter-spacing: 8px; text-align: center; font-size: 26px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--text); }
.check input { width: 22px; height: 22px; margin-top: 2px; flex: none; }

button, .button {
  display: inline-block; font: inherit; font-size: 17px; font-weight: 700; cursor: pointer;
  border: none; border-radius: 12px; padding: 14px 18px; text-decoration: none; text-align: center;
}
.primary { background: var(--accent); color: var(--accent-ink); width: 100%; margin-top: 18px; }
.secondary { background: transparent; color: var(--text); border: 1px solid var(--line); width: 100%; margin-top: 10px; }
button:disabled { opacity: .5; cursor: default; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-size: 14px; font-weight: 600; padding: 8px 12px; border-radius: 999px;
  background: #0b1020; color: var(--text); border: 1px solid var(--line);
}
.chip.selected { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip.locked { opacity: .45; }
.chip .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

.family-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 12px; font-size: 14px; }
.family-list { display: flex; flex-wrap: wrap; gap: 6px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 26px; }
.spots { list-style: none; padding: 0; margin: 0; }
.spots li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.spots li.got span:last-child { color: var(--ok); font-weight: 700; }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.friend { background: none; padding: 0; border-radius: 10px; }
.friend p { margin: 4px 0 0; font-size: 13px; color: var(--muted); text-align: center; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.overlay canvas { max-height: 90vh; width: auto; max-width: 100%; }

.big-message { font-size: 22px; font-weight: 800; text-align: center; margin: 16px 0; }
.nav { display: flex; gap: 10px; margin-top: 16px; }
.nav a { flex: 1; }

/* マイページのコレクションと閲覧（第2段） */
.collection li { align-items: center; gap: 8px; }
.collection li.locked span:first-child { opacity: .6; }
.collection li span.muted { font-size: 13px; text-align: right; }
.collection .chip { margin: 0; flex-shrink: 0; }
.viewer { position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; flex-direction: column; justify-content: center; padding: 16px; overflow-y: auto;
  -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.viewer-body { max-width: 560px; width: 100%; margin: 0 auto; }
.viewer-image { display: block; width: 100%; height: auto; border-radius: 14px;
  -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; pointer-events: none; }
.viewer-audio { font-size: 96px; text-align: center; margin: 12px 0; }
.viewer audio { width: 100%; }
.viewer-close { max-width: 560px; margin: 16px auto 0; }

/* マイページの会期後の抽選（第4段-A） */
.lottery-box:empty { display: none; }
.lottery-box { margin-top: 8px; }
.lottery-points { font-size: 18px; font-weight: 800; color: var(--accent); margin: 4px 0 8px; }
.lottery li { align-items: center; gap: 8px; }
.lottery .prize small { display: block; font-size: 13px; margin-top: 2px; }
.lottery .stepper { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.lottery .stepper .chip { min-width: 40px; margin: 0; }
.lottery .stepper .chip:disabled { opacity: .35; }
.lottery li.result { display: block; }
.lottery li.result .result-text { display: block; margin-top: 6px; }
.lottery li.result.win .result-text { color: var(--ok); font-weight: 800; font-size: 20px; }
.lottery li.result.win small { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 6px; }
.lottery .code { display: block; font-size: 28px; letter-spacing: 3px; color: var(--accent); font-variant-numeric: tabular-nums; }

/* 管理画面（第4段-B） */
body.admin main { max-width: 980px; }
.admin-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.admin-head .source { font-size: 13px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.admin-head .source.db { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.admin-tabs { margin: 8px 0 4px; }
.admin-tabs .demo-link { margin-left: auto; text-decoration: none; border-style: dashed; }
.admin-table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; font-size: 14px; }
.admin-table th, .admin-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table th { color: var(--muted); font-weight: 600; }
.admin-table tr.off td { opacity: .45; }
.admin-table .chip { margin: 0; }
body.admin select, body.admin input[type=number] { width: 100%; }
.url-once input { font-size: 13px; }
.warn { color: var(--danger); }
p.big { font-size: 20px; font-weight: 800; margin: 0 0 6px; }
body.admin h3 { font-size: 15px; margin: 18px 0 6px; color: var(--accent); }
@media (max-width: 600px) {
  /* スマホでは表の1行を小さなカードのように積む */
  .admin-table tr:first-child { display: none; }
  .admin-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .admin-table td { border: 0; padding: 0; }
  .admin-table td:first-child { width: 100%; font-weight: 700; font-size: 15px; }
  .admin-table td:last-child { margin-left: auto; }
  .admin-table .chip { white-space: nowrap; }
}

/* デモ用の画面（第4段-B） */
body.demo main { max-width: 520px; }
.demo-banner { margin: 0 0 8px; padding: 8px 12px; border-radius: 10px; background: #3a2a07; color: var(--accent);
  border: 1px dashed var(--accent); font-size: 13px; font-weight: 700; text-align: center; }
.demo-terms { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.demo-term { padding: 16px 10px; border-radius: 14px; font-size: 18px; font-weight: 800; color: var(--text);
  background: var(--panel); border: 2px solid var(--line); text-align: left; margin: 0; }
.demo-term small { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.demo-term.stall { border-color: #6b4f1d; }
.demo-term.vote { border-color: #6b1d2d; }
.demo-btn { padding: 16px; font-size: 17px; }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); width: 100%; margin-top: 10px; }

/* button などに display を付けると hidden 属性が効かなくなる。必ず隠れるようにする */
[hidden] { display: none !important; }
