/* フリボウル — 夜のボウリング場: 深紺 × ウッドアンバー × ネオンシアン/ピンク */
:root {
  --bg: #0a0c18;
  --panel: #141828;
  --line: #262c44;
  --text: #e8ecf6;
  --dim: #8b93ad;
  --wood: #c99a5b;
  --p0: #28c8ff;
  --p1: #ff4fa0;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans JP', sans-serif;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.screen { position: fixed; inset: 0; display: none; }
.screen.active { display: block; }

/* ---- ホーム ---- */
#screen-home, #screen-lobby {
  background:
    radial-gradient(ellipse 90% 50% at 50% -10%, #1d2440 0%, transparent 60%),
    var(--bg);
}
.home-inner {
  height: 100%;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 14px; padding: 24px; max-width: 380px; margin: 0 auto;
}
.logo { text-align: center; margin-bottom: 14px; }
.logo-pin { font-size: 52px; display: block; filter: drop-shadow(0 0 18px rgba(40,200,255,.5)); }
.logo h1 {
  font-family: 'Teko', 'Noto Sans JP', sans-serif;
  font-size: 64px; font-weight: 700; letter-spacing: .06em; line-height: 1;
  background: linear-gradient(180deg, #fff, var(--p0));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 32px rgba(40,200,255,.35);
}
.tagline { color: var(--dim); font-size: 13px; letter-spacing: .1em; }
input[type=text] {
  width: 100%; padding: 13px 16px; font-size: 16px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; outline: none;
  font-family: inherit;
}
input[type=text]:focus { border-color: var(--p0); }
.btn {
  width: 100%; padding: 14px; font-size: 16px; font-weight: 700;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
  font-family: inherit;
}
.btn.primary {
  background: linear-gradient(135deg, #10a8e0, #28c8ff);
  border: none; color: #041018;
  box-shadow: 0 4px 24px rgba(40,200,255,.35);
}
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .55; }
.join-row { display: flex; gap: 8px; width: 100%; }
.join-row input { flex: 1; text-transform: uppercase; letter-spacing: .3em; text-align: center; }
.join-row .btn { width: auto; padding: 14px 22px; }
.hint { color: var(--dim); font-size: 12px; text-align: center; line-height: 1.7; }

/* ---- ロビー ---- */
.lobby-label { color: var(--dim); letter-spacing: .2em; font-size: 12px; }
.room-code {
  font-family: 'Teko', sans-serif; font-size: 88px; font-weight: 700;
  letter-spacing: .18em; line-height: 1; color: var(--p0);
  text-shadow: 0 0 40px rgba(40,200,255,.5);
}
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--p0);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- ゲーム ---- */
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 8px;
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(180deg, rgba(6,8,16,.85), transparent);
  pointer-events: none;
}
#turn-status { font-size: 13px; font-weight: 700; flex: 1; }
#mini-score { display: flex; gap: 12px; font-family: 'Teko', sans-serif; font-size: 20px; letter-spacing: .04em; }
.c0 { color: var(--p0); }
.c1 { color: var(--p1); }
.icon-btn {
  pointer-events: auto;
  width: 40px; height: 40px; border-radius: 10px;
  background: rgba(20,24,40,.85); color: var(--text);
  border: 1px solid var(--line); font-size: 18px; cursor: pointer;
}
.icon-btn.small { width: 34px; height: 34px; font-size: 13px; }
.icon-btn.on { border-color: var(--p0); color: var(--p0); }

.watch-note {
  position: absolute; top: 42%; left: 0; right: 0; text-align: center;
  font-size: 15px; font-weight: 700; color: var(--dim);
  opacity: 0; transition: opacity .3s; pointer-events: none;
  text-shadow: 0 2px 8px #000;
}
.watch-note.on { opacity: 1; }

.controls {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 10px 14px calc(env(safe-area-inset-bottom, 0px) + 14px);
  display: none; flex-direction: column; gap: 10px;
  background: linear-gradient(0deg, rgba(6,8,16,.9), transparent);
}
.controls.on { display: flex; }
.aim-row { display: flex; align-items: center; gap: 8px; justify-content: center; }
.aim-help { font-size: 12px; color: var(--dim); }
.aim-help b { color: var(--text); font-family: 'Teko', sans-serif; font-size: 16px; }
#throw-btn {
  padding: 16px; border-radius: 16px; border: none; cursor: pointer;
  font-family: inherit; font-size: 18px; font-weight: 900; color: #041018;
  background: linear-gradient(135deg, #10a8e0, #28c8ff);
  box-shadow: 0 4px 28px rgba(40,200,255,.4);
  touch-action: none;
}
#throw-btn span { display: block; font-size: 11px; font-weight: 400; margin-top: 3px; opacity: .8; }
#throw-btn.holding {
  background: linear-gradient(135deg, #ff8a2a, #ffc02a);
  box-shadow: 0 4px 32px rgba(255,170,40,.55);
  animation: pulse 0.7s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.03); } }

