/* 令和の線ゲー - ネオン基調のUI */

:root {
  --bg: #05060d;
  --panel: rgba(14, 20, 40, 0.92);
  --panel-line: rgba(90, 200, 255, 0.28);
  --text: #e8f2ff;
  --text-dim: #8fa6c8;
  --accent: #3df0ff;
  --accent-2: #ff3ea5;
  --warn: #ffb03d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  /* スマホでの引っ張り更新・ダブルタップ拡大・長押し選択を止める */
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

#game { touch-action: none; }

#app {
  position: relative;
  width: 100%;
  height: 100%;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  pointer-events: auto;
  background: radial-gradient(ellipse at center, rgba(5, 8, 20, 0.72), rgba(3, 4, 10, 0.94));
  backdrop-filter: blur(3px);
  animation: fade-in 0.18s ease-out;
}

.screen.hidden { display: none; }

/*
 * 汎用の非表示。
 * これが無いと、ボタンなどに .hidden を付けても何も起きない
 * (要素ごとの .hidden 指定しかなかったため、実際に取り違えが起きた)。
 * .btn などの display 指定と同じ詳細度になるので、確実に勝たせる。
 */
.hidden { display: none !important; }
.screen.center { align-items: center; justify-content: center; }
.screen.scroll { align-items: flex-start; justify-content: center; overflow-y: auto; padding: 24px 16px; }

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---- タイトル ---- */

.title-block { text-align: center; }

.title-kicker {
  margin: 0 0 6px;
  letter-spacing: 0.42em;
  font-size: 12px;
  color: var(--accent);
  text-shadow: 0 0 14px rgba(61, 240, 255, 0.7);
}

.title-logo {
  margin: 0;
  font-size: clamp(48px, 9vw, 108px);
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow:
    0 0 12px rgba(61, 240, 255, 0.85),
    0 0 42px rgba(61, 240, 255, 0.45),
    0 6px 0 rgba(0, 0, 0, 0.4);
}

.title-logo span {
  color: var(--accent-2);
  text-shadow: 0 0 14px rgba(255, 62, 165, 0.9), 0 0 46px rgba(255, 62, 165, 0.5);
}

.title-sub {
  margin: 10px 0 30px;
  letter-spacing: 0.3em;
  color: var(--text-dim);
}

.title-hint {
  margin-top: 22px;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
}

/* ---- パネル ---- */

.panel {
  width: min(1120px, 100%);
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 16px;
  padding: 22px 26px 18px;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.7), inset 0 0 60px rgba(40, 90, 160, 0.08);
}

.panel.wide { width: min(1180px, 100%); }
.panel.narrow { width: min(420px, 100%); }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-head h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.12em;
}

