:root {
  --bg: #070b16;
  --panel: #0f1a2c;
  --line: #2c3a5c;
  --text: #e2e8f0;
  --muted: #8a9bb8;
  --cyan: #00f3ff;
  --pink: #ff3366;
  --yellow: #ffcc00;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

/* 上のHUD */
#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px 6px;
}
.core-card {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  font: 11px/1 ui-monospace, monospace;
}
.core-card.cyan { border-color: var(--cyan); color: var(--cyan); }
.core-card.pink { border-color: var(--pink); color: var(--pink); }
.bar { flex: 1; height: 8px; border-radius: 3px; background: #16233a; overflow: hidden; }
.cyan .fill { background: var(--cyan); }
.pink .fill { background: var(--pink); margin-left: auto; }
.fill { height: 100%; width: 100%; }
#timer {
  font: 700 18px/1 ui-monospace, monospace;
  color: #fff;
  min-width: 60px;
  text-align: center;
}

/* ミニマップ */
#minimap-wrap { padding: 0 10px 6px; }
#minimap {
  display: block;
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #050811;
  image-rendering: pixelated;
}

/* ゲーム画面 */
#view {
  position: relative;
  flex: 1;
  min-height: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
#game { display: block; width: 100%; height: 100%; }
#version {
  position: absolute;
  right: 6px;
  bottom: 4px;
  font-size: 10px;
  color: var(--muted);
  opacity: .7;
  pointer-events: none;
}

/* 手持ちのブロック数(左下) */
#hand {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(7, 11, 22, .75);
  font-size: 13px;
  font-weight: 700;
  color: #e2e8f0;
  pointer-events: none;
}
.hand-icon {
  width: 12px;
  height: 12px;
  background: #1a2238;
  border: 1px solid var(--cyan);
  box-shadow: 0 0 4px var(--cyan);
}
/* 操作の説明(上) */
#hint {
  position: absolute;
  left: 0;
  right: 0;
  top: 6px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  pointer-events: none;
}
/* 自分の体力(左上) */
#hp {
  position: absolute;
  left: 8px;
  top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(7, 11, 22, .75);
  font-size: 12px;
  font-weight: 700;
  color: #e2e8f0;
  pointer-events: none;
}
.hp-label { color: var(--cyan); }
.hp-bar { width: 90px; height: 8px; border-radius: 3px; background: #16233a; overflow: hidden; }
#hp-fill { height: 100%; width: 100%; background: var(--cyan); transition: width .15s; }
#hp-fill.mid { background: var(--yellow); }
#hp-fill.low { background: #ff3b3b; }
#hp-num { min-width: 24px; text-align: right; }

/* ダメージを受けたとき、画面のふちが赤く光る */
#hurt {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 40px rgba(255, 40, 60, .85);
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
}
#hurt.on { opacity: 1; transition: none; }

/* やられたとき */
#dead {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(40, 0, 10, .45);
  color: #ffd0d0;
  font-size: 15px;
  pointer-events: none;
}
#dead.show { display: flex; }
.dead-title { font-size: 28px; font-weight: 800; color: #ff3366; text-shadow: 0 0 10px #ff3366; }
#dead-count { font-size: 20px; font-weight: 800; color: #fff; }

/* 試合の結果 */
#result {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(3, 5, 12, .78);
  z-index: 20;
}
#result.show { display: flex; }
.result-box {
  width: min(320px, calc(100% - 32px));
  padding: 24px 18px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0b1020;
  text-align: center;
}
#result-title { font-size: 44px; font-weight: 900; letter-spacing: .06em; }
#result-title.win { color: var(--cyan); text-shadow: 0 0 16px var(--cyan); }
#result-title.lose { color: var(--pink); text-shadow: 0 0 16px var(--pink); }
#result-title.draw { color: var(--yellow); text-shadow: 0 0 16px var(--yellow); }
#result-reason { margin-top: 4px; font-size: 13px; color: var(--muted); }
.result-cores { display: flex; gap: 10px; margin: 18px 0; }
.rc { flex: 1; padding: 8px; border-radius: 8px; border: 1px solid; display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.rc b { font-size: 22px; }
.rc.cyan { border-color: var(--cyan); color: var(--cyan); }
.rc.pink { border-color: var(--pink); color: var(--pink); }
#again {
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 10px;
  background: var(--cyan);
  color: #070b16;
  font-size: 17px;
  font-weight: 800;
  font-family: inherit;
}

#change {
  width: 100%;
  height: 40px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: #e2e8f0;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
}

