@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Noto+Sans+JP:wght@400;700;900&display=swap');

:root {
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface2: #eceef3;
  --text: #1a1c22;
  --muted: #6a6f7e;
  --line: #dcdfe6;
  --accent: #ff5a36;
  --accent-ink: #ffffff;
  --danger: #d63a3a;
  --ok: #1f9d55;
  --radius: 12px;
  --num: 'Bebas Neue', 'Oswald', Impact, sans-serif;
  --jp: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic UI', system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111217;
    --surface: #1a1c23;
    --surface2: #242732;
    --text: #eceef3;
    --muted: #9aa0b0;
    --line: #2e3240;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--jp); background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- view switch ---------- */
html[data-view="display"] #control { display: none; }
html[data-view="control"] #display { display: none; }
html[data-view="display"] body { background: #0b0c10; overflow: hidden; }

/* ---------- control shell ---------- */
.ctl-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.ctl-head h1 { font-size: 18px; margin: 0; font-weight: 900; }
.ctl-head .back { color: var(--muted); text-decoration: none; font-size: 14px; }
.ctl-head .back:hover { color: var(--text); }
.head-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.ctl-main {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 440px);
  gap: 20px; padding: 20px; max-width: 1400px; margin: 0 auto; align-items: start;
}
@media (max-width: 900px) {
  .ctl-main { grid-template-columns: 1fr; padding: 16px; }
  /* 狭い画面ではプレビューを上に置くが、貼り付けない（貼り付くとボタンを隠してしまう） */
  .ctl-main .preview { order: -1; position: static; }
  .ctl-main .preview .ad { min-height: 100px; }
}
.panel { display: grid; gap: 16px; min-width: 0; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; min-width: 0;
}
.card h2 { font-size: 14px; margin: 0 0 12px; color: var(--muted); font-weight: 700; letter-spacing: .04em; }
.preview { position: sticky; top: 76px; display: grid; gap: 8px; }
.preview-box {
  aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden;
  background: #0b0c10; border: 1px solid var(--line);
}
/* プレビューは見るだけ。クリックできるとキーボードの入力先がプレビューに移り、ショートカットが効かなくなる */
.preview-box iframe { width: 100%; height: 100%; border: 0; display: block; pointer-events: none; }
.preview p { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.6; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
label.field { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
input[type="text"], input[type="number"], select, textarea {
  background: var(--surface2); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; width: 100%; min-width: 0;
}
textarea { resize: vertical; line-height: 1.6; }
input[type="color"] { width: 44px; height: 38px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: var(--surface2); }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  border: 1px solid var(--line); background: var(--surface2); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font-weight: 700; white-space: nowrap;
  transition: transform .06s, filter .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.big { font-size: 22px; padding: 16px 28px; border-radius: 12px; width: 100%; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.switch { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; cursor: pointer; user-select: none; }
.note { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.6; }

/* ---------- display chrome ---------- */
.disp { position: fixed; inset: 0; color: #fff; overflow: hidden; font-family: var(--jp); user-select: none; }
.fs-hint {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: rgba(0,0,0,.7); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; z-index: 100; transition: opacity .6s; pointer-events: none;
}
.fs-hint kbd { border: 1px solid #888; border-radius: 4px; padding: 0 5px; font-family: inherit; }
.fs-hint.gone { opacity: 0; }
.fs-btn {
  position: fixed; right: 14px; top: 14px; z-index: 100;
  background: rgba(0,0,0,.55); color: #fff; border: 1px solid rgba(255,255,255,.25);
  border-radius: 8px; padding: 6px 12px; cursor: pointer; transition: opacity .4s;
}
/* ---------- display shared parts ---------- */
.stage {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3vmin; padding: 5vmin; text-align: center;
  background: var(--stage, radial-gradient(circle at 50% 40%, #232838, #0b0c10 72%));
}
.d-title { font-weight: 900; font-size: 5vmin; color: #ffd84d; letter-spacing: .06em; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-title:empty { display: none; }
.d-sub { font-size: 3.2vmin; color: #b4b9c8; }
.d-num { font-family: var(--num); line-height: .9; font-variant-numeric: tabular-nums; }
.fitbox { width: 90vw; display: flex; align-items: center; justify-content: center; overflow: hidden; font-weight: 900; line-height: 1.25; word-break: break-word; overflow-wrap: anywhere; text-align: center; }
.pop { animation: popin .55s cubic-bezier(.3,1.6,.5,1) both; }
@keyframes popin { 0% { transform: scale(.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.rise { animation: rise .5s ease-out both; }
@keyframes rise { 0% { transform: translateY(4vmin); opacity: 0; } 100% { transform: none; opacity: 1; } }
.jitter { animation: jitter .12s linear infinite; }
@keyframes jitter { 0%,100% { transform: translate(0,0) rotate(-1deg); } 50% { transform: translate(0,-.5vmin) rotate(1deg); } }
.blink { animation: blink2 .6s steps(2) infinite; }
@keyframes blink2 { 50% { opacity: .25; } }
.hidden { display: none !important; }

/* control shared */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 560px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--surface2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.mono { font-family: var(--num); font-size: 48px; text-align: center; line-height: 1; }
.list { display: grid; gap: 6px; }
.list .li { display: flex; gap: 8px; align-items: center; background: var(--surface2); border-radius: 8px; padding: 6px 10px; }
textarea.items { min-height: 180px; }

/* ---------- 広告枠（操作画面・各ページのみ。出力画面には出さない） ---------- */
.ad { min-height: 100px; border: 1px dashed var(--line); border-radius: var(--radius); display: grid; place-items: center; color: var(--muted); font-size: 12px; background: var(--surface); overflow: hidden; }
.ad:empty::before { content: '広告スペース'; letter-spacing: .1em; }
.ad.ad-live { border: 0; background: none; min-height: 0; display: block; }
.preview .ad { min-height: 250px; }
html[data-view="display"] .ad { display: none !important; }

/* ---------- タグ ---------- */
.tagrow { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--surface2); color: var(--muted); text-decoration: none; border: 1px solid var(--line); white-space: nowrap; }
a.tag:hover { color: var(--text); border-color: var(--accent); }
.tag.t-学校 { background: #e3f0ff; color: #1d4f91; border-color: #c4dcfb; }
.tag.t-仕事 { background: #ececf4; color: #3c3f58; border-color: #d6d7e6; }
.tag.t-スポーツ { background: #e2f6e9; color: #17663a; border-color: #c2e8cf; }
.tag.t-あそび { background: #fff0d6; color: #8a5300; border-color: #f6dcae; }
.tag.t-イベント { background: #fde3ec; color: #9c1f4f; border-color: #f6c5d6; }
@media (prefers-color-scheme: dark) {
  .tag[class*="t-"] { background: var(--surface2); border-color: var(--line); color: var(--text); }
}
.first-time { font-size: 12px; }
.first-time a { color: var(--accent); }

/* ---------- 名簿バー・ダイアログ ---------- */
.rbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 6px; font-size: 13px; font-weight: 700; }
.rbar .rlink { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: auto; }
.nz-modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 1000; padding: 16px; }
.nz-dialog { background: var(--surface); color: var(--text); border-radius: 14px; width: min(560px, 100%); max-height: 86vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.nz-dhead { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.nz-dbody { padding: 16px; overflow: auto; }
.nz-rlist { display: grid; gap: 6px; }
.nz-ritem { text-align: left; display: grid; gap: 2px; background: var(--surface2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.nz-ritem:hover { border-color: var(--accent); }
.nz-ritem small { color: var(--muted); }
a.btn { text-decoration: none; display: inline-block; }

/* ---------- 説明ページ（ガイド・説明書・名簿） ---------- */
.doc { max-width: 920px; margin: 0 auto; padding: 0 20px 64px; line-height: 1.85; }
.doc h1 { font-size: clamp(26px, 5vw, 38px); margin: 32px 0 8px; }
.doc h2 { font-size: 22px; margin: 40px 0 12px; padding-bottom: 6px; border-bottom: 2px solid var(--line); scroll-margin-top: 70px; }
.doc h3 { font-size: 17px; margin: 24px 0 6px; }
.doc .lead { color: var(--muted); font-size: 16px; }
.doc ol, .doc ul { padding-left: 1.4em; }
.doc li { margin: 4px 0; }
.doc kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 6px; font-family: inherit; font-size: .9em; background: var(--surface2); }
.doc .box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin: 12px 0; }
.doc .warn { border-left: 6px solid #e08a00; }
.doc .danger { border-left: 6px solid var(--danger); }
.doc .ok { border-left: 6px solid var(--ok); }
.doc .toc { display: flex; flex-wrap: wrap; gap: 6px; }
.doc .toc a { font-size: 13px; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }
.doc .toc a:hover { border-color: var(--accent); }
.site-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.site-head .logo { font-weight: 900; font-size: 18px; color: var(--text); text-decoration: none; }
.site-head .logo span { color: var(--accent); }
.site-head nav { margin-left: auto; display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; }
.site-head nav a { color: var(--muted); text-decoration: none; }
.site-head nav a:hover, .site-head nav a.on { color: var(--text); }
.site-foot { margin-top: 48px; padding: 24px 20px 40px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); text-align: center; line-height: 2; }
.site-foot a { color: var(--muted); margin: 0 8px; }

/* ---------- 押し間違い対策：長押しボタン ---------- */
[data-hold] { position: relative; overflow: hidden; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
[data-hold]::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(214,58,58,.28); pointer-events: none; }
[data-hold].holding::before { width: 100%; transition: width var(--hold, 800ms) linear; }
[data-hold]::after { content: '長押し'; font-size: 10px; font-weight: 700; margin-left: 6px; padding: 0 5px; border-radius: 4px; background: rgba(0,0,0,.08); vertical-align: 1px; }
[data-hold].hold-hint { animation: holdhint .4s; }
[data-hold].hold-hint::after { content: '長押ししてください'; background: var(--danger); color: #fff; }
/* 6秒など長い長押しのボタン */
[data-hold][data-confirm]::after { content: '6秒長押し'; background: var(--danger); color: #fff; }
[data-hold][data-confirm].hold-hint::after { content: '6秒間押し続けてください'; }
[data-hold][data-left]::after { content: 'あと ' attr(data-left) ' 秒'; background: var(--danger); color: #fff; }
.btn.danger-fill { background: var(--danger); color: #fff; border-color: transparent; }
@keyframes holdhint { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
/* 危ないボタンは他のボタンから離して、右端に置く */
.row > [data-hold], .grid3 > [data-hold] { margin-left: auto; }

/* ---------- 目隠し画面（投票・役職確認など） ---------- */
.nz-secret { position: fixed; inset: 0; z-index: 2000; background: var(--bg); display: grid; place-items: center; padding: 20px; overflow: auto; }
.nz-secret[hidden] { display: none; }
.nz-sbox { width: min(560px, 100%); text-align: center; display: grid; gap: 14px; }
.nz-sbox h2 { margin: 0; font-size: clamp(22px, 5vw, 32px); }
.nz-sbox p { margin: 0; color: var(--muted); line-height: 1.7; }
.nz-big { font-size: 64px; line-height: 1; }
.nz-step { font-size: 13px; color: var(--muted); font-weight: 700; }
.nz-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.nz-choices .btn { padding: 16px 8px; font-size: 18px; white-space: normal; }
.nz-sfoot { margin-top: 18px; }
.nz-reveal { position: relative; border-radius: 16px; min-height: 180px; display: grid; place-items: center; background: var(--surface2); border: 2px dashed var(--line); cursor: pointer; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none; }
.nz-reveal .rv-cover { font-size: 20px; font-weight: 900; display: grid; gap: 6px; }
.nz-reveal .rv-cover small { font-size: 12px; color: var(--muted); font-weight: 400; }
.nz-reveal .rv-body { display: none; padding: 16px; }
.nz-reveal.show { background: var(--surface); border-style: solid; border-color: var(--accent); }
.nz-reveal.show .rv-cover { display: none; }
.nz-reveal.show .rv-body { display: block; }
body.secret-on { overflow: hidden; }

body.idle { cursor: none; }
body.idle .fs-btn { opacity: 0; pointer-events: none; }
