/* 抽選画面（設計書 §16〜§20）
   光過敏への配慮（§19）：点滅・フラッシュ・明るさや色の急な変化は使わない。背景色は常に同じ。 */

:root {
  --bg: #0f1b33;
  --panel: #16264a;
  --line: #2a3c66;
  --text: #f4f6fb;
  --muted: #a9b4cc;
  --accent: #ffd36b;
  --button: #3b6fd9;
  --danger: #ff9b8a;
  --font: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}
[hidden] { display: none !important; }
button {
  font-family: inherit;
  font-size: 16px;
  padding: 10px 18px;
  border: 0;
  border-radius: 8px;
  background: var(--button);
  color: #fff;
  cursor: pointer;
}
button.secondary { background: #33456e; }
button:disabled { opacity: .45; cursor: default; }
input, select, textarea {
  font-family: inherit;
  font-size: 16px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1528;
  color: var(--text);
}

/* ---- 開催中のイベントがないとき ---- */
.blank {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-size: clamp(20px, 3vw, 36px);
  color: var(--muted);
  text-align: center;
}

/* ---- 左右分割 ---- */
.screen {
  height: 100%;
  display: grid;
  grid-template-columns: 2fr 1fr;
}
.left {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 20px 28px 20px;
}
.event-name { font-size: clamp(16px, 1.6vw, 24px); color: var(--muted); }

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3vh;
  min-height: 0;
  text-align: center;
}
.stage-label { font-size: clamp(22px, 3.2vw, 52px); font-weight: 700; min-height: 1.3em; }
.stage-label.win { color: var(--accent); }
.digits {
  display: flex;
  gap: 0.12em;
  font-size: clamp(48px, 9vw, 170px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.digits span {
  display: inline-block;
  width: 0.78em;
  padding: 0.12em 0;
  text-align: center;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 0.12em;
}
.digits span.unknown { color: var(--muted); }
.stage-prize { font-size: clamp(22px, 3.4vw, 56px); font-weight: 700; min-height: 1.3em; }
.stage-message { font-size: clamp(18px, 2.2vw, 32px); color: var(--muted); }

.pending {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 12px 16px;
  border: 1px solid #8a6d2a;
  border-radius: 10px;
  background: #2b2614;
  color: var(--accent);
}
.controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--panel);
}
.controls label { color: var(--muted); }
.controls select { min-width: 280px; font-size: 18px; }
.remaining { font-size: 18px; min-width: 6em; }
button.start { font-size: 22px; padding: 12px 36px; margin-left: auto; }
.error { min-height: 1.6em; margin-top: 8px; color: var(--danger); }

/* ---- 右：当選履歴と検索 ---- */
.right {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 20px 20px 36px;
  background: var(--panel);
  border-left: 1px solid var(--line);
}
.right h2 { font-size: 18px; margin: 0 0 10px; color: var(--muted); font-weight: 600; }
.history { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.history-list {
  /* --row-h は、設定の表示件数がちょうど収まる1行の高さ（draw.js で計算）*/
  --row-h: 48px;
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
}
.history-list li {
  display: flex;
  align-items: center;
  gap: 0.6em;
  height: var(--row-h);
  padding: 0 4px;
  border-bottom: 1px solid var(--line);
  font-size: calc(var(--row-h) * 0.32);
}
.history-list .num { font-size: calc(var(--row-h) * 0.48); font-weight: 700; font-variant-numeric: tabular-nums; }
.history-list .prize { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-list .ops { display: flex; gap: 6px; }
.history-list .ops button { font-size: 12px; padding: 4px 8px; }
.history-list .empty { color: var(--muted); border: 0; }

.search { padding-top: 14px; border-top: 1px solid var(--line); margin-top: 12px; }
.search-form { display: flex; gap: 8px; }
.search-form input { flex: 1; min-width: 0; font-size: 20px; letter-spacing: .06em; }
.search-result { min-height: 3.2em; margin-top: 10px; font-size: 18px; line-height: 1.5; }
.search-result .state { font-weight: 700; color: var(--accent); }
.search-result .state.muted { color: var(--muted); }

.corner-link { position: absolute; right: 12px; bottom: 8px; font-size: 12px; color: var(--muted); }

/* ---- 全景品の抽選終了 ---- */
.final {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 2vh 3vw 3vh;
}
.final-title { margin: 0 0 2vh; text-align: center; font-size: clamp(22px, 3.4vw, 56px); color: var(--accent); }
.final-area { flex: 1; min-height: 0; overflow: hidden; }
.final-grid {
  /* 行数・文字の大きさは draw.js で、スクロールせずに全件が収まるように決める */
  display: grid;
  grid-auto-flow: column;
  column-gap: 2.5em;
  margin: 0 auto;
  padding: 0;
  list-style: none;
  width: max-content;
  max-width: 100%;
}
.final-grid li { display: flex; gap: 0.8em; white-space: nowrap; line-height: 1.35; }
.final-grid .num { font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---- 確認ダイアログ ---- */
.confirm {
  width: min(480px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
}
.confirm::backdrop { background: rgba(5, 10, 20, .6); }
.confirm h2 { margin: 0 0 8px; font-size: 20px; }
.confirm p { margin: 0 0 14px; white-space: pre-line; }
.confirm label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 14px; }
.confirm textarea { width: 100%; resize: vertical; }
.confirm-actions { display: flex; gap: 10px; margin-top: 16px; }

/* ---- 狭い画面（スマホで閲覧するとき）は上下に並べる ---- */
@media (max-width: 800px) {
  body { overflow: auto; }
  .screen { height: auto; min-height: 100%; grid-template-columns: 1fr; }
  .stage { padding: 24px 0; }
  .right { border-left: 0; border-top: 1px solid var(--line); }
  .history-list { flex: none; max-height: 60vh; }
  .controls select { min-width: 0; width: 100%; }
}
