/* ============================================================
   MINEWORLD — 深夜の発掘レーダー
   ダークインディゴの地層 × アンバーの探照光 × ピクセル和文
   ============================================================ */
:root {
  --ground:   #0b0e17;   /* 最深部 */
  --ground-2: #111527;   /* 地層 */
  --panel:    #151a2e;
  --line:     #232a45;
  --fog:      #1b2136;   /* 未開示タイル */
  --floor:    #0e1120;   /* 開示済みフロア */
  --amber:    #ffb627;   /* 探照光・アクセント */
  --amber-dim:#8f6a1f;
  --danger:   #ff4d3d;
  --text:     #d8dcec;
  --text-dim: #7d86a8;
  --font-px:  'DotGothic16', monospace;
  --font-body:'Zen Kaku Gothic New', sans-serif;
}

/* 中・韓はDotGothic16/Zen Kakuにグリフが無い＝システムフォントへフォールバック */
html[lang="zh"] {
  --font-px:  'DotGothic16', 'Microsoft YaHei', 'PingFang SC', monospace;
  --font-body:'Zen Kaku Gothic New', 'Microsoft YaHei', 'PingFang SC', sans-serif;
}
html[lang="ko"] {
  --font-px:  'DotGothic16', 'Malgun Gothic', 'Apple SD Gothic Neo', monospace;
  --font-body:'Zen Kaku Gothic New', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--ground);
  color: var(--text);
  font-family: var(--font-body);
  overflow-x: hidden;
}

/* ================= ゲーム画面 ================= */
#stage {
  position: relative;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--ground);
}
#board {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
#board.dragging { cursor: grabbing; }
/* 画面周縁の暗がり＝レーダー画面の空気感 */
#stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(5,7,13,.55) 100%);
}
#stage > *:not(#board) { z-index: 1; }

/* --- HUD 上部 --- */
#hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 18px;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(11,14,23,.85), transparent);
}
#brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.brand-mark { color: var(--amber); font-size: 14px; }
#brand h1 {
  font-family: var(--font-px);
  font-size: clamp(18px, 3.4vw, 26px);
  letter-spacing: .12em;
  color: var(--amber);
  text-shadow: 0 0 18px rgba(255,182,39,.45);
  font-weight: 400;
}
.proto-tag {
  font-family: var(--font-px);
  font-size: 10px;
  color: var(--ground);
  background: var(--amber);
  padding: 2px 6px;
  letter-spacing: .1em;
  align-self: center;
  white-space: nowrap;          /* 「SHARED WORLD」が2行に折れてHUDを押し広げるのを防ぐ */
}
#stats { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.chip {
  font-family: var(--font-px);
  font-size: 13px;
  background: rgba(21,26,46,.82);
  border: 1px solid var(--line);
  padding: 5px 10px;
  border-radius: 3px;
  color: var(--text-dim);
  white-space: nowrap;
}
.chip b { color: var(--text); font-weight: 400; margin-left: 2px; }
.chip.coord b { color: var(--amber); }
.chip.online { border-color: var(--amber-dim); }
.chip.online b { color: var(--amber); }
.chip[hidden] { display: none; }

/* --- 他プレイヤーの爆発に駆けつけるバナー --- */
#help-banner {
  position: absolute;
  left: 50%;
  top: 74px;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  padding: 12px 22px 14px;
  background: rgba(17,21,39,.96);
  border: 1px solid var(--danger);
  border-radius: 8px;
  box-shadow: 0 0 26px rgba(255,77,61,.28);
  animation: popIn2 .25s ease-out;
  max-width: 92vw;
}
#help-banner[hidden] { display: none; }
@keyframes popIn2 { from { opacity: 0; transform: translateX(-50%) translateY(-8px); } }
.help-text { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 88vw; }
.help-text b { font-family: var(--font-px); color: var(--danger); }
#help-bar {
  width: min(260px, 70vw);
  height: 8px;
  background: rgba(11,14,23,.9);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
#help-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--danger), var(--amber));
  transition: width .12s ease-out;
}
#help-btn {
  font-family: var(--font-px);
  font-size: 14px;
  letter-spacing: .06em;
  color: var(--ground);
  background: var(--amber);
  border: none;
  border-radius: 5px;
  padding: 8px 22px;
  cursor: pointer;
  touch-action: manipulation;
}
#help-btn:active { transform: scale(.95); }