/* 試合の前の画面 */
#setup {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(3, 5, 12, .82);
  z-index: 21;
}
#setup.show { display: flex; }
.setup-box {
  width: min(340px, calc(100% - 32px));
  padding: 24px 18px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0b1020;
  text-align: center;
}
.setup-title {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: .08em;
  color: var(--cyan);
  text-shadow: 0 0 14px var(--cyan), 3px 0 0 rgba(255, 51, 102, .6);
}
.setup-sub { margin: 4px 0 14px; font-size: 13px; color: var(--muted); }
.setup-label { margin: 12px 0 6px; font-size: 12px; color: var(--muted); text-align: left; }
.choice { display: flex; gap: 8px; }
.choice button {
  flex: 1;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: #e2e8f0;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
}
.choice button.on { border: 2px solid var(--cyan); color: var(--cyan); background: rgba(0, 243, 255, .08); }
.setup-note { margin: 14px 0 12px; font-size: 11px; color: var(--muted); }
#start {
  width: 100%;
  height: 50px;
  border: 0;
  border-radius: 10px;
  background: var(--cyan);
  color: #070b16;
  font-size: 18px;
  font-weight: 800;
  font-family: inherit;
}

/* 最初の画面・みんなで遊ぶ・ロビー */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(3, 5, 12, .9);
  z-index: 22;
  overflow-y: auto;
  padding: 16px 0;
}
.screen.show { display: flex; }
.screen-title { font-size: 22px; font-weight: 900; color: var(--cyan); margin-bottom: 6px; }
.big-btn {
  display: block;
  width: 100%;
  height: 50px;
  margin-top: 14px;
  border: 0;
  border-radius: 10px;
  background: var(--cyan);
  color: #070b16;
  font-size: 17px;
  font-weight: 800;
  font-family: inherit;
}
.big-btn.outline { background: transparent; border: 2px solid var(--pink); color: var(--pink); }
.big-btn:disabled { opacity: .4; }
.mid-btn {
  height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: var(--pink);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  font-family: inherit;
}
.sub-btn {
  display: block;
  width: 100%;
  height: 40px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: #e2e8f0;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
}
.field {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #070b16;
  color: #fff;
  font-size: 18px;
  font-family: inherit;
}
.field:focus { outline: none; border-color: var(--cyan); }
.join-row { display: flex; gap: 8px; }
.join-row .field { flex: 1; letter-spacing: .3em; text-align: center; }
.or { margin: 14px 0 0; font-size: 12px; color: var(--muted); }
.msg { min-height: 18px; margin-top: 10px; font-size: 13px; color: #ff8a8a; }
.msg.ok { color: var(--cyan); }
.center { text-align: center; }
#lobby-code {
  font: 900 44px/1 ui-monospace, monospace;
  letter-spacing: .15em;
  color: #fff;
  text-shadow: 0 0 12px var(--cyan);
}
.lobby-box { padding-top: 16px; }
.lobby-info { margin-top: 10px; font-size: 13px; color: #e2e8f0; }
.teams { display: flex; gap: 8px; margin-top: 12px; text-align: left; }
.team-col { flex: 1; min-width: 0; padding: 8px; border: 1px solid; border-radius: 10px; }
.team-col.cyan { border-color: var(--cyan); }
.team-col.pink { border-color: var(--pink); }
.team-head { font-size: 13px; font-weight: 800; margin-bottom: 6px; }
.cyan .team-head { color: var(--cyan); }
.pink .team-head { color: var(--pink); }
.slot {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  height: 32px;
  margin-bottom: 4px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f1a2c;
  color: #e2e8f0;
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
}
.slot .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.slot.ai { color: var(--muted); border-style: dashed; background: transparent; }
.slot.me { border-color: #fff; }
.slot .tag { font-size: 10px; padding: 1px 4px; border-radius: 4px; background: var(--yellow); color: #070b16; font-weight: 800; }
.slot .tag.you { background: #fff; }
.slot .mv { color: var(--muted); font-size: 12px; }
.team-btn {
  width: 100%;
  height: 34px;
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
}
.team-btn:disabled { opacity: .35; }
.wait { margin-top: 14px; font-size: 14px; color: var(--yellow); }
#to-lobby, #to-title, #result-wait { display: none; }
#result.online #again, #result.online #change { display: none; }
#result.online.host #to-lobby, #result.online #to-title { display: block; }
#result.online:not(.host) #result-wait { display: block; }

/* タイマー: 残り30秒で赤く */
#timer.hurry { color: #ff3b3b; }

/* 一瞬出るお知らせ */
#tip {
  position: absolute;
  left: 50%;
  top: 30%;
  transform: translate(-50%, -50%);
  padding: 6px 12px;
  border-radius: 6px;
  background: rgba(7, 11, 22, .85);
  border: 1px solid #ff3b3b;
  color: #ffd0d0;
  font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}
#tip.show { opacity: 1; }

/* 操作部 */
#controls { padding: 8px 10px 10px; }
#items {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 6px;
}
.item {
  width: 64px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-family: inherit;
}
.item.active { border: 2px solid var(--cyan); color: var(--cyan); }
.item { position: relative; touch-action: manipulation; }
.badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--yellow, #ffcc00);
  color: #070b16;
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
}
.badge.empty { background: #3a4460; color: #8a9bb8; }

#sticks {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stick {
  width: 140px;
  height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  touch-action: none;
}
.stick-base {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--panel);
  border: 2px solid var(--line);
}
.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: #1a2a44;
  border: 2px solid var(--cyan);
  will-change: transform;
}
#stick-right .stick-knob { border-color: var(--pink); }
.stick.held .stick-base { border-color: var(--cyan); }
.stick-label { font-size: 11px; color: var(--muted); }