.panel-foot {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.foot-buttons { display: flex; gap: 10px; margin-left: auto; flex-wrap: wrap; }

.section-title {
  margin: 22px 0 10px;
  font-size: 13px;
  letter-spacing: 0.24em;
  color: var(--accent);
}

.center-text { text-align: center; }
.hint { margin-top: 14px; text-align: center; font-size: 12px; color: var(--text-dim); }
.warning { margin: 0; color: var(--warn); font-size: 13px; min-height: 18px; }

.tag {
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(61, 240, 255, 0.12);
  border: 1px solid rgba(61, 240, 255, 0.4);
  font-size: 12px;
  letter-spacing: 0.1em;
}

/* ---- ボタン ---- */

.btn {
  appearance: none;
  border: 1px solid rgba(140, 200, 255, 0.35);
  background: rgba(30, 48, 88, 0.6);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 11px 22px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover { background: rgba(48, 76, 138, 0.75); box-shadow: 0 0 18px rgba(61, 240, 255, 0.25); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(180deg, #2ad3ff, #1178c8);
  border-color: #7fe9ff;
  color: #041022;
  box-shadow: 0 0 24px rgba(61, 240, 255, 0.4);
}
.btn-primary:hover { background: linear-gradient(180deg, #6ee4ff, #1a90e0); }

.btn-ghost { background: transparent; border-color: rgba(255, 255, 255, 0.16); color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }

.menu { display: flex; flex-direction: column; gap: 12px; width: min(320px, 80vw); margin: 0 auto; }

/* ---- プレイヤー設定 ---- */

.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
  gap: 14px;
}

.player-card {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.player-card.off { opacity: 0.45; }

.player-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.swatch {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  cursor: pointer;
  flex: 0 0 auto;
}

.player-label { font-weight: 800; letter-spacing: 0.16em; font-size: 12px; color: var(--text-dim); }

.seg { display: flex; gap: 4px; margin-left: auto; }

.seg button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 7px;
  cursor: pointer;
}

.seg button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #04121c;
}

.field { margin-top: 9px; }

.field label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.field input[type="text"],
.field select,
.match-field select,
.match-field input {
  width: 100%;
  background: rgba(6, 12, 26, 0.9);
  border: 1px solid rgba(140, 200, 255, 0.25);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
}

.field select:focus, .field input:focus { outline: 2px solid rgba(61, 240, 255, 0.5); }

.skill-desc {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-dim);
  min-height: 32px;
}

.skill-stats {
  display: flex;
  gap: 8px;
  font-size: 10px;
  color: var(--accent);
  letter-spacing: 0.06em;
  margin-top: 2px;
}

.match-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.match-field label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.range-row { display: flex; align-items: center; gap: 8px; }
.range-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.range-value { font-weight: 700; font-size: 13px; min-width: 46px; text-align: right; }

/* ---- 結果表 ---- */

.result-table { display: flex; flex-direction: column; gap: 8px; }

.result-row {
  display: grid;
  grid-template-columns: 54px 1.4fr repeat(6, minmax(52px, 0.7fr));
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border-left: 4px solid transparent;
  font-variant-numeric: tabular-nums;
}

.result-row.head {
  background: transparent;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--text-dim);
  padding: 0 14px;
  border-left-color: transparent;
}

.result-row.rank1 { background: rgba(255, 210, 87, 0.14); }

.result-rank { font-size: 22px; font-weight: 900; }
.result-name { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.result-name .cpu-tag {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-dim);
}
.result-cell { text-align: right; font-size: 14px; }
.result-cell.dim { color: var(--text-dim); font-size: 12px; }

.champion {
  text-align: center;
  padding: 18px 0 24px;
}

.champion .crown { font-size: 42px; }
.champion .name {
  font-size: 44px;
  font-weight: 900;
  letter-spacing: 0.06em;
  margin: 4px 0;
}
.champion .sub { color: var(--text-dim); letter-spacing: 0.2em; font-size: 12px; }

/* ---- あそびかた ---- */

.help-body { display: grid; gap: 18px; font-size: 13px; line-height: 1.75; }
.help-body h3 { margin: 0 0 6px; font-size: 14px; color: var(--accent); letter-spacing: 0.14em; }
.help-body ul { margin: 0; padding-left: 20px; color: var(--text-dim); }
.help-body li { margin-bottom: 4px; }
.help-body strong { color: var(--text); }

.skill-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; }
.skill-item {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
}
.skill-item .top { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.skill-item .kind {
  font-size: 9px;
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.1em;
}
.kind-attack { background: rgba(255, 61, 110, 0.2); color: #ff8aa5; }
.kind-defense { background: rgba(61, 240, 255, 0.16); color: #8ee9ff; }
.kind-mobility { background: rgba(255, 210, 87, 0.18); color: #ffd98a; }
.skill-item p { margin: 6px 0 0; font-size: 11px; color: var(--text-dim); line-height: 1.6; }

.key-table { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }
.key-item {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
}
.key-item b { color: var(--accent); }

/* ---- その他 ---- */

#pause-hint {
  position: absolute;
  right: 12px;
  bottom: 10px;
  font-size: 11px;
  color: rgba(160, 190, 220, 0.45);
  letter-spacing: 0.1em;
  pointer-events: none;
}

#pause-hint.hidden { display: none; }

#boot-error {
  position: absolute;
  left: 24px;
  top: 24px;
  right: 24px;
  padding: 18px 20px;
  border: 1px solid #ff5a5a;
  border-radius: 10px;
  background: rgba(30, 6, 10, 0.94);
  color: #ffb3b3;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  z-index: 100;
}

/* ---- タッチ操作 ---- */

#touch-layer {
  position: absolute;
  inset: 0;
  z-index: 20;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#touch-layer.hidden { display: none; }

.steer-hint {
  position: absolute;
  bottom: 0;
  width: 50%;
  height: 42%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: max(18px, env(safe-area-inset-bottom));
  font-size: 34px;
  color: rgba(180, 220, 255, 0.22);
  transition: color 0.08s ease, background 0.08s ease;
  pointer-events: none;
}

.steer-hint.left { left: 0; }
.steer-hint.right { right: 0; }

.steer-hint.active {
  color: rgba(120, 240, 255, 0.9);
  background: radial-gradient(ellipse at bottom, rgba(61, 240, 255, 0.16), transparent 70%);
}

#touch-skill {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 2px solid var(--skill-color, #3df0ff);
  background:
    linear-gradient(to top, rgba(61, 240, 255, 0.28) var(--skill-fill, 100%), rgba(10, 16, 32, 0.55) var(--skill-fill, 100%));
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font: inherit;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.6);
  transition: transform 0.06s ease, box-shadow 0.12s ease, opacity 0.12s ease;
  opacity: 0.5;
}