/* --- HUD 右側ボタン --- */
#hud-side {
  position: absolute;
  right: 14px;
  bottom: 90px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#hud-side button {
  width: 44px; height: 44px;      /* WCAG 2.5.5(AAA) の 44px。モバイル主体なので目標値を採る */
  font-family: var(--font-px);
  font-size: 18px;
  color: var(--text);
  background: rgba(21,26,46,.88);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
#hud-side button:hover { border-color: var(--amber); color: var(--amber); }

/* --- 操作ヒント --- */
#hint {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(20px);
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(11,14,23,.85);
  border: 1px solid var(--line);
  padding: 8px 16px;
  border-radius: 20px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .6s, transform .6s;
  pointer-events: none;
  max-width: 94vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
#hint.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#hint .k {
  font-family: var(--font-px);
  color: var(--amber);
  margin-right: 3px;
}

/* --- 死亡オーバーレイ --- */
#death-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(255,77,61,.16), rgba(11,14,23,.88) 75%);
  animation: deathIn .25s ease-out;
  z-index: 5;
}
#death-overlay[hidden] { display: none; }
@keyframes deathIn { from { opacity: 0; } to { opacity: 1; } }
.death-box { text-align: center; }
.death-title {
  font-family: var(--font-px);
  font-size: clamp(26px, 6vw, 44px);
  color: var(--danger);
  text-shadow: 0 0 30px rgba(255,77,61,.6);
  animation: shake .4s ease-out;
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}
.death-sub { color: var(--text-dim); margin-top: 10px; font-size: 14px; }
.death-count {
  font-family: var(--font-px);
  margin-top: 18px;
  color: var(--text);
  font-size: 16px;
}
.death-count b { color: var(--amber); font-size: 26px; font-weight: 400; }

/* --- 鎮火（救助）バー --- */
.rescue-label {
  font-family: var(--font-px);
  margin-top: 22px;
  font-size: 14px;
  color: var(--amber);
  letter-spacing: .08em;
  animation: rescuePulse 0.8s ease-in-out infinite;
}
@keyframes rescuePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}
#rescue-bar {
  width: min(320px, 70vw);
  height: 14px;
  margin: 10px auto 0;
  background: rgba(21,26,46,.9);
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}
#rescue-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--danger), var(--amber));
  transition: width .12s ease-out;
}

/* --- ポップアップ通知（共鳴・解体・鎮火） --- */
#popup {
  position: absolute;
  left: 50%;
  top: 26%;                       /* 救助バナー（上部）と重ならない位置 */
  transform: translateX(-50%);
  font-family: var(--font-px);
  font-size: clamp(16px, 3vw, 24px);
  letter-spacing: .1em;
  color: var(--amber);
  text-shadow: 0 0 22px rgba(255,182,39,.55);
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
  z-index: 4;
}
#popup.pop { animation: popIn 2.6s ease-out forwards; }
#popup.green { color: #9bc53d; text-shadow: 0 0 22px rgba(155,197,61,.55); }
#popup.violet { color: #b98ef0; text-shadow: 0 0 22px rgba(185,142,240,.55); }

/* --- 標（サイン）メニュー・言語メニュー --- */
#sign-menu,
#lang-menu {
  position: fixed;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(17,21,39,.97);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
#sign-menu[hidden], #lang-menu[hidden] { display: none; }
#lang-menu {
  position: absolute;
  right: 64px;
  bottom: 90px;
  z-index: 40;
}
#lang-menu button.active { color: var(--amber); }
#sign-menu button,
#lang-menu button {
  min-height: 44px;
  font-family: var(--font-body);
  font-size: 13px;
  text-align: left;
  color: var(--text);
  background: none;
  border: none;
  border-radius: 4px;
  padding: 8px 12px;
  cursor: pointer;
  white-space: nowrap;
}
#sign-menu button:hover,
#lang-menu button:hover { background: rgba(255,182,39,.14); color: var(--amber); }
@keyframes popIn {
  0%   { opacity: 0; transform: translateX(-50%) translateY(14px) scale(.92); }
  10%  { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.04); }
  16%  { transform: translateX(-50%) scale(1); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* --- スクロール誘導 --- */
#scroll-cue {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  padding: 4px 14px 6px;
  font-family: var(--font-px);
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--text-dim);
  text-decoration: none;
  background: rgba(11,14,23,.7);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  transition: color .15s;
}
#scroll-cue:hover { color: var(--amber); }