/* ---- 投球方式切替 / 構えオーバーレイ ---- */
.mode-btn {
  pointer-events: auto;
  height: 34px; padding: 0 10px; border-radius: 10px;
  background: rgba(20,24,40,.85); color: var(--text);
  border: 1px solid var(--line); font-size: 11px; font-weight: 700; cursor: pointer;
  font-family: inherit; white-space: nowrap;
}
.arm-overlay {
  position: absolute; inset: 0; display: none; z-index: 14;
  flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: radial-gradient(ellipse 80% 60% at 50% 45%, rgba(16,168,224,.22), rgba(6,8,16,.82));
  touch-action: none;
}
.arm-overlay.on { display: flex; }
.arm-overlay.holding {
  background: radial-gradient(ellipse 80% 60% at 50% 45%, rgba(255,170,40,.28), rgba(6,8,16,.82));
}
.arm-text {
  font-size: 19px; font-weight: 900; text-align: center; line-height: 1.8;
  padding: 0 26px; text-shadow: 0 2px 12px #000; pointer-events: none;
}
.arm-text small { display: block; font-size: 12px; font-weight: 400; color: var(--dim); }
.arm-cancel {
  padding: 10px 26px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: rgba(20,24,40,.9); color: var(--dim);
  border: 1px solid var(--line); cursor: pointer; font-family: inherit;
}

/* ---- 結果演出 ---- */
.result {
  position: absolute; top: 30%; left: 0; right: 0; text-align: center;
  opacity: 0; transform: scale(.8); transition: all .25s cubic-bezier(.2,1.6,.4,1);
  pointer-events: none;
}
.result.on { opacity: 1; transform: scale(1); }
#result-main {
  font-family: 'Teko', sans-serif; font-size: 78px; font-weight: 700; line-height: 1;
  letter-spacing: .06em;
  background: linear-gradient(180deg, #fff, var(--p0));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 26px rgba(40,200,255,.6));
}
#result-sub { font-size: 15px; font-weight: 700; color: var(--dim); }

/* ---- スコア表 (オーバーヘッドモニター風) ---- */
.scorepanel {
  position: absolute; inset: 0; display: none;
  background: rgba(4,6,12,.72); backdrop-filter: blur(4px);
  z-index: 10;
}
.scorepanel.on { display: flex; align-items: center; justify-content: center; }
.scorepanel-inner {
  width: min(96vw, 720px); background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 14px;
  box-shadow: 0 0 60px rgba(40,200,255,.12), inset 0 0 40px rgba(0,0,0,.5);
}
.sheet { display: flex; align-items: stretch; gap: 6px; margin: 6px 0; }
.sheet.me .sheet-name::after { content: ' (あなた)'; font-size: 10px; color: var(--dim); }
.sheet-name {
  width: 86px; font-size: 12px; font-weight: 700;
  display: flex; align-items: center;
}
.frames { display: flex; flex: 1; gap: 2px; }
.frame {
  flex: 1; background: #0d101e; border: 1px solid var(--line); border-radius: 6px;
  padding: 2px; text-align: center; min-width: 0;
}
.frame.active { border-color: var(--p0); box-shadow: 0 0 10px rgba(40,200,255,.3); }
.frame:last-child { flex: 1.4; }
.fn { font-size: 9px; color: var(--dim); }
.marks {
  font-family: 'Teko', sans-serif; font-size: 17px; line-height: 1.1;
  display: flex; justify-content: center; gap: 2px; min-height: 18px;
}
.marks i { width: 1px; background: var(--line); }
.cum { font-family: 'Teko', sans-serif; font-size: 16px; color: var(--wood); min-height: 17px; }
.total {
  width: 52px; display: flex; align-items: center; justify-content: center;
  font-family: 'Teko', sans-serif; font-size: 30px; color: var(--text);
  background: #0d101e; border: 1px solid var(--line); border-radius: 6px;
}

/* ---- ゲームオーバー ---- */
.gameover {
  position: absolute; inset: 0; display: none;
  background: rgba(4,6,12,.8); z-index: 20;
  align-items: center; justify-content: center;
}
.gameover.on { display: flex; }
.gameover-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  padding: 28px 24px; text-align: center; width: min(88vw, 340px);
  display: flex; flex-direction: column; gap: 14px;
}
.gameover-card h2 {
  font-family: 'Teko', sans-serif; font-size: 44px; font-weight: 700; line-height: 1;
  color: var(--p0); letter-spacing: .1em;
}
.gameover-card p { font-size: 16px; font-weight: 700; }

/* ---- トースト ---- */
.toast {
  position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%) translateY(20px);
  background: rgba(20,24,40,.95); border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 999px; font-size: 13px; font-weight: 700;
  opacity: 0; transition: all .25s; z-index: 50; max-width: 88vw; text-align: center;
  pointer-events: none;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
