/* 表示画面。寸法は枠（コンテナ）基準の cqw / cqh で指定し、全画面でも埋め込みでも同じ比率で見えるようにする */
.display {
  --bg: #111316;
  --surface: #1b1e23;
  --surface-2: #252930;
  --line: #333841;
  --text: #eef0f3;
  --muted: #9aa1ab;
  --accent: #f5c542;
  --danger: #ef5b5b;
  --radius: 14px;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, "Menlo", monospace;
  color-scheme: dark;
  container-type: size;
  position: relative;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
.display *, .display *::before, .display *::after { box-sizing: border-box; }
.display button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
.display .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.display .offline-banner {
  display: none; position: absolute; top: 0; left: 0; right: 0; z-index: 40;
  background: var(--danger); color: #fff; text-align: center; padding: 6px; font-size: 14px;
}
.display.offline .offline-banner { display: block; }

.display header {
  display: flex; align-items: center; gap: 2cqw;
  padding: 1.6cqh 2.4cqw; font-size: clamp(11px, 2.2cqh, 28px); color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.display header .round { color: var(--text); font-weight: 700; }
.display header .spacer { flex: 1; }
.display header .badge { padding: .2em .7em; border-radius: 999px; background: var(--surface-2); }
.display header .badge:empty { display: none; }
.display header .badge.hot { background: var(--accent); color: #15171a; }
.display .icon-btn {
  background: none; border: 1px solid var(--line); border-radius: 8px;
  padding: .25em .55em; color: var(--muted); font-size: inherit; line-height: 1.2;
}
.display .icon-btn:focus-visible, .display button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.display main { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* 手番表示 */
.display .hero {
  flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2cqh; background: var(--hero-bg, var(--surface)); color: var(--hero-ink, var(--text));
  transition: background-color .35s ease; position: relative; text-align: center; padding: 2cqh 3cqw;
}
.display .hero .label { font-size: clamp(12px, 4cqh, 48px); opacity: .75; letter-spacing: .08em; }
.display .hero .name {
  font-weight: 800; line-height: 1.05; letter-spacing: .02em;
  font-size: clamp(28px, min(16cqw, 24cqh), 320px);
  word-break: keep-all; overflow-wrap: anywhere;
}
.display .hero .name small { font-size: .32em; font-weight: 700; margin-left: .15em; }
.display .hero .clock { font-size: clamp(24px, 15cqh, 220px); font-weight: 700; line-height: 1; }
.display .hero .clock.warn { color: var(--hero-warn, #7a3d00); }
.display .hero .clock.over { animation: bgt-blink 1s steps(2) infinite; }
.display .hero .sub { font-size: clamp(11px, 2.6cqh, 32px); opacity: .7; }
@keyframes bgt-blink { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .display .hero .clock.over { animation: none; text-decoration: underline; } }

.display .paused-mask {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(10, 11, 13, .72); color: #fff; font-size: clamp(20px, 10cqh, 140px); font-weight: 800; letter-spacing: .2em;
}
.display.paused .paused-mask { display: flex; }

/* 手番順の帯 */
.display .strip {
  display: flex; gap: 1cqw; padding: 1.6cqh 2.4cqw 2.2cqh; overflow: hidden;
  background: var(--bg); border-top: 1px solid var(--line);
}
.display .chip {
  flex: 1 1 0; min-width: 0; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto;
  column-gap: .8cqw; align-items: center; padding: 1.2cqh 1cqw; border-radius: var(--radius);
  background: var(--surface); border: 3px solid transparent; font-size: clamp(10px, 2.6cqh, 34px);
}
.display .chip .seat {
  grid-row: span 2; width: 2em; height: 2em; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; background: var(--c); color: var(--on-c);
}
.display .chip .nm { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.display .chip .meta { color: var(--muted); font-size: .72em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.display .chip.now { border-color: var(--c); background: var(--surface-2); }
.display .chip.passed { opacity: .38; }
.display .chip.passed .nm { text-decoration: line-through; }

/* 選択画面（手番順決め・次の人の指名） */
.display .picker { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4cqh; padding: 3cqh 3cqw; }
.display .picker h1 { margin: 0; font-size: clamp(18px, 7cqh, 96px); text-wrap: balance; text-align: center; }
.display .picker p { margin: 0; color: var(--muted); font-size: clamp(11px, 2.6cqh, 32px); text-align: center; }
.display .cards { display: flex; gap: 2cqw; flex-wrap: wrap; justify-content: center; width: 100%; }
.display .card {
  flex: 0 1 18cqw; aspect-ratio: 3 / 4; max-height: 46cqh; border-radius: 2cqh; border: 3px solid var(--c);
  background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2cqh;
  font-size: clamp(12px, 4cqh, 52px); font-weight: 800; position: relative; padding: 1cqh;
}
.display .card.on { background: var(--c); color: var(--ink); }
.display .card .key { font-size: .6em; color: var(--muted); font-family: var(--mono); }
.display .card.on .key { color: inherit; opacity: .6; }
.display .card .rank { position: absolute; top: .4em; right: .6em; font-size: 1.4em; }

/* 待機・結果 */
.display .lobby { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3.5cqh; text-align: center; padding: 3cqh 4cqw; }
.display .lobby h1 { margin: 0; font-size: clamp(22px, 9cqh, 120px); letter-spacing: .06em; }
.display .lobby .cards .card { aspect-ratio: auto; padding: 2cqh 1cqw; }
.display .lobby .hint { color: var(--muted); font-size: clamp(11px, 3cqh, 36px); line-height: 1.6; }
.display .lobby .url { color: var(--accent); font-family: var(--mono); overflow-wrap: anywhere; }
.display .lobby .join { display: flex; align-items: center; gap: 3cqw; }
.display .lobby .qr { background: #fff; padding: 1cqh; border-radius: 1cqh; line-height: 0; }
.display .lobby .qr img, .display .lobby .qr canvas { width: 18cqh; height: 18cqh; }
.display .keys { color: #6b717b; font-size: clamp(10px, 1.8cqh, 20px); }
.display table.result { border-collapse: collapse; font-size: clamp(11px, 3.2cqh, 40px); }
.display table.result th, .display table.result td { padding: .5em 1.2em; border-bottom: 1px solid var(--line); text-align: right; }
.display table.result th:first-child, .display table.result td:first-child { text-align: left; }
.display table.result thead th { color: var(--muted); font-weight: 500; font-size: .7em; }
.display .dot { display: inline-block; width: .7em; height: .7em; border-radius: 50%; margin-right: .5em; vertical-align: middle; }

/* 開始オーバーレイ（音声の自動再生制限を解除するため1回クリックが要る） */
.display .gate {
  position: absolute; inset: 0; background: rgba(8, 9, 11, .92); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3cqh; z-index: 50; text-align: center; padding: 24px;
}
.display .gate button {
  font-size: clamp(16px, 4cqh, 44px); font-weight: 800; padding: .8em 2em; border-radius: 999px;
  border: 0; background: var(--accent); color: #15171a;
}
.display .gate p { color: var(--muted); margin: 0; font-size: clamp(11px, 2.2cqh, 24px); }

.display dialog {
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 16px;
  padding: 24px; width: min(480px, calc(100vw - 32px)); font-family: var(--font);
}
.display dialog::backdrop { background: rgba(0, 0, 0, .6); }
.display dialog h2 { margin: 0 0 16px; font-size: 20px; }
.display dialog label { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 14px 0; font-size: 15px; }
.display dialog select, .display dialog input[type=range] { flex: 1; max-width: 60%; }
.display dialog select { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.display dialog .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.display dialog .row button { padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); }

/* ===== kkds（甲南キッチン デザインシステム）準拠の上書き =====
   色は brand.py の6色のみ。黄の面に白文字を置かない（帯のロゴだけ例外）。
   帯の高さは kkds の BAND_H 120px を 1080 の画面に当てた 11.1cqh、ロゴ高さは帯の 40%（LOGO_H 48/120）。 */
.display {
  --accent: #E3C831; --ink: #1A1A1A; --ink2: #4D4D4D; --ink3: #808080; --line: #E0E0E0; --paper: #FFFFFF;
  --bg: var(--paper); --surface: var(--paper); --surface-2: var(--paper); --text: var(--ink); --muted: var(--ink2);
  --font: "BIZ UDPGothic", "Hiragino Sans", system-ui, sans-serif;
  --display-font: "LINE Seed JP", "BIZ UDPGothic", "Hiragino Sans", sans-serif;
  --mono: "BIZ UDPGothic", "Hiragino Sans", sans-serif;
  color-scheme: light;
  line-break: strict;
}
.display .num { font-variant-numeric: tabular-nums; }
.display header {
  height: 11.1cqh; padding: 0 3.3cqw; background: var(--accent); color: var(--ink); border-bottom: 0;
  font-size: clamp(11px, 2.4cqh, 28px); gap: 2.2cqw;
}
.display header .logo { height: 4.44cqh; width: auto; display: block; }
.display header .round { color: var(--ink); font-weight: 700; }
.display header [data-id="h-phase"] { color: var(--ink); }
.display header .badge { background: var(--paper); color: var(--ink); }
.display header .badge.hot { background: var(--ink); color: var(--paper); }
.display .icon-btn { border-color: var(--ink); color: var(--ink); }

/* 手番：白地に黒の名前。プレイヤー色は左の太いバーだけ（識別のための情報） */
.display .hero {
  background: var(--paper); color: var(--ink); align-items: flex-start; text-align: left;
  padding: 4.4cqh 5cqw 4.4cqh calc(5cqw + 2.2cqw); gap: 1.5cqh;
}
.display .hero::before { content: ""; position: absolute; left: 3.3cqw; top: 4.4cqh; bottom: 4.4cqh; width: 1.2cqw; background: var(--hero-bg); border-radius: 0.4cqw; }
.display .hero .label { font-size: clamp(12px, 3cqh, 40px); color: var(--ink2); opacity: 1; letter-spacing: .04em; }
.display .hero .name { font-family: var(--display-font); font-weight: 800; letter-spacing: -.01em; word-break: keep-all; }
.display .hero .name small { font-family: var(--font); font-weight: 700; color: var(--ink2); }
.display .hero .clock { font-family: var(--display-font); font-weight: 800; color: var(--ink); }
.display .hero .clock.warn { color: var(--ink); background: var(--accent); padding: 0 .2em; border-radius: .08em; }
.display .hero .clock.over { color: var(--ink); }
.display .hero .sub { color: var(--ink2); opacity: 1; font-size: clamp(11px, 3cqh, 36px); }
.display .paused-mask { background: rgba(26, 26, 26, .82); color: var(--paper); }

.display .strip { background: var(--paper); border-top: 2px solid var(--line); padding: 2.2cqh 3.3cqw 3cqh; gap: 1.25cqw; }
.display .chip { background: var(--paper); border: 2px solid var(--line); border-radius: 8px; }
.display .chip.now { border-color: var(--ink); background: var(--paper); box-shadow: inset 0 -0.6cqh 0 var(--accent); }
.display .chip .meta { color: var(--ink3); }

.display .picker h1, .display .lobby h1 { font-family: var(--display-font); font-weight: 800; color: var(--ink); word-break: keep-all; }
.display .picker p, .display .lobby .hint { color: var(--ink2); }
.display .card { background: var(--paper); border: 2px solid var(--line); border-left: 1.2cqw solid var(--c); border-radius: 8px; color: var(--ink); }
.display .card.on { background: var(--paper); color: var(--ink); border-color: var(--ink); border-left-color: var(--c); box-shadow: inset 0 -0.8cqh 0 var(--accent); }
.display .card .key, .display .card.on .key { color: var(--ink3); opacity: 1; }
.display .lobby .url { color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: .2em; }
.display .lobby .qr { border: 2px solid var(--line); }
.display .keys { color: var(--ink3); }
.display table.result th, .display table.result td { border-bottom-color: var(--line); }
.display .gate { background: rgba(255, 255, 255, .96); }
.display .gate button { background: var(--accent); color: var(--ink); font-family: var(--display-font); }
.display .gate p { color: var(--ink2); }
.display dialog { background: var(--paper); color: var(--ink); border-color: var(--line); }
.display dialog select, .display dialog .row button { background: var(--paper); color: var(--ink); border-color: var(--line); }

.display.tap-next main { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }

/* ===== プレイヤー色をはっきり使う（本人の指示で kkds の色数制限を外す。帯・ロゴ・書体は kkds のまま） ===== */
.display .hero { background: var(--hero-bg); color: var(--hero-ink); align-items: center; text-align: center; padding: 4.4cqh 5cqw; }
.display .hero::before { display: none; }
.display .hero .label, .display .hero .sub, .display .hero .name small { color: inherit; opacity: .78; }
.display .hero .name, .display .hero .clock { color: inherit; }
.display .hero .clock.warn { color: var(--paper); background: var(--ink); padding: 0 .25em; }
.display .hero .clock.over { color: inherit; }
.display .chip { background: color-mix(in srgb, var(--c) 22%, var(--paper)); border-color: color-mix(in srgb, var(--c) 60%, var(--paper)); }
.display .chip.now { background: var(--c); border-color: var(--ink); box-shadow: none; color: var(--on-c); }
.display .chip.now .meta { color: inherit; opacity: .8; }
.display .chip.now .seat { background: var(--paper); color: var(--ink); }
.display .chip.passed { background: var(--paper); border-color: var(--line); }
.display .card { background: color-mix(in srgb, var(--c) 22%, var(--paper)); border-color: color-mix(in srgb, var(--c) 60%, var(--paper)); border-left-color: var(--c); }
.display .card.on { background: var(--c); color: var(--on-c); border-color: var(--ink); box-shadow: none; }
.display .card.on .key { color: inherit; opacity: .7; }

/* 左端だけの濃い帯はやめ、枠は四辺そろえる */
.display .card { border-left-width: 2px; border-left-color: color-mix(in srgb, var(--c) 60%, var(--paper)); }
.display .card.on { border-left-color: var(--ink); }

/* 持ち時間を大きく：手番の人の時計と、帯の各自の残り */
.display .hero .clock { font-size: clamp(32px, 21cqh, 300px); }
.display .hero .name { font-size: clamp(28px, min(13cqw, 20cqh), 280px); }
.display .hero { gap: 1cqh; }
.display .strip { padding: 1.8cqh 3.3cqw 2.4cqh; }
.display .chip { padding: 1.4cqh 1.2cqw; font-size: clamp(11px, 2.8cqh, 36px); column-gap: 1cqw; }
.display .chip .meta { font-family: var(--display-font); font-weight: 800; font-size: 1.5em; color: var(--ink); line-height: 1.1; }
.display .chip.now .meta { color: inherit; opacity: 1; }
.display .chip.passed .meta { color: var(--ink3); font-family: var(--font); font-weight: 400; font-size: 1em; }

/* ===== 薄い色は使わない：色の面はすべて濃い色のべた塗り、文字は白 ===== */
.display .hero { color: #fff; }
.display .hero .clock.warn { background: #fff; color: var(--hero-bg); }
.display .chip, .display .card { background: var(--c); color: #fff; border: 4px solid var(--c); }
.display .chip .meta, .display .chip.now .meta { color: #fff; opacity: 1; }
.display .chip .seat { background: rgba(0, 0, 0, .28); color: #fff; }
.display .chip.now .seat { background: rgba(0, 0, 0, .28); color: #fff; }
.display .chip.now { border-color: var(--ink); outline: 4px solid var(--ink); outline-offset: 0; transform: translateY(-0.6cqh); }
.display .chip.passed { background: #4D4D4D; border-color: #4D4D4D; color: #fff; opacity: 1; }
.display .chip.passed .meta { color: #fff; }
.display .card .key, .display .card.on .key { color: #fff; opacity: .75; }
.display .card.on { background: var(--c); color: #fff; border-color: var(--ink); outline: 4px solid var(--ink); }
.display .lobby .cards .card { border-left-width: 4px; }

/* ===== 鮮やかな色に戻す：べた塗りのまま、文字は色に合わせて白か黒 ===== */
.display .hero { color: var(--hero-ink); }
.display .hero .clock.warn { background: var(--hero-ink); color: var(--hero-bg); }
.display .chip, .display .card, .display .card.on { color: var(--on-c); }
.display .chip .meta, .display .chip.now .meta, .display .card .key, .display .card.on .key { color: var(--on-c); }
.display .chip .seat, .display .chip.now .seat { background: rgba(0, 0, 0, .18); color: var(--on-c); }
.display .chip.passed, .display .chip.passed .meta { color: #fff; }