#touch-skill .icon { font-size: 30px; line-height: 1; }
#touch-skill .count { font-size: 10px; font-weight: 800; letter-spacing: 0.06em; }
#touch-skill.ready { opacity: 1; box-shadow: 0 0 26px var(--skill-color, #3df0ff); }
#touch-skill.pressed { transform: translateX(-50%) scale(0.9); }

#touch-pause {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(10, 16, 32, 0.6);
  color: rgba(220, 240, 255, 0.8);
  font-size: 16px;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

/* キーボード前提の案内はスマホでは出さない */
body.mobile .title-hint,
body.mobile #pause-hint,
body.mobile #screen-pause .hint { display: none; }

/* ---- 縦持ちの案内 ---- */

#rotate-prompt {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 6, 14, 0.96);
  text-align: center;
  padding: 24px;
}

#rotate-prompt.hidden { display: none; }
.rotate-inner { max-width: 320px; }
.rotate-icon {
  font-size: 56px;
  display: inline-block;
  animation: rotate-tilt 1.8s ease-in-out infinite;
}
#rotate-prompt h2 { margin: 12px 0 8px; font-size: 20px; letter-spacing: 0.1em; }
#rotate-prompt p { margin: 0 0 20px; color: var(--text-dim); font-size: 13px; line-height: 1.7; }

@keyframes rotate-tilt {
  0%, 45% { transform: rotate(0deg); }
  70%, 100% { transform: rotate(90deg); }
}

/* ---- 1人プレイ設定 ---- */

.solo-setup { display: grid; gap: 16px; }
.solo-setup.hidden { display: none; }
.player-grid.hidden { display: none; }

.solo-block {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
}

.solo-block h3 {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--accent);
}

.solo-row { display: flex; align-items: center; gap: 10px; }
.solo-row .field { margin-top: 0; flex: 1; }

.cpu-slots { display: grid; gap: 8px; margin-top: 10px; }
.cpu-slot { display: flex; align-items: center; gap: 8px; }
.cpu-slot .dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; }
.cpu-slot select { flex: 1; }

/* ---- オンライン対戦 ---- */

.online-block {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
  margin-bottom: 14px;
}

.online-block h3 {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--accent);
}

.online-block .hint { margin-top: 0; margin-bottom: 10px; text-align: left; }
.online-block .btn { width: 100%; }

.room-code-block { text-align: center; margin-bottom: 16px; }
.room-code-block .hint { margin-top: 0; }

.room-code {
  margin: 6px 0 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.35em;
  /* 伝えるときに読み違えないよう、字面をはっきりさせる */
  text-indent: 0.35em;
  color: var(--accent);
  text-shadow: 0 0 18px currentColor;
}

.lobby-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.lobby-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}

/* 入れなかったことは見落とされると困るので、はっきり出す */
.warning.alert {
  color: #ffd2d2;
  background: rgba(190, 40, 60, 0.22);
  border: 1px solid rgba(255, 120, 140, 0.55);
  border-radius: 10px;
  padding: 10px 14px;
  text-align: left;
  line-height: 1.6;
}

@keyframes alert-flash {
  0% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
  100% { transform: translateX(0); }
}

.warning.alert.alert-flash { animation: alert-flash 0.32s ease; }

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  cursor: pointer;
}

.check-row input { width: 16px; height: 16px; }

.lobby-name { font-weight: 600; }
.lobby-skill { color: var(--text-dim); font-size: 12px; margin-left: auto; }
.lobby-row .tag { margin-left: 6px; }

/* 接続状態。プレイ中に相手待ちで止まっていることを知らせる */
#net-status {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(10, 13, 24, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 0.08em;
  pointer-events: none;
  z-index: 30;
}

#net-status.hidden { display: none; }

/* ---- 小さい画面向けの調整 ---- */

@media (max-width: 720px) {
  .result-row { grid-template-columns: 44px 1fr repeat(3, minmax(44px, 0.7fr)); font-size: 12px; }
  .result-row .hide-sm { display: none; }
  .panel { padding: 16px 14px 14px; border-radius: 12px; }
  .panel-head h2 { font-size: 18px; }
  .screen.scroll { padding: 12px 8px; }
  .menu { width: min(300px, 86vw); }
  .btn { padding: 13px 18px; }
  .foot-buttons { width: 100%; }
  .foot-buttons .btn { flex: 1; }
  #pause-hint { display: none; }
  .title-sub { margin-bottom: 20px; }
  .result-cell { font-size: 12px; }
  .result-rank { font-size: 18px; }
}

/* 横持ちのスマホは高さが足りないので、タイトルを詰める */
@media (max-height: 480px) {
  .title-logo { font-size: clamp(34px, 11vh, 64px); }
  .title-sub { margin: 6px 0 14px; font-size: 12px; }
  .title-kicker { font-size: 10px; }
  .btn { padding: 9px 18px; }
  .menu { gap: 8px; }
  .title-hint { margin-top: 12px; }
  .screen.scroll { padding: 8px; }
}