/* SHOT ボタン(v0.9): 押すと、いちばん近い敵へ自動で撃つ */
#shot {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 2px solid var(--pink);
  background: radial-gradient(circle at 40% 35%, #3a1426, #1a0a14 70%);
  color: var(--pink);
  font: 800 12px/1 ui-monospace, monospace;
  letter-spacing: 1px;
  box-shadow: 0 0 12px rgba(255, 51, 102, 0.35);
  touch-action: none;
}
#shot.on { background: var(--pink); color: #12060c; box-shadow: 0 0 18px rgba(255, 51, 102, 0.7); }

/* ダッシュのゲージ(左スティックのまわりの輪。へると短くなる。からっぽになると灰色) */
#dash-ring { --g: 100%; isolation: isolate; }
#dash-ring::before {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  z-index: -1;
  background: conic-gradient(var(--yellow) var(--g), rgba(255, 204, 0, 0.12) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  filter: drop-shadow(0 0 3px var(--yellow));
}
#dash-ring.tired::before { background: conic-gradient(#6b7699 var(--g), rgba(107, 118, 153, 0.15) 0); filter: none; }
#dash-ring.dashing::before { filter: drop-shadow(0 0 6px var(--yellow)); }

/* まだ使えない部品 */
.soon { opacity: .35; }

/* 横向きのときの案内 */
#rotate {
  display: none;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  font-size: 18px;
  z-index: 10;
}
@media (orientation: landscape) and (max-height: 500px) {
  #rotate { display: flex; }
}

/* iPhone(Safari)は「拡大しない」の設定を無視することがあるので、
   すべての部分に「ダブルタップ・ピンチで拡大しない」を指定する */
#app, #app * { touch-action: none; }
#rotate, #rotate * { touch-action: none; }
/* 画面の上に出る画面(最初の画面・ロビーなど)は、縦のスクロールだけできる */
.screen, .screen *, #setup, #setup *, #result, #result * { touch-action: pan-y; }

/* v0.8: 拾った銃・C4 は金色のふち */
.item.loot { border-color: #ffb020; color: #ffcc66; box-shadow: 0 0 8px rgba(255, 176, 32, 0.45); }
.item.loot.active { border: 2px solid #ffb020; color: #ffcc66; }
.item .badge[hidden] { display: none; }
/* 長い名前(ショットガン・マシンガン)が2行にならないように */
#gun-name { white-space: nowrap; letter-spacing: -0.5px; }
.item.loot #gun-name { font-size: 10.5px; }
/* シールドのゲージ(HP の下の細い金色のバー。シールドがあるときだけ) */
.hp-bars { display: flex; flex-direction: column; gap: 2px; }
.sh-bar { width: 90px; height: 3px; border-radius: 2px; background: #2a2210; overflow: hidden; visibility: hidden; }
.sh-bar.on { visibility: visible; box-shadow: 0 0 4px rgba(255, 176, 32, 0.6); }
#sh-fill { height: 100%; width: 0; background: #ffb020; transition: width .15s; }

/* 言語の切りかえ(最初の画面)とサイトへのリンク */
.lang-sw { display: flex; justify-content: center; gap: 6px; margin: 10px 0 14px; }
.lang-sw button { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 12px; font-family: inherit; }
.lang-sw button.on { background: var(--cyan); border-color: var(--cyan); color: #04121a; font-weight: 700; }
.mg-foot { margin: 18px 0 0; font-size: 13px; text-align: center; color: var(--muted); }
.mg-foot a { color: var(--muted); }
