/* アイスブレイク横丁 — 全ゲーム共通の土台と部品。
   色はゲーム側の :root で --ib-* を決める(ここは形だけ)。
   グラデーション・ぼかし・ガラス表現は使わない。太いフチ+押すとへこむボタン。
   下の黒い影は「押せるもの」だけに付ける(札や紙には付けない)。角の丸みは、紙は小さく・ボタンは大きく。
   文字はふだん細め(500)、見出し・ボタン・名前だけ太くする。 */
:root {
  --ib-font: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", sans-serif;
  --ib-line: 3px;
  --ib-r: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overscroll-behavior-y: none; }
/* ダブルタップで画面が拡大しないように(電卓やもぐらを速く押すと拡大していた)。iPhone の Safari は viewport の user-scalable=no を無視するので、こちらで止める。スクロールと2本指の拡大はそのまま(たっちょんと同じ) */
html, body { touch-action: manipulation; }
[hidden] { display: none !important; }
body {
  font-family: var(--ib-font);
  font-weight: 500;
  color: var(--ib-ink);
  /* PCではスマホ幅の画面の左右を、ゲームの背景色で埋める */
  background: var(--ib-bg);
  background-image: var(--ib-bg-image, none);
  background-size: var(--ib-bg-size, auto);
  display: flex;
  justify-content: center;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-user-select: none;
  user-select: none;
}
input { user-select: text; -webkit-user-select: text; font-family: inherit; }
button { font-family: inherit; color: inherit; cursor: pointer; }

#app { width: 100%; max-width: 448px; min-height: 100dvh; position: relative; overflow: hidden; }

.screen {
  display: none;
  position: absolute;
  inset: 0;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex-direction: column;
}
.screen.active { display: flex; animation: ib-fade .25s ease; }
@keyframes ib-fade { from { opacity: 0; } to { opacity: 1; } }

/* ===== Buttons ===== */
.ib-btn {
  display: block; width: 100%;
  min-height: 54px; padding: 10px 16px;
  border: var(--ib-line) solid var(--ib-ink);
  border-radius: var(--ib-btn-r, var(--ib-r));
  font-size: 17px; font-weight: 900; letter-spacing: .04em;
  box-shadow: 0 5px 0 var(--ib-ink);
  transition: transform .06s, box-shadow .06s;
}
.ib-btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--ib-ink); }
.ib-btn:disabled { opacity: .45; cursor: default; }
.ib-btn-primary { background: var(--ib-primary); color: var(--ib-primary-ink); }
.ib-btn-light { background: var(--ib-light); color: var(--ib-ink); }
.ib-btn-small { min-height: 44px; font-size: 14px; box-shadow: 0 4px 0 var(--ib-ink); }
.ib-btn.is-on { background: var(--ib-light); color: var(--ib-ink); }
.ib-link { background: none; border: none; color: var(--ib-text); font-size: 14px; text-decoration: underline; text-underline-offset: 4px; padding: 8px; align-self: center; }

