/* みんなで連打大会 — dopagaki design（黒地・蛍光色・硬い影・斜め帯・スタンプ）。ローカルフォントのみ使用 */

:root {
  --ink: #05050a;
  --panel: rgba(12, 12, 22, .92);
  --line: #2c2f42;
  --text: #f6f7fb;
  --text-dim: #b1b5c9;
  --yellow: #ffe63b;
  --pink: #ff3f8e;
  --cyan: #19e3ff;
  --lime: #7dff5a;
  --purple: #9a5cff;
  --team-a: #ff3f6e;
  --team-b: #19c8ff;
  --on-neon: #0a0a10;
  --font-ja: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", Meiryo, "Noto Sans JP", system-ui, sans-serif;
  --font-latin: "Arial Black", "Segoe UI Black", "Helvetica Neue", Arial, var(--font-ja);
  --ease-punch: cubic-bezier(.2, 1.55, .35, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--text); -webkit-text-size-adjust: 100%; }
body {
  min-width: 300px;
  font-family: var(--font-ja);
  font-weight: 600;
  line-height: 1.55;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; touch-action: manipulation; cursor: pointer; }
button:disabled { cursor: default; }
p, h1, h2, h3, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
b.ta, .ta-badge { color: var(--team-a); }
b.tb, .tb-badge { color: var(--team-b); }

