/* あみだくじ固有の見た目（共通は ../common/base.css） */
.stage { position: relative; }
.linkbtn { display: inline-flex; align-items: center; text-decoration: none; }
.select { font: inherit; font-size: 17px; min-height: var(--tap); min-width: 8em; padding: 0 10px; border: 2px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.select:focus-visible { outline: 3px solid var(--warn); outline-offset: 2px; }

/* ---------- 入力のバー ---------- */
.am-edit { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; }
.am-edit-label { flex: none; font-weight: 700; font-size: 15px; min-width: 5.5em; line-height: 1.3; }
.am-edit-label small { display: block; font-weight: 400; color: var(--ink-sub); font-size: 14px; }
.am-input { flex: 1 1 auto; min-width: 0; font: inherit; font-size: 18px; min-height: var(--tap); padding: 0 10px; border: 2px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.am-input:focus { outline: 3px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.am-step { width: var(--tap); padding: 0; justify-content: center; display: inline-flex; align-items: center; flex: none; }

/* ---------- あみだくじ ---------- */
.amida { --n: 5; position: relative; user-select: none; -webkit-user-select: none; }
.am-row { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); }
.am-mid { height: clamp(220px, 42vh, 440px); position: relative; }
.am-mid svg { display: block; width: 100% !important; height: 100% !important; touch-action: manipulation; }
.am-mid.addable svg { cursor: crosshair; }
.am-cell {
  appearance: none; font: inherit; color: var(--ink); background: var(--surface); margin: 0 2px; padding: 4px 2px;
  border: 2px solid var(--line-strong); border-radius: var(--radius); min-height: var(--tap);
  display: flex; align-items: center; justify-content: center; text-align: center; line-height: 1.25;
  font-size: 16px; font-weight: 700; overflow: hidden; word-break: break-all; position: relative;
}
.am-cell .tx { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden;
}
button.am-cell { cursor: pointer; }
button.am-cell:disabled { cursor: default; }
.am-cell:focus-visible { outline: 3px solid var(--warn); outline-offset: 1px; z-index: 1; }
.am-cell .ph { color: var(--ink-sub); font-weight: 400; }
.am-cell.editing { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent); }
.am-top .am-cell { margin-bottom: 4px; }
.am-bot .am-cell { margin-top: 4px; }
/* 人数が多いと縦書き */
.amida.vert .am-cell { writing-mode: vertical-rl; text-orientation: upright; font-size: 15px; min-height: 5.6em; max-height: 7.2em; padding: 4px 0; margin: 0 1px; border-width: 1.5px; letter-spacing: 0; }
.amida.vert.tight .am-cell { font-size: 14px; margin: 0; border-radius: 3px; }
/* たどった人・たどり着いた結果 */
.am-cell .no { position: absolute; left: 3px; top: 2px; font-size: 14px; line-height: 1; color: var(--ink-sub); font-weight: 700; writing-mode: horizontal-tb; }
.amida.vert .am-cell .no { display: none; }
.am-cell.done { border-color: var(--pc); box-shadow: inset 0 -5px 0 var(--pc); }
.am-cell.hidden-res { background: repeating-linear-gradient(45deg, var(--bg) 0 6px, var(--surface) 6px 12px); color: var(--ink-sub); }
.am-cell.hidden-res .q { font-size: 20px; font-weight: 800; }
.am-cell.got { border-color: var(--pc); box-shadow: inset 0 0 0 2px var(--pc); animation: am-pop .3s ease-out; }
.am-cell.star { color: var(--ng); }
.am-cell.pick { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent); }
.am-cell.right { border-color: var(--ok); box-shadow: 0 0 0 3px var(--ok); }
.am-cell.wrong { border-color: var(--ng); }
@keyframes am-pop { 0% { transform: scale(.85); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .am-cell.got { animation: none; } }

.am-v { stroke: var(--ink); stroke-linecap: round; }
.am-h { stroke: var(--ink); stroke-linecap: round; }
.am-h.user { stroke: var(--accent); stroke-dasharray: none; }
.am-cover-bg { fill: var(--bg); }
.am-cover-line { stroke: var(--line); stroke-width: 5; }
.am-cover { stroke: var(--line); stroke-width: 1.5; }
.am-cover-box { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.5; }
.am-cover-text { fill: var(--ink); font-family: var(--font); }
.am-cover-g { transition: opacity .5s; }
.am-cover-g.gone { opacity: 0; }
.am-fadein { animation: am-fade .6s ease-out; }
@keyframes am-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .am-fadein { animation: none; } .am-cover-g { transition: none; } }
.am-head { filter: drop-shadow(0 1.5px 1px rgba(0,0,0,.28)); }

/* ---------- ボタン・まとめて入力・結果 ---------- */
.am-btns { margin-top: 10px; }
.am-btns .btn:not(.icon) { min-height: 52px; font-size: 18px; }
.am-bulk { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-top: 10px; background: var(--surface); }
.am-bulk-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.am-bulk label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 15px; }
.am-bulk textarea { font: inherit; font-size: 16px; font-weight: 400; padding: 6px 8px; border: 2px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); resize: vertical; min-height: 9em; }
.am-result { border: 2px solid var(--accent); border-radius: var(--radius); padding: 12px 16px; margin-top: 12px; background: var(--surface); }
.am-result-title { margin: 0 0 8px; font-size: 1.15rem; }
.am-result-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 4px 16px; }
.am-result-list li { display: flex; align-items: center; gap: 8px; font-size: 16px; padding: 2px 0; min-width: 0; }
.am-result-list .dot { width: 24px; height: 24px; border-radius: 50%; flex: none; color: #FFFFFF; font-size: 14px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.am-result-list .nm { font-weight: 700; overflow-wrap: anywhere; }
.am-result-list .arrow { color: var(--ink-sub); flex: none; }
.am-result-list .rs { overflow-wrap: anywhere; }
.am-result-list .rs.win { color: var(--ng); font-weight: 800; }
.am-score { font-size: 1.6rem; font-weight: 800; margin: 0 0 8px; }

.common-btns { margin-top: 8px; }
.callout { z-index: 20; top: 12%; }
.result-box { z-index: 25; top: 10%; }

@media (max-width: 480px) {
  .stage { padding: 8px; }
  .am-mid { height: clamp(200px, 36vh, 340px); }
  .am-cell { font-size: 15px; margin: 0 1px; }
  .am-bulk-cols { grid-template-columns: 1fr; }
  .am-btns .btn:not(.icon) { flex: 1 1 auto; }
  .result-box { inset: 6% 3% auto; padding: 16px; }
}
.amida.vert .am-cell .tx { display: block; -webkit-line-clamp: unset; max-height: 100%; }
.amida.tight .am-cell.hidden-res .q { font-size: 14px; }

/* 英語のページ: 人数が多いときの縦書きは、英字を横に寝かせる（1文字ずつ立てると読みにくい） */
:root:lang(en) .amida.vert .am-cell { text-orientation: mixed; }
:root:lang(en) .amida.vert .am-cell.hidden-res { text-orientation: upright; } /* 「?」は立てたまま */
:root:lang(en) .am-cell, :root:lang(en) .am-cell .tx { word-break: normal; overflow-wrap: anywhere; } /* 英語は語の途中で折らない（収まらない長い語だけ折る） */

/* iPhone の「連絡先を自動入力」を出さないため入力欄は type=search（要望No.87）。検索欄の見た目は消す */
input[type=search]{-webkit-appearance:none;appearance:none}
input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{display:none;-webkit-appearance: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: 1; --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; } }
/* 上のバーの高さ ここまで */
