/* ぬるまゆオリジナルビンゴ 共通スタイル
   色はここで定義する。列（B I N G O）ごとにボールの色を変える */
:root {
  --background: #fff3e0;
  --background-dot: #f6dfbd;
  --surface: #ffffff;
  --text: #4a3426;
  --muted: #7a6656;
  --accent: #e2622a;          /* ♨ のオレンジ */
  --accent-strong: #b5461a;
  --accent-soft: #ffe3c8;
  --border: #edcfae;
  --gold: #f2b632;
  --gold-soft: #fff1c9;
  --success: #2f7d4f;
  --danger: #b23a2c;
  --overlay: rgb(60 34 16 / 60%);
  --shadow: 0 10px 30px rgb(140 80 30 / 14%);
  --radius: 22px;
  --lB: #e0583a;  --lI: #c98510;  --lN: #3a9558;  --lG: #3a7cc2;  --lO: #9558b5;
  --font-body: "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
  --font-display: "M PLUS Rounded 1c", "Yu Gothic", "Meiryo", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--text); font-family: var(--font-body); line-height: 1.6;
  background-color: var(--background);
  background-image: radial-gradient(var(--background-dot) 1.4px, transparent 1.6px);
  background-size: 22px 22px;
}
button, input { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .5; cursor: default; }
button, a, input { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
h1, h2, p { margin: 0; }
h1, h2, .latest-number, .host-number, .ball { font-family: var(--font-display); font-weight: 800; }
a { color: var(--accent-strong); overflow-wrap: anywhere; }
input[type="text"], input[type="password"] { width: 100%; border: 2px solid var(--border); border-radius: 14px; background: var(--surface); padding: 12px 14px; font-size: 16px; color: var(--text); }
label { display: block; font-weight: 700; }
table { border-collapse: separate; border-spacing: 6px; width: 100%; table-layout: fixed; }
th { font-weight: 800; }

/* ボタン */
.primary-button, .secondary-button { min-height: 50px; padding: 12px 24px; border-radius: 999px; font-weight: 800; border: 0; font-family: var(--font-display); }
.primary-button { background: var(--accent); color: #fff; box-shadow: 0 5px 0 var(--accent-strong); }
.primary-button:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 var(--accent-strong); }
.secondary-button { background: var(--surface); color: var(--accent-strong); border: 2px solid var(--accent); }
.text-button { border: 0; padding: 6px 8px; min-height: 36px; background: transparent; color: var(--accent-strong); text-decoration: underline; }
.small { font-size: .8rem; }
.muted { color: var(--muted); }
.notice { color: var(--danger); font-size: .9rem; overflow-wrap: anywhere; }
.connection-status { min-height: 1.2em; color: var(--muted); font-size: .8rem; }
.connection-status:empty { min-height: 0; }
.eyebrow { color: var(--muted); font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.h1-small { display: block; font-size: .55em; color: var(--accent); letter-spacing: .12em; }

/* ボール（列ごとの色） */
.ball {
  --c: var(--accent);
  display: inline-grid; place-items: center; align-content: center;
  width: var(--size, 124px); height: var(--size, 124px); border-radius: 50%;
  color: #fff; line-height: 1;
  background: radial-gradient(circle at 22% 20%, rgb(255 255 255 / 45%) 0 8%, transparent 9%), var(--c);
  box-shadow: inset 0 -8px 0 rgb(0 0 0 / 14%), 0 8px 18px rgb(80 40 10 / 22%);
  font-variant-numeric: tabular-nums;
}
.ball-l { font-size: calc(var(--size, 124px) * .2); opacity: .92; }
.ball-n { font-size: calc(var(--size, 124px) * .46); margin-top: .04em; }
[data-l="B"] { --c: var(--lB); } [data-l="I"] { --c: var(--lI); } [data-l="N"] { --c: var(--lN); }
[data-l="G"] { --c: var(--lG); } [data-l="O"] { --c: var(--lO); }

/* ===== 参加者画面 ===== */
.player-shell { width: min(100%, 520px); margin: auto; padding: 12px 14px max(28px, env(safe-area-inset-bottom)); }
.player-header { text-align: center; }
.hero-image { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius); box-shadow: var(--shadow); background: var(--surface); }
.player-header h1 { font-size: clamp(1.5rem, 7vw, 2rem); line-height: 1.2; margin-top: 12px; }
.identity { font-size: .9rem; overflow-wrap: anywhere; margin-top: 4px; }
.identity #playerName:not(:empty)::after { content: " さん"; }
.identity .text-button { font-size: .75rem; }
.latest-panel { text-align: center; padding: 12px 6px 14px; margin: 12px 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.latest-number { --size: clamp(110px, 34vw, 140px); display: grid; place-items: center; min-height: var(--size); margin-top: 6px; color: var(--accent); }
.latest-number.waiting { font-size: 1.3rem; min-height: 0; padding: 18px 0 8px; }
.latest-number .ball { animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { 0% { transform: scale(.3) rotate(-30deg); } 100% { transform: scale(1) rotate(0); } }

.card-panel { padding: 14px 8px 16px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); text-align: center; border: 3px solid var(--accent-soft); }
.bingo-card { border-spacing: 5px; }
.bingo-card th { padding-bottom: 2px; }
.bingo-card thead th { color: #fff; font-family: var(--font-display); font-size: clamp(1.2rem, 6vw, 1.6rem); line-height: 1; }
.bingo-card thead th { background: var(--c); border-radius: 12px; padding: 8px 0; }
.bingo-card thead th:nth-child(1) { --c: var(--lB); } .bingo-card thead th:nth-child(2) { --c: var(--lI); }
.bingo-card thead th:nth-child(3) { --c: var(--lN); } .bingo-card thead th:nth-child(4) { --c: var(--lG); }
.bingo-card thead th:nth-child(5) { --c: var(--lO); }
.bingo-card td {
  position: relative; height: clamp(54px, 15vw, 78px); background: #fffaf3; border: 2px solid var(--border);
  border-radius: 14px; font-size: clamp(1.35rem, 6.4vw, 2rem); font-weight: 800; font-family: var(--font-display);
  font-variant-numeric: tabular-nums; color: var(--text);
}
.bingo-card td:nth-child(1) { --c: var(--lB); } .bingo-card td:nth-child(2) { --c: var(--lI); }
.bingo-card td:nth-child(3) { --c: var(--lN); } .bingo-card td:nth-child(4) { --c: var(--lG); }
.bingo-card td:nth-child(5) { --c: var(--lO); }
/* 出た番号はスタンプを押したように */
.bingo-card td.marked:not(.free) { color: #fff; border-color: transparent; background: #fffaf3; z-index: 0; }
.bingo-card td.marked:not(.free)::before {
  content: ""; position: absolute; inset: 3px; border-radius: 50%; z-index: -1;
  background: var(--c); transform: rotate(-8deg);
  box-shadow: inset 0 0 0 3px rgb(255 255 255 / 35%);
}
.bingo-card td.last { outline: 4px solid var(--gold); outline-offset: 1px; }
.bingo-card td.completed { background: var(--gold-soft); border-color: var(--gold); }
.bingo-card td.free { background: #fff; border-color: var(--accent); }
.free-label {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: flex-end;
  width: 100%; height: 100%; font-size: .55rem; letter-spacing: .08em; color: var(--accent-strong); font-family: var(--font-body);
  background: url("/img/nurumayu.png") center 30% / clamp(28px, 8vw, 40px) no-repeat; padding-bottom: 2px;
}
.bingo-card td.hit::before { animation: stamp .6s ease-out; }
@keyframes stamp { 0% { transform: scale(1.8) rotate(-25deg); opacity: 0; } 60% { transform: scale(.9) rotate(-6deg); opacity: 1; } 100% { transform: scale(1) rotate(-8deg); } }
.card-caption { margin-top: 10px; font-size: .75rem; color: var(--muted); }
.card-caption a { font-weight: 800; letter-spacing: .08em; }
.reach-status { min-height: 0; margin-top: 10px; }
.reach-status:not(:empty) {
  display: inline-block; padding: 6px 22px; border-radius: 999px; background: var(--gold); color: #5a3a00;
  font-family: var(--font-display); font-size: 1.25rem; font-weight: 800; animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.06); } }
.claim-summary { color: var(--success); font-weight: 800; margin: 8px 0; }
.claim-summary:empty { margin: 0; }
#openWin { margin-top: 10px; width: 100%; font-size: 1.2rem; }
.history-panel { padding: 22px 4px; }
.history-panel h2 { font-size: 1.05rem; }
.number-history { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 12px 0; }
.number-history li {
  padding: 2px 10px; border-radius: 999px; font-size: .82rem; font-weight: 700;
  color: #fff; background: var(--c, var(--muted)); font-family: var(--font-display);
}
.number-history li:first-child { font-size: 1rem; padding: 3px 14px; box-shadow: 0 0 0 3px var(--gold); }

/* リーチの強調 */
.reach-banner {
  position: sticky; top: 0; z-index: 10; margin: -12px -14px 10px; padding: 10px 14px calc(10px + 2px);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 12px;
  background: linear-gradient(180deg, #e8402c, #c92f1f); color: #fff; text-align: center;
  font-family: var(--font-display); font-weight: 800; box-shadow: 0 6px 16px rgb(150 30 10 / 30%);
  border-radius: 0 0 18px 18px;
}
.reach-banner-label { font-size: 1.5rem; animation: pulse 1s ease-in-out infinite; }
.reach-banner-needs { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; font-size: 1.05rem; }
.reach-banner.is-bingo { background: linear-gradient(180deg, var(--gold), #e09a12); color: #4a2c00; font-size: 1.2rem; }
.ball-sm { --size: 46px; box-shadow: 0 0 0 3px #fff; }
.ball-sm .ball-l { font-size: 10px; }
.ball-sm .ball-n { font-size: 20px; }
.card-wrap { position: relative; }
.reach-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.reach-stroke { stroke: #e23b2a; stroke-width: 10; stroke-linecap: round; opacity: .5; }
.bingo-card td.reach-line:not(.marked) { border-color: #e23b2a; }
.bingo-card td.reach-target {
  border: 4px solid #e23b2a; background: #fff0ec; color: #c92f1f; z-index: 1;
  animation: target 1s ease-in-out infinite;
}
.bingo-card td.reach-target::after {
  content: "あと1つ"; position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  background: #e23b2a; color: #fff; font-family: var(--font-body); font-size: .58rem; font-weight: 700;
  line-height: 1; padding: 3px 6px; border-radius: 999px; white-space: nowrap;
}
@keyframes target { 50% { box-shadow: 0 0 0 5px rgb(226 59 42 / 28%); } }

/* ダイアログ */
dialog { color: var(--text); background: var(--surface); border: 0; border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); }
dialog::backdrop { background: var(--overlay); }
.name-dialog { width: min(440px, calc(100% - 28px)); }
.name-dialog form { display: grid; gap: 14px; }
.name-dialog h2 { font-size: 1.5rem; color: var(--accent); }
.name-dialog h2::before { content: ""; display: block; width: 64px; height: 64px; margin: 0 auto 8px; background: url("/img/nurumayu.png") center / contain no-repeat; }
.name-dialog h2, .name-dialog form > p:first-of-type { text-align: center; }
.win-dialog {
  width: 100%; height: 100%; height: 100dvh; max-width: none; max-height: none; margin: 0; border-radius: 0; overflow: auto;
  background: radial-gradient(circle at 50% 35%, #fff6d8 0, #ffe3b0 45%, #ffc98a 100%);
}
.win-content { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; min-height: 100%; text-align: center; padding: 16px 0; }
.win-image { width: min(78vw, 380px); height: auto; border-radius: 50%; box-shadow: 0 0 0 8px #fff, var(--shadow); }
.win-content h2 {
  font-size: clamp(3.4rem, 16vw, 5.4rem); line-height: 1; color: var(--accent);
  text-shadow: 3px 3px 0 #fff, 6px 6px 0 rgb(181 70 26 / 25%); animation: pop .6s cubic-bezier(.2, 1.6, .4, 1);
}
#winDescription { font-weight: 700; }
#claimButton { font-size: 1.25rem; min-width: 240px; }
.claim-result { max-width: 480px; font-size: 1.25rem; font-weight: 800; white-space: pre-line; color: var(--accent-strong); }

/* ===== 主催者画面（プロジェクター 1920×1080） ===== */
.host-shell { max-width: 1920px; min-height: 100vh; padding: 18px 36px 12px; margin: auto; }
.host-header, .host-header-actions { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.host-header h1 { display: flex; align-items: center; gap: 14px; font-size: clamp(1.6rem, 2.4vw, 2.8rem); line-height: 1.1; }
.host-header .h1-small { display: inline; font-size: .7em; margin-right: .3em; letter-spacing: .05em; }
.title-icon { width: 1.4em; height: 1.4em; border-radius: 50%; }
.host-game { display: grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); gap: 36px; align-items: center; margin-top: 10px; }
.host-draw { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.host-draw .eyebrow { font-size: clamp(1.4rem, 1.9vw, 2.2rem); line-height: 1.2; color: var(--accent-strong); font-family: var(--font-display); }
.host-number { --size: min(36vh, 30vw); display: grid; place-items: center; min-height: var(--size); color: var(--accent); }
.host-number .ball { animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
.host-number.rolling .ball { animation: none; filter: saturate(.6); }
.host-number.waiting { font-size: clamp(3rem, 5vw, 5.6rem); line-height: 1.2; min-height: 0; padding: 20px 0 6px; }
.draw-button { font-size: clamp(1.4rem, 1.8vw, 2rem); padding: 16px 56px; }
.draw-options { display: flex; align-items: center; justify-content: center; gap: 20px; }
.draw-options label { font-size: .9rem; font-weight: 400; }
.host-hero { width: min(100%, 520px); height: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
/* 抽選が始まったらイラストは小さく */
.host-number:not(.waiting) ~ .host-hero { width: min(70%, 300px); }
.host-board-panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 12px; }
.host-board { border-spacing: 6px 3px; }
.host-board th { color: #fff; font-family: var(--font-display); font-size: clamp(1.4rem, 2vw, 2.2rem); line-height: 1.2; background: var(--c); border-radius: 12px; }
.host-board th:nth-child(1), .host-board td:nth-child(1) { --c: var(--lB); }
.host-board th:nth-child(2), .host-board td:nth-child(2) { --c: var(--lI); }
.host-board th:nth-child(3), .host-board td:nth-child(3) { --c: var(--lN); }
.host-board th:nth-child(4), .host-board td:nth-child(4) { --c: var(--lG); }
.host-board th:nth-child(5), .host-board td:nth-child(5) { --c: var(--lO); }
.host-board td {
  text-align: center; border-radius: 999px; background: #fbf3e8; color: #c9b8a6; font-weight: 800;
  font-family: var(--font-display); font-size: clamp(1rem, 1.55vw, 1.85rem); line-height: 1.12; padding: 1px; font-variant-numeric: tabular-nums;
}
.host-board td.marked { background: var(--c); color: #fff; }
.host-board td.last { box-shadow: 0 0 0 4px var(--gold); animation: pulse 1.2s ease-in-out infinite; }
.host-stats { display: flex; justify-content: center; flex-wrap: wrap; align-items: center; gap: 10px 56px; padding: 8px 16px; margin: 14px 0 10px; background: var(--surface); border-radius: 999px; box-shadow: var(--shadow); font-size: 1.25rem; font-weight: 700; }
.host-stats strong { font-family: var(--font-display); font-size: 2rem; color: var(--accent-strong); margin: 0 .15em; }
#hostGameLabel { font-size: .9rem; color: var(--muted); font-weight: 400; }
.claims-panel { background: var(--surface); border-radius: 18px; padding: 8px 16px; }
.claims-panel h2 { font-size: 1.2rem; color: var(--accent-strong); }
.claims-scroll { max-height: 150px; overflow: auto; }
.claims-table { border-collapse: collapse; font-size: 1.05rem; }
.claims-table th, .claims-table td { padding: 4px 12px; text-align: left; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.claims-table th { position: sticky; top: 0; background: var(--surface); color: var(--muted); font-size: .85rem; }
.claims-table th:nth-child(2) { width: 40%; }
.claims-table tr.new-claim { background: var(--gold-soft); font-weight: 800; }
.new-claim-notice { color: var(--accent); margin-left: 20px; }
.bgm-control { display: flex; align-items: center; gap: 10px; }
.bgm-control input[type="range"] { width: 120px; accent-color: var(--accent); }
.host-footer { display: flex; gap: 24px; justify-content: flex-end; margin-top: 8px; font-size: .8rem; }
.host-footer .text-button { color: var(--muted); }
.auth-panel { background: var(--accent-soft); padding: 18px; border-radius: 16px; margin-top: 12px; }
.auth-panel form { display: flex; gap: 16px; align-items: center; }
.auth-panel input { max-width: 380px; }
/* 参加用QRコード（開始前に映す画面） */
.qr-panel { display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: center; padding: 24px 0; }
.qr-hero { width: 100%; height: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
.qr-side { text-align: center; display: grid; justify-items: center; gap: 10px; }
.qr-panel h2 { font-size: clamp(1.8rem, 2.6vw, 3rem); color: var(--accent); }
.qr-code { display: inline-block; background: var(--surface); padding: 24px; border-radius: 24px; box-shadow: var(--shadow); }
.qr-code img, .qr-code canvas { display: block; width: min(34vh, 380px) !important; height: auto !important; image-rendering: pixelated; }
.qr-panel a { font-size: clamp(1.1rem, 1.6vw, 1.7rem); font-weight: 700; }
.qr-panel p { font-size: 1.2rem; }
@media (max-width: 900px) {
  .host-shell { padding: 14px; }
  .host-header { align-items: flex-start; flex-direction: column; }
  .host-header-actions { gap: 8px; }
  .host-game { grid-template-columns: 1fr; gap: 14px; }
  .host-number { --size: 180px; }
  .host-board td { font-size: 1.1rem; }
  .host-stats { gap: 12px 24px; font-size: 1rem; border-radius: 18px; }
  .claims-table { font-size: .8rem; }
  .claims-table th, .claims-table td { padding: 6px 3px; }
  .auth-panel form { flex-wrap: wrap; }
  .qr-panel { grid-template-columns: 1fr; }
  .qr-code img, .qr-code canvas { width: min(70vw, 300px) !important; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