/* ---------- 共通部品 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 48px; padding: 8px 20px;
  border: 3px solid var(--on-neon); border-radius: 12px;
  background: #23243a; color: var(--text);
  font-weight: 900; text-decoration: none;
  box-shadow: 5px 5px 0 var(--on-neon);
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--on-neon); }
.btn--yellow { background: var(--yellow); color: var(--on-neon); }
.btn--danger { background: #ff3b30; color: #fff; }
.btn--ghost { background: transparent; border-color: #4a4d66; box-shadow: none; color: var(--text); }
.btn small { font-weight: 700; opacity: .7; }
.link-btn { border: 0; background: none; color: var(--text-dim); text-decoration: underline; padding: 8px; font-weight: 600; }
.tool {
  min-height: 38px; padding: 4px 14px;
  border: 2px solid #4a4d66; border-radius: 999px;
  background: rgba(20, 21, 36, .9); color: var(--text);
  font-size: 15px; font-weight: 800;
}
.tool[aria-pressed="false"] { color: var(--text-dim); border-style: dashed; }
.tool--danger { border-color: #ff3b30; color: #ff8a80; }
.tool--sm { min-height: 32px; padding: 2px 10px; font-size: 13px; }
.conn { font-size: 13px; color: var(--text-dim); white-space: nowrap; }
.conn::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 50%; background: #888; vertical-align: 1px; }
.conn[data-kind="online"]::before { background: var(--lime); box-shadow: 0 0 8px var(--lime); }
.conn[data-kind="reconnecting"]::before, .conn[data-kind="connecting"]::before { background: var(--yellow); }
.conn[data-kind="offline"]::before { background: #ff3b30; }
.form-error { min-height: 1.4em; color: #ff8a80; font-size: 14px; }
.ev-icon { display: inline-block; width: 1.6em; height: 1.6em; flex: none; }
.ev-icon svg, .sprite svg { display: block; width: 100%; height: 100%; }
.sprite { display: inline-block; width: 40px; height: 40px; }
.ic-sprites { display: inline-flex; gap: 4px; }
.ic-sprites .sprite { animation: bob 1.2s ease-in-out infinite; }
.ic-sprites .sprite:nth-child(2) { animation-delay: .2s; }
.ic-sprites .sprite:nth-child(3) { animation-delay: .4s; }
.ic-sprites .sprite:nth-child(4) { animation-delay: .6s; }
.ic-sprites .sprite:nth-child(5) { animation-delay: .8s; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-6deg); } }

.tape {
  position: absolute; left: -5%; right: -5%;
  overflow: hidden; white-space: nowrap;
  background: var(--yellow); color: var(--on-neon);
  font: 900 18px/1 var(--font-latin); letter-spacing: .06em;
  padding: 8px 0; border-block: 3px solid var(--on-neon);
  pointer-events: none;
}
.tape span { display: inline-block; animation: tape 26s linear infinite; }
.tape-top { top: 14px; transform: rotate(-2deg); }
.tape-bottom { bottom: 16px; transform: rotate(1.5deg); background: var(--team-b); }
.tape-bottom span { animation-direction: reverse; }
@keyframes tape { to { transform: translateX(-50%); } }

/* ---------- タイトル ---------- */
.screen-title {
  position: relative; min-height: 100vh; min-height: 100dvh; overflow: hidden;
  background:
    repeating-conic-gradient(from 0deg at 50% 38%, rgba(255, 63, 110, .07) 0deg 6deg, transparent 6deg 18deg),
    radial-gradient(ellipse at 50% 30%, #241a3c 0%, var(--ink) 70%);
}
.title-body {
  position: relative; z-index: 1;
  max-width: 980px; margin: 0 auto;
  padding: 76px 20px 90px;
  display: flex; flex-direction: column; align-items: center; gap: 22px; text-align: center;
}
.back-link { align-self: flex-start; color: var(--text-dim); font-size: 14px; text-decoration: none; border-bottom: 1px dashed; }
.logo { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.logo-kicker { font-size: clamp(22px, 5vw, 34px); font-weight: 900; color: var(--yellow); transform: rotate(-4deg); text-shadow: 3px 3px 0 var(--on-neon); }
.logo-word {
  margin-top: 6px;
  font-size: clamp(64px, 17vw, 150px); font-weight: 900; letter-spacing: .02em;
  color: #fff;
  -webkit-text-stroke: 4px var(--on-neon); paint-order: stroke fill;
  text-shadow: 6px 6px 0 var(--team-a), 12px 12px 0 var(--on-neon), -6px -4px 0 var(--team-b);
  animation: logoShake 2.4s ease-in-out infinite;
}
@keyframes logoShake { 0%, 86%, 100% { transform: none; } 88% { transform: translate(-3px, 2px) rotate(-1deg); } 90% { transform: translate(3px, -2px) rotate(1deg); } 92% { transform: translate(-2px, 1px); } }
.logo-stamp {
  margin-top: 10px; padding: 4px 16px;
  border: 4px solid var(--lime); color: var(--lime);
  font: 900 clamp(18px, 4vw, 28px)/1.1 var(--font-latin); letter-spacing: .12em;
  transform: rotate(-6deg);
}
.lead { font-size: clamp(16px, 3.6vw, 20px); max-width: 34em; }
.title-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; width: 100%; }
.big-btn, .join-box {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left;
  padding: 18px 20px 20px 72px; min-height: 150px;
  border: 4px solid var(--on-neon); border-radius: 18px;
  box-shadow: 8px 8px 0 var(--on-neon);
}
.big-btn--host { background: var(--yellow); color: var(--on-neon); }
.big-btn--host:not(:disabled):hover { transform: translate(-2px, -2px); box-shadow: 10px 10px 0 var(--on-neon); }
.join-box { background: #1b1c30; border-color: var(--team-b); }
.bb-no { position: absolute; left: 16px; top: 14px; font: 900 34px/1 var(--font-latin); opacity: .5; }
.bb-name { font-size: 24px; font-weight: 900; }
.bb-sub { font-size: 14px; font-weight: 600; opacity: .85; }
.join-row { display: flex; gap: 10px; margin-top: 6px; }
.room-input, .p-input {
  min-width: 0; height: 52px; padding: 0 14px;
  border: 3px solid var(--on-neon); border-radius: 12px;
  background: #fff; color: var(--on-neon);
  font: 900 24px/1 var(--font-latin); letter-spacing: .14em;
}
.room-input { width: 9ch; text-align: center; }
.p-input { width: 100%; font: 800 20px/1 var(--font-ja); letter-spacing: 0; }
.title-events { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 18px; }
.title-events li { display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 8px; border: 2px solid var(--line); border-radius: 999px; background: rgba(20, 20, 36, .8); font-size: 16px; }
.title-events .ev-icon { width: 38px; height: 38px; }
.title-note { color: var(--text-dim); font-size: 14px; }

/* ---------- 大型表示 ---------- */
.screen-host { position: fixed; inset: 0; overflow: hidden; background: #000; }
.host-stage {
  --s: 1;
  position: absolute; left: 50%; top: 50%;
  width: 1600px; height: 900px;
  transform: translate(-50%, -50%) scale(var(--s));
  overflow: hidden; background: var(--ink);
  font-size: 22px;
}
.scene-canvas { position: absolute; inset: 0; width: 1600px; height: 900px; display: block; transition: opacity .4s; }
.host-stage[data-view="lobby"] .scene-canvas { opacity: .22; }
.host-tap {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 20;
  padding: 8px 18px; border-radius: 999px; background: var(--yellow); color: var(--on-neon); font-weight: 900;
  animation: blink 1.2s step-end infinite; pointer-events: none;
}
@keyframes blink { 50% { opacity: .55; } }

.host-bar {
  position: absolute; left: 0; right: 0; top: 0; height: 76px; z-index: 6;
  display: flex; align-items: center; gap: 26px; padding: 0 22px;
  background: rgba(5, 5, 10, .88); border-bottom: 3px solid var(--line);
}
.hb-logo { display: flex; align-items: baseline; gap: 6px; }
.hb-logo span { color: var(--yellow); font-size: 18px; font-weight: 900; }
.hb-logo b { font-size: 34px; font-weight: 900; -webkit-text-stroke: 2px var(--on-neon); paint-order: stroke fill; text-shadow: 3px 3px 0 var(--team-a); }
.hb-room { font-size: 18px; color: var(--text-dim); }
.hb-room b { margin-left: 6px; font: 900 34px/1 var(--font-latin); color: var(--yellow); letter-spacing: .1em; }
.hb-tally { display: flex; align-items: center; gap: 8px; font: 900 28px/1 var(--font-latin); }
.hb-tally .ta-badge, .hb-tally .tb-badge { font-size: 20px; }
.hb-tally small { font: 700 14px var(--font-ja); color: var(--text-dim); margin-left: 6px; }
.hb-dash { color: var(--text-dim); }
.hb-tools { margin-left: auto; display: flex; gap: 8px; }
.ta-badge, .tb-badge {
  display: inline-grid; place-items: center; width: 1.5em; height: 1.5em;
  border: 3px solid var(--on-neon); border-radius: 8px;
  background: var(--team-a); color: #fff; font: 900 1em/1 var(--font-latin);
  -webkit-text-stroke: 1px var(--on-neon);
  box-shadow: 3px 3px 0 var(--on-neon);
}
.tb-badge { background: var(--team-b); }

.view { position: absolute; left: 0; right: 0; top: 76px; bottom: 0; z-index: 3; opacity: 0; visibility: hidden; transition: opacity .25s, visibility 0s .25s; }
.view.on { opacity: 1; visibility: visible; transition: opacity .25s; }

/* ロビー */
.view-lobby {
  display: grid; grid-template-columns: 410px 1fr; grid-template-rows: 1fr 250px;
  gap: 18px; padding: 18px 24px 20px;
}
.qr-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 18px; border: 4px solid var(--on-neon); border-radius: 22px;
  background: #fff; color: var(--on-neon);
  box-shadow: 10px 10px 0 var(--yellow);
  transform: rotate(-1.2deg);
}
.qr { width: 330px; height: 330px; }
.qr svg { display: block; width: 100%; height: 100%; }
.qr-cap { font-size: 22px; font-weight: 900; white-space: nowrap; }
.qr-url { font-size: 15px; font-weight: 700; color: #3a3a4a; word-break: break-all; text-align: center; }
.qr-room { font-size: 18px; }
.qr-room b { font: 900 30px/1 var(--font-latin); letter-spacing: .12em; margin-left: 4px; }

.teams { position: relative; display: grid; grid-template-columns: 1fr 70px 1fr; grid-template-rows: 1fr auto; gap: 0 10px; min-height: 0; }
.team-col {
  display: flex; flex-direction: column; min-height: 0;
  border: 4px solid var(--on-neon); border-radius: 20px;
  background: linear-gradient(160deg, rgba(255, 63, 110, .28), rgba(20, 16, 34, .92) 55%);
  box-shadow: 8px 8px 0 var(--team-a);
  overflow: hidden;
}
.team-col--b { background: linear-gradient(200deg, rgba(25, 200, 255, .28), rgba(20, 16, 34, .92) 55%); box-shadow: 8px 8px 0 var(--team-b); }
.tc-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 3px solid rgba(255, 255, 255, .12); }
.tc-badge {
  display: grid; place-items: center; width: 60px; height: 60px; flex: none;
  border: 4px solid var(--on-neon); border-radius: 14px;
  background: var(--team-a); font: 900 40px/1 var(--font-latin); color: #fff;
  -webkit-text-stroke: 2px var(--on-neon); paint-order: stroke fill;
  box-shadow: 4px 4px 0 var(--on-neon);
}
.team-col--b .tc-badge { background: var(--team-b); }
.tc-name {
  flex: 1; min-width: 0; text-align: left; padding: 2px 6px;
  border: 2px dashed transparent; border-radius: 8px; background: none;
  font-size: 34px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tc-name:hover { border-color: rgba(255, 255, 255, .35); }
.tc-count { font-size: 22px; white-space: nowrap; }
.tc-count b { font: 900 46px/1 var(--font-latin); color: var(--yellow); margin-right: 2px; }
.chips { flex: 1; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; padding: 14px; overflow: hidden; }
.chip {
  max-width: 100%; padding: 4px 12px;
  border: 2px solid var(--on-neon); border-radius: 999px;
  background: #fff; color: var(--on-neon); font-size: 19px; font-weight: 900;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 3px 3px 0 var(--on-neon);
  animation: chipIn .35s var(--ease-punch);
}
.chip[data-online="false"] { opacity: .45; border-style: dashed; }
@keyframes chipIn { from { transform: scale(.3) rotate(-10deg); opacity: 0; } }
.chips-more { padding: 0 16px 12px; color: var(--text-dim); font-size: 18px; }
.vs { align-self: center; justify-self: center; font: 900 54px/1 var(--font-latin); color: var(--yellow); -webkit-text-stroke: 3px var(--on-neon); paint-order: stroke fill; text-shadow: 5px 5px 0 var(--on-neon); transform: rotate(-8deg); }
.lobby-hint { grid-column: 1 / -1; margin-top: 12px; text-align: center; font-size: 26px; font-weight: 900; color: var(--yellow); }
.lobby-wait { position: absolute; right: 8px; top: -30px; font-size: 17px; color: var(--text-dim); }

.setup { grid-column: 1 / -1; display: grid; grid-template-columns: auto 1fr 300px; gap: 18px; min-height: 0; }
.setup-events { margin: 0; padding: 10px 14px 14px; border: 3px solid var(--line); border-radius: 18px; background: rgba(12, 12, 22, .85); min-width: 0; }
.setup-events legend, .opt-l { padding: 0 6px; font-size: 17px; color: var(--text-dim); }
.ev-cards { display: flex; gap: 10px; height: 100%; }
.ev-card {
  width: 132px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 3px solid #3a3d55; border-radius: 16px; background: #181a2c; padding: 8px 6px;
  transition: transform .12s;
}
.ev-card .ev-icon { width: 78px; height: 78px; }
.ev-card b { font-size: 19px; line-height: 1.2; }
.ev-card small { font-size: 14px; color: var(--text-dim); }
.ev-card[aria-pressed="true"] { border-color: var(--on-neon); background: var(--yellow); color: var(--on-neon); box-shadow: 5px 5px 0 var(--on-neon); transform: translateY(-4px) rotate(-1.5deg); }
.ev-card[aria-pressed="true"] small { color: var(--on-neon); }
.setup-opts { display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 12px 16px; border: 3px solid var(--line); border-radius: 18px; background: rgba(12, 12, 22, .85); }
.opt { display: flex; align-items: center; gap: 10px; }
.opt-l { width: 4.2em; flex: none; padding: 0; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { min-height: 44px; padding: 4px 14px; border: 2px solid #3a3d55; border-radius: 10px; background: #181a2c; font-size: 18px; font-weight: 800; }
.seg button[aria-pressed="true"] { border-color: var(--on-neon); background: var(--cyan); color: var(--on-neon); box-shadow: 3px 3px 0 var(--on-neon); }
.start-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 5px solid var(--on-neon); border-radius: 22px;
  background: var(--yellow); color: var(--on-neon);
  box-shadow: 9px 9px 0 var(--team-a);
  font-size: 36px; font-weight: 900; line-height: 1.1; white-space: nowrap;
  animation: pulse 1.6s ease-in-out infinite;
}
.start-btn small { font: 800 16px var(--font-latin); opacity: .7; }
.start-btn:disabled { background: #3a3d55; color: #8d90a8; box-shadow: none; animation: none; }
.start-btn:not(:disabled):active { transform: translate(4px, 4px); box-shadow: 4px 4px 0 var(--team-a); }
@keyframes pulse { 50% { transform: scale(1.03) rotate(-1deg); } }

/* 説明・抽選・カウントダウン */
.view-intro { display: grid; place-items: center; background: radial-gradient(ellipse at center, rgba(5, 5, 10, .35), rgba(5, 5, 10, .82) 70%); }
.roulette { text-align: center; }
.roulette-title { font-size: 64px; font-weight: 900; color: var(--yellow); text-shadow: 5px 5px 0 var(--on-neon); margin-bottom: 30px; }
.roulette-row { display: flex; gap: 26px; }
.rl-card {
  width: 270px; height: 280px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  border: 5px solid #3a3d55; border-radius: 24px; background: #181a2c; font-size: 32px;
  transition: transform .08s;
}
.rl-card .ev-icon { width: 160px; height: 160px; }
.rl-card.on { border-color: var(--on-neon); background: var(--yellow); color: var(--on-neon); transform: scale(1.1) rotate(-2deg); box-shadow: 10px 10px 0 var(--team-a); }
.intro-card {
  width: 1160px; padding: 30px 40px 34px; text-align: center;
  border: 6px solid var(--on-neon); border-radius: 30px;
  background: rgba(14, 14, 26, .94);
  box-shadow: 14px 14px 0 var(--yellow);
}
.intro-card.pop { animation: slam .5s var(--ease-punch); }
@keyframes slam { from { transform: scale(1.8) rotate(-6deg); opacity: 0; } }
.ic-no { font-size: 28px; color: var(--text-dim); }
.ic-title { font-size: 150px; line-height: 1.05; font-weight: 900; color: #fff; -webkit-text-stroke: 6px var(--on-neon); paint-order: stroke fill; text-shadow: 8px 8px 0 var(--team-a), 16px 16px 0 var(--on-neon); }
.ic-en { margin-top: 6px; font: 900 34px/1 var(--font-latin); letter-spacing: .16em; color: var(--lime); }
.ic-rule { margin-top: 22px; font-size: 40px; font-weight: 900; }
.ic-obstacle { display: inline-flex; align-items: center; gap: 14px; margin-top: 18px; padding: 10px 24px; border: 4px dashed #ff8a80; border-radius: 18px; font-size: 32px; }
.ic-obstacle b { color: #ff5a5a; font-size: 1.3em; }
.ic-obstacle .sprite { width: 64px; height: 64px; }
.ic-teams { margin-top: 16px; font-size: 28px; color: var(--text-dim); }
.countdown {
  position: absolute; inset: 0; display: grid; place-items: center;
  font: 900 380px/1 var(--font-latin); color: var(--yellow);
  -webkit-text-stroke: 12px var(--on-neon); paint-order: stroke fill;
  text-shadow: 18px 18px 0 var(--on-neon);
  background: rgba(5, 5, 10, .55);
  pointer-events: none; z-index: 8;
}
.view-play .countdown, .host-stage .countdown { z-index: 8; }
.countdown.beat { animation: beat .8s var(--ease-punch); }
.countdown.go { color: var(--lime); font-size: 300px; background: transparent; }
@keyframes beat { from { transform: scale(2.2); opacity: 0; } 40% { opacity: 1; } }
.abort-btn { position: absolute; right: 22px; bottom: 18px; z-index: 9; }

/* 勝負中 */
.view-play { pointer-events: none; }
.hud { position: absolute; left: 22px; right: 22px; top: 8px; display: grid; grid-template-columns: 1fr 300px 1fr; gap: 16px; }
.hud-team {
  display: flex; gap: 14px; padding: 8px 16px; min-height: 150px;
  border: 4px solid var(--on-neon); border-radius: 18px;
  background: linear-gradient(120deg, var(--team-a), #a8183e);
  box-shadow: 7px 7px 0 var(--on-neon);
}
.hud-team--b { flex-direction: row-reverse; background: linear-gradient(240deg, var(--team-b), #0b6f9c); }
.ht-main { flex: 1; min-width: 0; }
.hud-team--b .ht-main { text-align: right; }
.ht-name { display: flex; align-items: center; gap: 10px; font-size: 26px; font-weight: 900; white-space: nowrap; overflow: hidden; text-shadow: 2px 2px 0 var(--on-neon); }
.hud-team--b .ht-name { justify-content: flex-end; }
.ht-name .ta-badge, .ht-name .tb-badge { background: #fff; color: var(--on-neon); -webkit-text-stroke: 0; }
.ht-score b { font: 900 80px/1 var(--font-latin); color: #fff; -webkit-text-stroke: 3px var(--on-neon); paint-order: stroke fill; text-shadow: 5px 5px 0 var(--on-neon); }
.ht-score small { font-size: 22px; margin-left: 4px; }
.ht-sub { font-size: 17px; font-weight: 800; }
.top-list { width: 230px; display: flex; flex-direction: column; justify-content: center; gap: 4px; counter-reset: rank; }
.top-list li { display: flex; gap: 8px; align-items: center; padding: 2px 10px; border-radius: 8px; background: rgba(5, 5, 10, .55); font-size: 18px; counter-increment: rank; }
.top-list li::before { content: counter(rank); font: 900 18px var(--font-latin); color: var(--yellow); }
.top-list li span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-list li b { font-family: var(--font-latin); }
.hud-timer { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px; border: 4px solid var(--on-neon); border-radius: 18px; background: var(--yellow); color: var(--on-neon); box-shadow: 7px 7px 0 var(--on-neon); }
.ht-event { font-size: 24px; font-weight: 900; }
.ht-time b { font: 900 96px/1 var(--font-latin); }
.ht-time b.hurry { color: #e8002d; animation: hurry .5s ease-in-out infinite; display: inline-block; }
.ht-time small { font-size: 22px; }
@keyframes hurry { 50% { transform: scale(1.15); } }
.hud-bar { grid-column: 1 / -1; display: flex; height: 22px; border: 4px solid var(--on-neon); border-radius: 999px; overflow: hidden; background: var(--on-neon); }
.hud-bar span { width: var(--w, 50%); transition: width .25s ease-out; }
#hud-bar-a { background: var(--team-a); }
#hud-bar-b { background: var(--team-b); }
.hud-fair { grid-column: 1 / -1; justify-self: center; margin-top: -6px; padding: 2px 14px; border-radius: 999px; background: rgba(5, 5, 10, .75); font-size: 17px; }
.oops-feed { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; flex-direction: column-reverse; align-items: center; gap: 8px; width: 760px; }
.oops {
  display: flex; align-items: center; gap: 10px; padding: 4px 16px 4px 6px;
  border: 3px solid var(--on-neon); border-radius: 999px; background: #fff; color: var(--on-neon);
  font-size: 22px; font-weight: 900; box-shadow: 5px 5px 0 var(--team-a);
  animation: oopsIn 2.6s ease-out forwards;
}
.oops--b { box-shadow: 5px 5px 0 var(--team-b); }
.oops .sprite { width: 48px; height: 48px; }
.oops b { color: #e8002d; font: 900 28px var(--font-latin); }
@keyframes oopsIn { 0% { transform: scale(.4) rotate(-8deg); opacity: 0; } 12% { transform: scale(1.08); opacity: 1; } 20% { transform: none; } 85% { opacity: 1; } 100% { opacity: 0; transform: translateY(-20px); } }
.last5, .finish-stamp {
  position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%) rotate(-6deg);
  font-size: 120px; font-weight: 900; color: #fff; white-space: nowrap;
  -webkit-text-stroke: 6px var(--on-neon); paint-order: stroke fill; text-shadow: 10px 10px 0 #e8002d;
}
.last5.flash { animation: flash5 1.6s ease-out forwards; }
@keyframes flash5 { 0% { transform: translate(-50%, -50%) rotate(-6deg) scale(2); opacity: 0; } 15% { opacity: 1; transform: translate(-50%, -50%) rotate(-6deg) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }
.finish-stamp { padding: 10px 50px; border: 10px solid #e8002d; border-radius: 26px; background: rgba(5, 5, 10, .7); color: #fff; font-size: 160px; text-shadow: 10px 10px 0 var(--on-neon); }
.finish-stamp.pop { animation: stamp .45s var(--ease-punch); }
@keyframes stamp { from { transform: translate(-50%, -50%) rotate(-14deg) scale(2.4); opacity: 0; } }

/* 結果 */
.view-result { display: flex; flex-direction: column; align-items: center; padding: 14px 30px; background: linear-gradient(rgba(5, 5, 10, .78), rgba(5, 5, 10, .25) 60%, rgba(5, 5, 10, .6)); }
.res-title { font-size: 30px; font-weight: 900; color: var(--yellow); text-shadow: 3px 3px 0 var(--on-neon); }
.res-teams { display: grid; grid-template-columns: 1fr 90px 1fr; gap: 10px; width: 100%; margin-top: 10px; }
.res-team { padding: 8px 22px 10px; border: 5px solid var(--on-neon); border-radius: 22px; background: linear-gradient(120deg, var(--team-a), #a8183e); box-shadow: 8px 8px 0 var(--on-neon); transition: transform .3s, filter .3s; }
.res-team--b { background: linear-gradient(240deg, var(--team-b), #0b6f9c); text-align: right; }
.res-team.win { transform: scale(1.04) rotate(-1deg); box-shadow: 8px 8px 0 var(--on-neon), 0 0 40px var(--yellow); }
.res-team.lose { filter: saturate(.35) brightness(.7); }
.rt-name { display: flex; align-items: center; gap: 10px; font-size: 30px; font-weight: 900; text-shadow: 2px 2px 0 var(--on-neon); }
.res-team--b .rt-name { justify-content: flex-end; }
.rt-name .ta-badge, .rt-name .tb-badge { background: #fff; color: var(--on-neon); -webkit-text-stroke: 0; }
.rt-score b { font: 900 92px/1.05 var(--font-latin); color: #fff; -webkit-text-stroke: 4px var(--on-neon); paint-order: stroke fill; text-shadow: 6px 6px 0 var(--on-neon); }
.rt-score small { font-size: 28px; }
.rt-sub { font-size: 20px; font-weight: 800; }
.rt-mvp { min-height: 1.5em; margin-top: 4px; font-size: 22px; font-weight: 900; color: var(--yellow); text-shadow: 2px 2px 0 var(--on-neon); }
.res-vs { align-self: center; justify-self: center; font: 900 56px/1 var(--font-latin); color: var(--yellow); -webkit-text-stroke: 3px var(--on-neon); paint-order: stroke fill; }
.res-winner {
  margin-top: 22px; padding: 2px 46px;
  border: 8px solid var(--on-neon); border-radius: 24px;
  background: var(--yellow); color: var(--on-neon);
  font-size: 92px; font-weight: 900; line-height: 1.15;
  box-shadow: 12px 12px 0 var(--on-neon);
  transform: rotate(-3deg);
}
.res-winner[data-winner="A"] { box-shadow: 12px 12px 0 var(--team-a); }
.res-winner[data-winner="B"] { box-shadow: 12px 12px 0 var(--team-b); }
.res-winner.pop { animation: winPop .6s var(--ease-punch); }
@keyframes winPop { from { transform: rotate(-12deg) scale(2.6); opacity: 0; } }
.res-note { min-height: 1.4em; margin-top: 10px; font-size: 20px; color: var(--text-dim); }
.res-awards { display: flex; gap: 18px; margin-top: 2px; }
.award { padding: 6px 18px; border: 3px solid var(--on-neon); border-radius: 999px; background: #fff; color: var(--on-neon); font-size: 22px; font-weight: 900; box-shadow: 4px 4px 0 var(--lime); }
.award--oops { box-shadow: 4px 4px 0 #ff8a80; }
.award:empty { display: none; }
.mini-qr { position: absolute; left: 24px; bottom: 20px; display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; border: 3px solid var(--on-neon); border-radius: 16px; background: #fff; color: var(--on-neon); font-size: 17px; font-weight: 800; line-height: 1.35; box-shadow: 5px 5px 0 var(--yellow); }
.mini-qr-code { width: 132px; height: 132px; }
.mini-qr-code svg { display: block; width: 100%; height: 100%; }
.mini-qr b { font: 900 24px var(--font-latin); letter-spacing: .08em; }
.res-actions { position: absolute; right: 26px; bottom: 22px; display: flex; align-items: center; gap: 16px; }
.start-btn--small { width: 330px; height: 110px; font-size: 30px; }
.btn--ghost small { font-family: var(--font-latin); }

.caption {
  position: absolute; left: 50%; bottom: 14px; z-index: 7; transform: translateX(-50%);
  max-width: 1200px; padding: 6px 22px; border-radius: 12px;
  background: rgba(5, 5, 10, .82); font-size: 24px; text-align: center;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.caption.on { opacity: 1; }
.host-stage[data-view="lobby"] .caption { bottom: auto; top: 330px; }
.host-stage[data-view="play"] .caption { bottom: auto; top: 304px; }
.host-stage[data-view="result"] .caption { display: none; }

/* ---------- スマホ ---------- */
.screen-player {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  min-height: 100vh; min-height: 100dvh;
  background: radial-gradient(ellipse at 50% 0%, #241a3c, var(--ink) 70%);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-user-select: none; user-select: none;
}
body[data-team="A"] .screen-player { background: radial-gradient(ellipse at 50% 0%, rgba(255, 63, 110, .35), var(--ink) 70%); }
body[data-team="B"] .screen-player { background: radial-gradient(ellipse at 50% 0%, rgba(25, 200, 255, .32), var(--ink) 70%); }
.p-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 2px solid var(--line); background: rgba(5, 5, 10, .7); font-size: 13px; white-space: nowrap; }
.conn:empty { display: none; }
@media (max-width: 400px) { .p-back { display: none; } .p-room { margin-left: 0; } .p-bar .conn { margin-left: auto; } }
.p-back { color: var(--text-dim); text-decoration: none; font-size: 12px; }
/* 説明・連打の最中は、うっかり押さないように隠す */
body[data-pview="play"] .p-back, body[data-pview="intro"] .p-back { visibility: hidden; }
.p-room { margin-left: auto; color: var(--text-dim); }
.p-room b { font: 900 18px/1 var(--font-latin); color: var(--yellow); letter-spacing: .08em; }
.pview { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 16px 18px 22px; }
.p-logo { text-align: center; font-size: 40px; font-weight: 900; line-height: 1.1; -webkit-text-stroke: 2px var(--on-neon); paint-order: stroke fill; text-shadow: 4px 4px 0 var(--team-a); }
.p-logo span { display: block; font-size: 18px; color: var(--yellow); -webkit-text-stroke: 0; text-shadow: none; }
.p-label { font-size: 14px; color: var(--text-dim); }
.p-teams { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.p-team {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 8px;
  border: 4px solid var(--on-neon); border-radius: 20px;
  background: var(--team-a); color: #fff; box-shadow: 6px 6px 0 var(--on-neon);
  text-shadow: 2px 2px 0 var(--on-neon);
}
.p-team--b { background: var(--team-b); }
.p-team:active { transform: translate(3px, 3px); box-shadow: 3px 3px 0 var(--on-neon); }
.p-team:disabled { filter: grayscale(1); opacity: .5; }
.pt-badge { font: 900 64px/1 var(--font-latin); -webkit-text-stroke: 3px var(--on-neon); paint-order: stroke fill; }
.pt-name { font-size: 20px; font-weight: 900; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-team small { font-size: 15px; }
.p-myteam {
  display: flex; flex-direction: column; align-items: center; padding: 18px 10px 14px;
  border: 4px solid var(--on-neon); border-radius: 22px;
  background: var(--team-a); box-shadow: 7px 7px 0 var(--on-neon); text-shadow: 2px 2px 0 var(--on-neon);
}
body[data-team="B"] .p-myteam { background: var(--team-b); }
.pm-badge { font: 900 90px/1 var(--font-latin); -webkit-text-stroke: 4px var(--on-neon); paint-order: stroke fill; }
.pm-team { font-size: 28px; font-weight: 900; }
.pm-me { font-size: 18px; }
.p-status { text-align: center; font-size: 18px; color: var(--yellow); }
.p-next { text-align: center; font-size: 15px; color: var(--text-dim); }
.p-rules { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border: 2px solid var(--line); border-radius: 14px; background: rgba(12, 12, 22, .8); font-size: 15px; }
.p-obs { display: flex; align-items: center; gap: 8px; }
.p-obs b { color: #ff5a5a; }
.p-obs .sprite { width: 34px; height: 34px; }
.p-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pview-intro { align-items: center; justify-content: center; text-align: center; }
.ev-icon--big { width: 140px; height: 140px; }
.pi-title { font-size: 40px; font-weight: 900; -webkit-text-stroke: 2px var(--on-neon); paint-order: stroke fill; text-shadow: 4px 4px 0 var(--team-a); }
.pi-rule { font-size: 19px; }
.pi-count { min-height: 1.1em; font: 900 120px/1 var(--font-latin); color: var(--yellow); -webkit-text-stroke: 5px var(--on-neon); paint-order: stroke fill; text-shadow: 6px 6px 0 var(--on-neon); }
.pi-count.beat { animation: beat .8s var(--ease-punch); }
.pi-team { color: var(--text-dim); }

/* 連打の画面 */
.pview-play { padding: 0; gap: 0; overflow: hidden; }
.pp-hud { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 14px; padding: 8px 14px 10px; background: rgba(5, 5, 10, .8); border-bottom: 3px solid var(--on-neon); }
.pp-time { font-size: 16px; }
.pp-time b { font: 900 42px/1 var(--font-latin); color: var(--yellow); }
.pp-mine { justify-self: end; font-size: 16px; }
.pp-mine small { margin-right: 6px; color: var(--text-dim); }
.pp-mine b { font: 900 42px/1 var(--font-latin); }
.pp-bar { grid-column: 1 / -1; display: flex; height: 14px; border: 3px solid var(--on-neon); border-radius: 999px; overflow: hidden; }
.pp-bar span { width: var(--w, 50%); transition: width .25s; }
#pp-bar-a { background: var(--team-a); }
#pp-bar-b { background: var(--team-b); }
.tap-area {
  position: relative; flex: 1; min-height: 0; overflow: hidden;
  touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
  background:
    repeating-conic-gradient(from 0deg at 50% 60%, rgba(255, 255, 255, .06) 0deg 5deg, transparent 5deg 15deg),
    radial-gradient(circle at 50% 60%, rgba(255, 63, 110, .45), var(--ink) 75%);
  cursor: pointer;
}
.tap-area[data-team="B"] {
  background:
    repeating-conic-gradient(from 0deg at 50% 60%, rgba(255, 255, 255, .06) 0deg 5deg, transparent 5deg 15deg),
    radial-gradient(circle at 50% 60%, rgba(25, 200, 255, .42), var(--ink) 75%);
}
.tap-area.ouch { animation: ouch .45s ease-out; }
@keyframes ouch { 0% { box-shadow: inset 0 0 0 14px #ff2b2b; } 100% { box-shadow: inset 0 0 0 0 transparent; } }
.tap-art { position: absolute; inset: 6% 4% 4%; display: grid; place-items: center; pointer-events: none; }
.tap-art svg { width: 100%; height: 100%; max-height: 100%; overflow: visible; }
/* 動かす部分だけ、自分の大きさを基準に動かす（中の transform 属性には影響させない） */
.ta-drum, .ta-head, .ta-kine, .ta-mochi, .ta-box, .ta-rikishi, .ta-rope, .ta-hands { transform-box: fill-box; }
.ta-drum { transform-origin: center; }
.hit .ta-drum, .hit2 .ta-drum { animation: drumHit .14s ease-out; }
@keyframes drumHit { 30% { transform: scale(.94); } }
.hit .ta-head, .hit2 .ta-head { animation: headFlash .14s ease-out; }
@keyframes headFlash { 30% { fill: #ffffff; } }
.ta-kine { transform-origin: center; transform: translateY(-34%); }
.hit .ta-kine { animation: pound .16s ease-in; }
.hit2 .ta-kine { animation: pound2 .16s ease-in; }
@keyframes pound { 45% { transform: translateY(0); } }
@keyframes pound2 { 45% { transform: translateY(0); } }
.ta-mochi { transform-origin: center bottom; }
.hit .ta-mochi, .hit2 .ta-mochi { animation: squash .2s ease-out .06s; }
@keyframes squash { 40% { transform: scale(1.15, .78); } }
.ta-box { transform-origin: center bottom; }
.hit .ta-box { animation: boxJolt .12s ease-out; }
.hit2 .ta-box { animation: boxJolt2 .12s ease-out; }
@keyframes boxJolt { 40% { transform: translate(-4px, 6px); } }
@keyframes boxJolt2 { 40% { transform: translate(4px, 6px); } }
.ta-rikishi { transform-origin: center bottom; }
.hit .ta-rikishi, .hit2 .ta-rikishi { animation: hop .14s ease-out; }
@keyframes hop { 40% { transform: translateY(-10%) rotate(2deg); } }
.ta-rope, .ta-hands { transform-origin: center; }
.hit .ta-rope, .hit .ta-hands { animation: yank .15s ease-out; }
.hit2 .ta-rope, .hit2 .ta-hands { animation: yank2 .15s ease-out; }
@keyframes yank { 40% { transform: translateY(14%); } }
@keyframes yank2 { 40% { transform: translateY(14%) rotate(-2deg); } }
.tap-pops { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.tpop {
  position: absolute; left: var(--x); top: var(--y);
  transform: translate(-50%, -50%) rotate(var(--r));
  font-size: 30px; font-weight: 900; color: #fff; white-space: nowrap;
  -webkit-text-stroke: 3px var(--on-neon); paint-order: stroke fill; text-shadow: 3px 3px 0 var(--on-neon);
  animation: tpop .7s ease-out forwards;
}
.tpop--minus { color: #ff4040; font: 900 52px/1 var(--font-latin); }
.tpop--ouch { color: var(--yellow); font-size: 34px; }
@keyframes tpop { 0% { transform: translate(-50%, -50%) rotate(var(--r)) scale(.6); opacity: 1; } 20% { transform: translate(-50%, -80%) rotate(var(--r)) scale(1.15); } 100% { transform: translate(-50%, -190%) rotate(var(--r)); opacity: 0; } }
.obstacles { position: absolute; inset: 0; pointer-events: none; }
.ob {
  position: absolute; left: 0; top: 0; width: var(--d); height: var(--d);
  transform: translate(var(--x), var(--y)) rotate(var(--rot));
  opacity: var(--o, 1);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .65), rgba(255, 255, 255, 0) 70%);
  filter: drop-shadow(4px 5px 0 rgba(0, 0, 0, .8));
  will-change: transform;
}
.ob svg { width: 100%; height: 100%; display: block; }
.ob.bonk svg { animation: bonk .3s ease-out; }
@keyframes bonk { 30% { transform: scale(1.3, .7); } }
.tap-msg {
  position: absolute; left: 0; right: 0; top: 34%; text-align: center; pointer-events: none;
  font-size: 54px; font-weight: 900; color: var(--yellow);
  -webkit-text-stroke: 4px var(--on-neon); paint-order: stroke fill; text-shadow: 5px 5px 0 var(--on-neon);
}
.tap-msg.flash { animation: beat .7s var(--ease-punch); }

.pview-result { align-items: center; text-align: center; justify-content: center; }
.pr-stamp { padding: 6px 30px; border: 6px solid var(--on-neon); border-radius: 18px; background: var(--yellow); color: var(--on-neon); font-size: 56px; font-weight: 900; transform: rotate(-4deg); box-shadow: 8px 8px 0 var(--on-neon); }
.pr-stamp[data-outcome="lose"] { background: #4a4d66; color: #fff; }
.pr-stamp[data-outcome="draw"] { background: var(--cyan); }
.pr-stamp.wait { visibility: hidden; }
.pr-stamp.pop { animation: winPop .6s var(--ease-punch); }
.pr-team { font-size: 20px; }
.pr-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.pr-stats div { padding: 8px 4px; border: 2px solid var(--line); border-radius: 12px; background: rgba(12, 12, 22, .85); }
.pr-stats dt { font-size: 12px; color: var(--text-dim); }
.pr-stats dd { font: 900 28px/1.2 var(--font-latin); }
.pr-rank { font-size: 17px; color: var(--yellow); }
.pr-scores { font-size: 14px; color: var(--text-dim); }
.pview-ended { align-items: center; justify-content: center; text-align: center; gap: 24px; }
.pe-msg { font-size: 20px; }

/* ---------- ダイアログ・お知らせ ---------- */
.dlg { max-width: min(520px, 92vw); padding: 0; border: 4px solid var(--on-neon); border-radius: 20px; background: #15162a; color: var(--text); box-shadow: 10px 10px 0 var(--yellow); }
.dlg::backdrop { background: rgba(0, 0, 0, .6); }
.dlg-body { display: flex; flex-direction: column; gap: 14px; padding: 22px; }
.dlg-title { font-size: 22px; font-weight: 900; }
.dlg-text { color: var(--text-dim); font-size: 15px; }
.dlg-text:empty { display: none; }
.dlg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 50; transform: translateX(-50%);
  max-width: min(640px, 92vw); padding: 10px 18px; border: 3px solid var(--on-neon); border-radius: 14px;
  background: var(--yellow); color: var(--on-neon); font-weight: 900; box-shadow: 5px 5px 0 var(--on-neon);
}

/* ---------- 動きを減らす ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
  .tape span { animation: none; }
}