/* ===== Waiting room ===== */
.ib-content { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 18px 18px 22px; }
.ib-plate { align-self: center; text-align: center; background: var(--ib-paper); border: var(--ib-line) solid var(--ib-ink); border-radius: 4px; padding: 8px 22px 10px; margin-top: 4px; }
.ib-plate-label { font-size: 12px; color: var(--ib-muted); }
.ib-code { font-family: "Dela Gothic One", var(--ib-font); font-weight: 400; font-size: 38px; letter-spacing: .14em; margin-right: -.14em; line-height: 1.15; }
.ib-plate-hint { font-size: 11px; color: var(--ib-muted); margin-top: 2px; }
.ib-section { color: var(--ib-text); font-size: 13px; font-weight: 700; letter-spacing: .08em; display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.ib-section::after { content: ""; flex: 1; height: 2px; background: currentColor; opacity: .3; }
/* メンバーは1枚の紙に線で区切った名簿(出席簿)。準備OKは赤いハンコ */
.ib-members { display: flex; flex-direction: column; background: var(--ib-paper); border: var(--ib-line) solid var(--ib-ink); border-radius: 4px; }
.ib-member { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 0; min-height: 50px; color: var(--ib-ink); }
.ib-member + .ib-member { border-top: 2px solid var(--ib-ink); }
.ib-member-name { flex: 1; min-width: 0; font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-member-name small { font-size: 11px; color: var(--ib-muted); margin-left: 4px; }
.ib-member-empty { color: var(--ib-muted); font-size: 13px; }
.ib-member-empty .ib-seat { background: transparent; color: var(--ib-muted); }
/* 出席番号: 左の列を区切り線つきの四角に */
.ib-seat { align-self: stretch; margin: -6px 0; width: 40px; flex-shrink: 0; border-right: 2px solid var(--ib-ink); display: flex; align-items: center; justify-content: center; font-family: "Dela Gothic One", var(--ib-font); font-weight: 400; font-size: 17px; color: var(--ib-ink); }
.ib-member:first-child .ib-seat { border-top-left-radius: 1px; }
.ib-host { flex-shrink: 0; font-size: 11px; font-weight: 900; background: var(--ib-ink); color: var(--ib-paper); padding: 1px 6px; border-radius: 2px; }
.ib-ok { flex-shrink: 0; width: 40px; height: 40px; border: 3px solid #D0352B; border-radius: 50%; color: #D0352B; display: flex; align-items: center; justify-content: center; font-family: "Dela Gothic One", var(--ib-font); font-weight: 400; font-size: 13px; transform: rotate(-14deg); animation: ib-stamp .25s ease-out; }
@keyframes ib-stamp { from { transform: rotate(-14deg) scale(1.7); opacity: 0; } to { transform: rotate(-14deg) scale(1); opacity: 1; } }
.ib-notyet { flex-shrink: 0; width: 40px; font-size: 10px; color: var(--ib-muted); text-align: center; }
.ib-avatar { width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%; border: 2.5px solid var(--ib-ink); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 900; color: var(--ib-ink); }
.ib-tag { flex-shrink: 0; font-size: 10px; border: 2px solid var(--ib-ink); border-radius: 999px; padding: 1px 7px; }
.ib-tag-host { background: var(--ib-ink); color: var(--ib-paper); }
.ib-tag-ready { background: var(--ib-primary); color: var(--ib-primary-ink); }
.ib-tag-wait { background: transparent; color: var(--ib-muted); border-color: var(--ib-muted); }
.ib-kick { flex-shrink: 0; width: 30px; height: 30px; border-radius: 4px; border: 2px solid var(--ib-ink); background: var(--ib-light); color: var(--ib-ink); font-size: 15px; line-height: 1; }
.ib-setting { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--ib-paper); border: 2.5px solid var(--ib-ink); border-radius: 4px; padding: 8px 10px; }
.ib-setting-label { font-size: 14px; font-weight: 700; }
.ib-seg { display: flex; border: 2.5px solid var(--ib-ink); border-radius: 6px; overflow: hidden; }
.ib-seg button { border: 0; border-left: 2px solid var(--ib-ink); background: var(--ib-light); padding: 6px 12px; font-size: 13px; font-weight: 900; }
.ib-seg button:first-child { border-left: 0; }
.ib-seg button.on { background: var(--ib-primary); color: var(--ib-primary-ink); }
.ib-seg button:disabled { cursor: default; }
.ib-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 10px; }
.ib-hint { color: var(--ib-text); font-size: 12px; text-align: center; }
.ib-row { display: flex; gap: 10px; }

/* ===== Modals ===== */
.ib-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .55); display: flex; align-items: center; justify-content: center; padding: 18px; }
.ib-modal { position: relative; width: 100%; max-width: 360px; max-height: calc(100dvh - 36px); overflow-y: auto; background: var(--ib-paper); color: var(--ib-ink); border: var(--ib-line) solid var(--ib-ink); border-radius: 6px; padding: 22px 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.ib-modal-title { font-size: 18px; font-weight: 900; text-align: center; }
.ib-close { position: absolute; top: 8px; right: 10px; width: 34px; height: 34px; border: 0; background: none; font-size: 24px; line-height: 1; }
.ib-label { font-size: 12px; color: var(--ib-muted); margin-bottom: -6px; }
.ib-input { width: 100%; font-size: 18px; font-weight: 700; padding: 10px 12px; border: var(--ib-line) solid var(--ib-ink); border-radius: 4px; background: #fff; color: var(--ib-ink); }
.ib-input-code { font-family: "Dela Gothic One", var(--ib-font); font-weight: 400; font-size: 24px; letter-spacing: .3em; text-align: center; }
.ib-error { color: #C8302A; font-size: 13px; min-height: 1em; text-align: center; }
.ib-error:empty { display: none; }
.ib-consent { font-size: 11px; line-height: 1.6; color: var(--muted); text-align: center; word-break: keep-all; overflow-wrap: anywhere; }
.ib-consent a { color: inherit; text-underline-offset: 2px; }
.ib-hint-dark { font-size: 13px; text-align: center; color: var(--ib-muted); }
.ib-qr { background: #fff; border: 2.5px solid var(--ib-ink); border-radius: 2px; padding: 0; align-self: center; width: 240px; }
.ib-qr svg { display: block; width: 100%; height: auto; }

/* 遊び方: 1ページ1ステップ */
.ib-step-no { align-self: center; font-family: "Dela Gothic One", var(--ib-font); font-weight: 400; font-size: 34px; line-height: 1; color: var(--ib-accent); }
.ib-step-no small { font-size: 14px; color: var(--ib-muted); margin-left: 4px; }
.ib-step-title { text-align: center; font-size: 17px; font-weight: 900; margin-top: -4px; }
.ib-step-art { display: flex; justify-content: center; }
.ib-step-art:empty { display: none; }
.ib-step-body { font-size: 14px; line-height: 1.75; text-align: center; }
.ib-dots { display: none !important; justify-content: center; gap: 6px; }
.ib-dots i { width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--ib-ink); }
.ib-dots i.on { background: var(--ib-ink); }

/* ===== Toast / reconnect ===== */
.ib-toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; background: var(--ib-ink); color: var(--ib-paper); border-radius: 6px; padding: 10px 18px; font-size: 13px; max-width: calc(100% - 32px); text-align: center; }
.ib-reconnect { position: fixed; top: 0; left: 0; right: 0; z-index: 70; background: var(--ib-ink); color: var(--ib-paper); font-size: 12px; text-align: center; padding: 8px; }

/* 招待(リンク/QR)は番号札のすぐ下に同じ大きさで。遊び方・退出は下に小さく */
.ib-invite { margin-top: -2px; }
.ib-links { display: flex; justify-content: center; gap: 18px; }
.ib-links .ib-link { padding: 4px 8px; font-size: 13px; }
/* 背の低い画面(iPhone SE など): 招待ボタンのぶん待合室を詰める。招待ボタンがあるので説明文は省く */
@media (max-height: 620px) {
  .ib-content { gap: 9px; padding-top: 12px; }
  .ib-plate { padding: 4px 22px 6px; }
  .ib-code { font-size: 32px; }
  .ib-plate-hint { display: none; }
  .ib-member { min-height: 42px; padding: 5px 10px 5px 0; }
  .ib-seat { margin: -5px 0; }
  .ib-bottom { gap: 8px; padding-top: 4px; }
}

/* 最終結果の「もう1回!」と、その下の小さいボタン2つ */
.ib-again { font-size: 20px; }
.ib-again-wait { text-align: center; font-size: 13px; color: var(--ib-text); }
.ib-final-row { display: flex; gap: 8px; }
.ib-final-row .ib-btn { flex: 1; min-width: 0; }

/* ===== カットイン(段階が変わった瞬間に全員へ) =====
   斜めの帯が右から飛びこんで止まり、左へ抜ける。後ろの細い帯は逆から来る。ベタ塗りだけで動きを出す。
   色はゲームの --ib-primary。data-kind="jam" は妨害など、赤で目立たせたいとき */
.ib-cutin { position: fixed; inset: 0; z-index: 55; display: flex; align-items: center; justify-content: center; pointer-events: none; overflow: hidden; }
.ib-cutin::before { content: ""; position: absolute; left: -20%; right: -20%; top: 50%; height: 120px; margin-top: -54px; background: var(--ib-ink); transform: rotate(-7deg) translateX(-110%); }
.ib-cutin-band { position: relative; width: 130%; flex-shrink: 0; padding: 14px 0 16px; text-align: center; background: var(--ib-primary); color: var(--ib-primary-ink); border-top: 4px solid var(--ib-ink); border-bottom: 4px solid var(--ib-ink); transform: rotate(-7deg) translateX(110%); }
.ib-cutin-title { font-size: clamp(28px, 9vw, 40px); font-weight: 900; line-height: 1.2; letter-spacing: .04em; padding: 0 16%; text-wrap: balance; }
.ib-cutin-sub { font-size: 15px; font-weight: 900; margin-top: 2px; padding: 0 16%; }
.ib-cutin[data-kind="jam"] .ib-cutin-band { background: #D0352B; color: #FFFFFF; }
.ib-cutin[data-kind="paper"] .ib-cutin-band { background: var(--ib-paper); color: var(--ib-ink); }
.ib-cutin.is-open::before { animation: ib-cut-back 1.7s cubic-bezier(.2, .8, .2, 1) both; }
.ib-cutin.is-open .ib-cutin-band { animation: ib-cut-band 1.7s cubic-bezier(.2, .8, .2, 1) both; }
.ib-cutin.is-open .ib-cutin-title { animation: ib-cut-text 1.7s ease both; }
@keyframes ib-cut-band {
  0% { transform: rotate(-7deg) translateX(110%); }
  16% { transform: rotate(-7deg) translateX(-2%); }
  22%, 80% { transform: rotate(-7deg) translateX(0); }
  100% { transform: rotate(-7deg) translateX(-115%); }
}
@keyframes ib-cut-back {
  0%, 4% { transform: rotate(-7deg) translateX(-110%); }
  20%, 82% { transform: rotate(-7deg) translateX(0); }
  100% { transform: rotate(-7deg) translateX(115%); }
}
@keyframes ib-cut-text {
  0%, 16% { transform: scale(1.25); }
  26%, 100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .ib-cutin.is-open::before, .ib-cutin.is-open .ib-cutin-band, .ib-cutin.is-open .ib-cutin-title { animation: ib-cut-fade 1.7s both; transform: rotate(-7deg); }
  @keyframes ib-cut-fade { 0%, 100% { opacity: 0; } 10%, 85% { opacity: 1; } }
}