/* ================= 情報コンテンツ帯 ================= */
#info {
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 20px 40px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 26px 28px;
  margin-bottom: 28px;
}
.panel h2 {
  font-family: var(--font-px);
  font-weight: 400;
  font-size: 18px;
  letter-spacing: .08em;
  color: var(--amber);
  margin-bottom: 14px;
}
.panel p { font-size: 14px; line-height: 1.9; color: var(--text); margin-bottom: 10px; }
.panel ul { list-style: none; margin: 10px 0; }
.panel li {
  font-size: 14px;
  line-height: 1.9;
  padding-left: 18px;
  position: relative;
  color: var(--text);
}
.panel li::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: var(--amber-dim);
}
.panel b { color: var(--amber); font-weight: 700; }
.panel .note { font-size: 12px; color: var(--text-dim); }

/* --- 記録 --- */
#record-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px;
  margin: 14px 0 20px;
}
.rec {
  background: var(--ground-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 16px 8px;
  text-align: center;
}
.rec b {
  display: block;
  font-family: var(--font-px);
  font-size: 24px;
  font-weight: 400;
  color: var(--text);
}
.rec span { font-size: 11px; color: var(--text-dim); }
.rec-actions { display: flex; gap: 10px; flex-wrap: wrap; }
button.danger,
button.share {
  font-family: var(--font-body);
  font-size: 12px;
  min-height: 44px;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 20px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
button.danger:hover { color: var(--danger); border-color: var(--danger); }
button.share { color: var(--amber); border-color: var(--amber-dim); }
button.share:hover { border-color: var(--amber); }

/* --- 広告プレースホルダ（ゲーム画面外・高さ予約でCLSゼロ） --- */
.ad-slot {
  min-height: 120px;
  margin: 0 0 28px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ad-slot span {
  font-family: var(--font-px);
  font-size: 11px;
  letter-spacing: .15em;
  color: #3a4262;
}

footer {
  text-align: center;
  padding: 20px 0 10px;
  font-size: 11px;
  color: var(--text-dim);
}
footer p { max-width: 640px; margin: 0 auto; line-height: 1.8; }
.foot-nav {
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.foot-nav a {
  color: var(--text-dim);
  font-size: 12px;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding: 4px 2px;
  transition: color .15s, border-color .15s;
}
.foot-nav a:hover { color: var(--amber); border-color: var(--amber-dim); }

/* ================= 法務ページ（privacy / terms） ================= */
.legal-body { background: var(--ground); }
#legal {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}
.legal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.legal-brand {
  font-family: var(--font-px);
  font-size: 18px;
  letter-spacing: .1em;
  color: var(--amber);
  text-decoration: none;
}
.legal-brand .brand-mark { font-size: 12px; }
#lang-inline { display: flex; gap: 4px; flex-wrap: wrap; }
#lang-inline button {
  font-family: var(--font-body);
  font-size: 12px;
  min-height: 44px;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 14px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
#lang-inline button:hover { color: var(--amber); border-color: var(--amber-dim); }
#lang-inline button.active { color: var(--amber); border-color: var(--amber); }
#legal h1 {
  font-family: var(--font-px);
  font-weight: 400;
  font-size: clamp(20px, 4vw, 28px);
  letter-spacing: .06em;
  color: var(--text);
  margin: 26px 0 20px;
}
#legal .panel h2 {
  font-size: 15px;
  margin-top: 24px;
}
#legal .panel h2:first-child { margin-top: 0; }
#legal .panel p { font-size: 14px; line-height: 1.95; }
#legal .updated {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-dim);
}
#legal .foot-nav { margin-top: 26px; }

@media (max-width: 560px) {
  #hud-top { padding: 10px 12px; }
  .chip { font-size: 11px; padding: 4px 7px; }
  .chip.coord, .chip.sec { display: none; }
  /* 狭幅では接続状態は 👥 チップが示すので、バッジは畳んで盤面の視界を優先する */
  .proto-tag { display: none; }
  #help-banner { top: 66px; padding: 8px 12px; }
  .help-text { font-size: 12px; }
  #hud-side { bottom: 110px; right: 10px; }
  .panel { padding: 20px 18px; }
  #record-grid { grid-template-columns: repeat(2, 1fr); }
}
