/* 抽選ルーレット・くじ引き 固有の見た目（共通は ../common/base.css） */
.linkbtn { display: inline-flex; align-items: center; text-decoration: none; }
.num-choices .choice span { min-width: 64px; justify-content: center; padding: 0 10px; }

/* 並び: 盤（ルーレット・くじ・班）→ 結果 → ボタン → 項目の入力 → 履歴 */
.tool { display: flex; flex-direction: column; }
.wheel-box, .kuji-box, .team-box { order: 1; }
.result { order: 2; } .main-btns { order: 3; } .edit { order: 4; } .hist-box { order: 5; }
.tool[data-mode="team"] .result { order: 1; }
.tool[data-mode="team"] .main-btns { order: 2; }
.tool[data-mode="team"] .team-box { order: 3; }
.tool[data-mode="team"] .hist-box { order: 4; margin-top: 8px; border-top: none; padding-top: 0; }
.tool[data-mode="team"] .edit { order: 5; }

/* ルーレット（盤の色は明るいまま。ダークでも文字が読める） */
.wheel-box { padding-top: 22px; overflow: hidden; } /* 回した盤（正方形）の角が外へ広がって横にはみ出さないように */
.wheel-wrap {
  position: relative; margin: 0 auto; aspect-ratio: 1;
  width: min(100%, 440px, max(250px, calc(100svh - 380px)));
  cursor: pointer; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.tool.busy .wheel-wrap, .tool.busy .kuji-stage { cursor: progress; }
.stage svg.wheel { display: block; width: 100%; height: 100%; transform-origin: 50% 50%; will-change: transform; filter: var(--shadow-piece); }
.wheel .slice { stroke: #FFFFFF; stroke-width: 3; stroke-linejoin: round; transition: fill-opacity .2s; }
.wheel.has-hit .slice:not(.hit) { fill-opacity: .42; }
.wheel .slice.hit { stroke: #1F2328; stroke-width: 7; }
.wheel .rim { fill: none; stroke: #5B616B; stroke-width: 5; }
.wheel .empty-disc { fill: #EFE9DC; stroke: #B9AE95; stroke-width: 4; stroke-dasharray: 16 12; }
.wheel .labels text { fill: #1F2328; font-family: var(--font); font-weight: 600; pointer-events: none; }
.hub {
  position: absolute; left: 50%; top: 50%; width: 17%; height: 17%; transform: translate(-50%, -50%);
  border-radius: 50%; background: #FFFFFF; border: 4px solid #5B616B; box-shadow: 0 1px 2px rgba(0,0,0,.25); pointer-events: none;
}
.stage svg.pointer { position: absolute; left: 50%; top: -20px; width: 46px; height: 50px; transform: translateX(-50%); pointer-events: none; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); z-index: 2; }
.pointer path { fill: #2B2F35; stroke: #FFFFFF; stroke-width: 4; stroke-linejoin: round; }

/* くじ引き（箱と紙。地は紙の色） */
.kuji-stage {
  position: relative; height: 300px; border-radius: var(--radius); background: #EFE9DC; border: 1px solid #D9D0BC; overflow: hidden;
  cursor: pointer; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.box-art { position: absolute; left: 50%; bottom: 14px; width: 220px; height: 150px; transform: translateX(-50%); }
.box-top { position: absolute; left: 0; right: 0; top: 0; height: 40px; background: #E6B97F; border: 3px solid #7A4E2A; border-radius: 8px 8px 2px 2px; z-index: 1; }
.box-hole { position: absolute; left: 50%; top: 9px; width: 104px; height: 22px; transform: translateX(-50%); background: #3A2616; border-radius: 50%; z-index: 1; }
.box-art.empty .box-hole { background: #6E5238; }
.box-front { position: absolute; left: 0; right: 0; top: 36px; bottom: 0; background: #D39A5E; border: 3px solid #7A4E2A; border-radius: 2px 2px 8px 8px; z-index: 3; display: flex; align-items: center; justify-content: center; }
.box-name { color: #3A2616; font-size: 30px; font-weight: 700; letter-spacing: .2em; }
.slip {
  position: absolute; left: 50%; bottom: 120px; width: 64px; height: 34px; z-index: 2; opacity: 0;
  background: #FFFFFF; border: 1px solid #BDB29A; border-radius: 3px; transform: translate(-50%, 40px);
  background-image: linear-gradient(90deg, transparent 49%, #CFC6B0 49%, #CFC6B0 51%, transparent 51%);
}
.slip.rise { animation: rise .9s cubic-bezier(.3, .7, .4, 1) both; }
@keyframes rise {
  0%   { opacity: 1; transform: translate(-50%, 40px) rotate(0deg); }
  35%  { opacity: 1; transform: translate(-50%, -8px) rotate(-4deg); }
  75%  { opacity: 1; transform: translate(-50%, -70px) rotate(3deg) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -100px) rotate(0deg) scale(1.4); }
}
.paper {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 4;
  min-width: 56%; max-width: calc(100% - 24px); padding: 8px 20px 12px; text-align: center;
  background: #FFFFFF; color: #1F2328; border: 1px solid #CFC6B0; border-radius: var(--radius); filter: var(--shadow-piece);
}
.paper[hidden] { display: none; }
.paper-no { display: block; font-size: 14px; color: #5B616B; }
.paper-text { display: block; font-size: 2rem; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.paper.open { animation: unfold .35s ease-out both; }
@keyframes unfold { from { transform: translateX(-50%) scaleY(.08); } to { transform: translateX(-50%) scaleY(1); } }
.kuji-left { text-align: center; margin: 8px 0 0; color: var(--ink-sub); font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .slip.rise, .paper.open { animation: none; } }

/* 班分け */
.teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.teams-empty { grid-column: 1 / -1; margin: 12px 0; text-align: center; color: var(--ink-sub); }
.team { border: 1px solid var(--line); border-top: 5px solid var(--accent); border-radius: var(--radius); padding: 6px 10px 8px; background: var(--board); }
.team:nth-child(4n+2) { border-top-color: var(--p-green); } .team:nth-child(4n+3) { border-top-color: var(--p-red); } .team:nth-child(4n+4) { border-top-color: var(--p-yellow); }
.team-name { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 4px; font-size: 1.1rem; }
.team-n { font-size: 14px; font-weight: 400; color: var(--ink-sub); }
.team-list { list-style: none; margin: 0; padding: 0; }
.team-list li { padding: 3px 0; border-bottom: 1px dashed var(--line); overflow-wrap: anywhere; opacity: 0; transform: translateY(-4px); transition: opacity .18s, transform .18s; }
.team-list li:last-child { border-bottom: none; }
.team-list li.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .team-list li { transition: none; } }

/* 結果 */
.result { text-align: center; margin: 12px 0 0; min-height: 2.6em; line-height: 1.3; overflow-wrap: anywhere; }
.result .lbl { color: var(--ink-sub); font-size: 1rem; }
.result b { font-size: 2.1rem; }
.result.team-sum { min-height: 0; margin: 4px 0 0; font-weight: 700; }
.result.team-sum:empty { display: none; }
.result.pop { animation: rpop .3s ease-out; }
@keyframes rpop { from { transform: scale(.92); opacity: .3; } to { transform: none; opacity: 1; } }

.main-btns { justify-content: center; margin-top: 8px; }
.go-btn { min-width: 170px; min-height: 56px; font-size: 21px; }

/* 項目の入力 */
.edit { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 10px; }
.edit-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.edit-label { font-weight: 700; }
.edit-count { color: var(--ink-sub); font-size: 15px; font-variant-numeric: tabular-nums; }
.edit textarea {
  display: block; width: 100%; box-sizing: border-box; margin-top: 6px; min-height: 180px; resize: vertical;
  font: inherit; font-size: 16px; line-height: 1.5; padding: 8px 10px;
  border: 2px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink);
}
.edit textarea:focus-visible, .num-fill input:focus-visible { outline: 3px solid var(--warn); outline-offset: 1px; }
.edit textarea[readonly] { opacity: .6; }
.edit-btns { margin-top: 8px; }
.num-fill { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.num-fill label { font-size: 15px; color: var(--ink-sub); }
.num-fill input { width: 4.6em; min-height: var(--tap); font: inherit; padding: 0 8px; border: 2px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.out-box { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-top: 10px; padding: 6px 10px; border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.out-list { margin: 0; overflow-wrap: anywhere; }
.out-title { font-weight: 700; }
.kuji-tools { margin-top: 10px; }
.kuji-tools[hidden], .out-box[hidden] { display: none; }

/* これまでの結果 */
.hist-box { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 8px; }
.hist-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.hist-title { font-size: 1rem; margin: 0; }
.hist-btns { display: inline-flex; gap: 8px; }
.hist { list-style: none; margin: 6px 0 0; padding: 0; max-height: 216px; overflow-y: auto; }
.hist li { display: flex; align-items: baseline; gap: 12px; padding: 4px 6px; border-bottom: 1px dashed var(--line); overflow-wrap: anywhere; }
.hist li.new { background: var(--accent-soft); }
.hist li.empty { color: var(--ink-sub); border: none; }
.hist .h-no { color: var(--ink-sub); min-width: 2.2em; text-align: right; font-size: 14px; font-variant-numeric: tabular-nums; flex: none; }
.hist .h-v { font-weight: 700; }

/* 大きく表示（プロジェクター用）: 全画面にできる端末は全画面、できなければページいっぱい */
.tool.big {
  position: fixed; inset: 0; z-index: 100; overflow: auto; background: var(--bg);
  display: flex; flex-direction: column; justify-content: center; padding: 3vh 3vw;
}
.tool.big .edit, .tool.big .hist-box { display: none; }
.tool.big .wheel-box { padding-top: 26px; flex: none; }
.tool.big .wheel-wrap { width: min(92vw, 62vh); }
.tool.big .result b { font-size: 8vh; }
.tool.big .result .lbl { font-size: 3vh; }
.tool.big .result.team-sum { font-size: 3vh; }
.tool.big .go-btn { min-height: 72px; font-size: 26px; min-width: 240px; }
.tool.big .kuji-stage { height: 62vh; }
.tool.big .paper-text { font-size: 9vh; }
.tool.big .paper-no { font-size: 2.6vh; }
.tool.big .box-art { transform: translateX(-50%) scale(1.5); transform-origin: 50% 100%; }
.tool.big .kuji-left { font-size: 2.4vh; }
.tool.big .teams { grid-template-columns: repeat(auto-fill, minmax(min(100%, 26vh), 1fr)); font-size: 2.6vh; }
.tool.big .team-name { font-size: 3vh; }
body.big-open { overflow: hidden; }

@media (max-width: 480px) {
  .stage { padding: 8px; }
  .turnbar { margin-bottom: 6px; }
  .wheel-box { padding-top: 20px; }
  .kuji-stage { height: 270px; }
  .box-art { width: 190px; height: 132px; }
  .paper-text { font-size: 1.6rem; }
  .result b { font-size: 1.8rem; }
  .go-btn { min-width: 140px; }
  .teams { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .linkbtn { display: none; } /* 狭い画面では「使いかた」を省く（解説はすぐ下） */
}

/* くじ引きでは、当たりは紙に大きく出るので、下の行は読み上げ用にだけ残す */
.tool[data-mode="kuji"]:not(.big) .result { position: absolute; width: 1px; height: 1px; min-height: 0; margin: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.tool.big[data-mode="kuji"] .result { display: none; }
/* 上のバーの高さを一定に（No.93。数字は一番長い文が画面の幅（360px・375px 以上・641px 以上）で何行になるか。--tb-rt はふりがなの分。base.css・turnbar.js） */
.turnbar { --tb-msg-lines: 2; --tb-st-lines: 1; --tb-rt: 0px; --tb-st-rt: 0px; }
@media (min-width: 375px) { .turnbar { --tb-msg-lines: 2; --tb-st-lines: 1; } }
@media (min-width: 641px) { .turnbar { --tb-msg-lines: 1; --tb-st-lines: 1; } }
:root:lang(en) .turnbar { --tb-msg-lines: 2; --tb-st-lines: 2; --tb-rt: 0px; --tb-st-rt: 0px; }
@media (min-width: 375px) { :root:lang(en) .turnbar { --tb-msg-lines: 2; --tb-st-lines: 1; } }
@media (min-width: 641px) { :root:lang(en) .turnbar { --tb-msg-lines: 1; --tb-st-lines: 1; } }
/* 上のバーの高さ ここまで */
