/* ============================================================
   テーマ変数(黒ベース + シアンアクセント + 1P青/2P赤)
   ============================================================ */
:root {
  --bg-top:    #12161c;
  --bg-bottom: #05070a;
  --panel:     #171e27;
  --panel-2:   #1e2733;
  --line:      #2a3543;
  --ink:       #e8edf2;
  --ink-dim:   #92a3b5;

  --cyan:      #4fd1e0;
  --cyan-soft: rgba(79, 209, 224, 0.35);

  --p1:        #6fa8dc;
  --p1-deep:   #3d5a80;
  --p1-glow:   rgba(111, 168, 220, 0.45);

  --p2:        #e06666;
  --p2-deep:   #8a3a3a;
  --p2-glow:   rgba(224, 102, 102, 0.45);

  --ok:        #6ac36a;
  --warn:      #e0c341;
  --danger:    #e06666;

  --radius:    10px;
  --shadow:    0 6px 20px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

body {
  font-family: "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  color: var(--ink);
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(1000px 440px at 50% -140px, rgba(79,209,224,0.10), transparent 70%),
    linear-gradient(170deg, var(--bg-top), var(--bg-bottom) 60%, #000);
  background-attachment: fixed;
}

#app { width: 720px; max-width: 100%; }

.screen.hidden, .phase.hidden, .hidden { display: none; }

/* --- タイトル --- */
h1 {
  font-size: 22px;
  text-align: center;
  letter-spacing: 0.08em;
  margin: 6px 0 14px;
  padding-bottom: 10px;
  position: relative;
  text-shadow: 0 0 14px var(--cyan-soft);
}
h1::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 180px;
  height: 1px;
  transform: translateX(-50%);
  border-radius: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  box-shadow: 0 0 8px var(--cyan);
}
h2 { font-size: 16px; margin: 4px 0; letter-spacing: 0.04em; }
.hint { font-size: 13px; color: var(--ink-dim); text-align: center; line-height: 1.6; }

/* ============================================================
   セットアップ(1P青 / 2P赤 の色分け)
   ============================================================ */
.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.setup-box {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-top: 3px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.2s;
}
.setup-box:hover { transform: translateY(-2px); }

.setup-box:nth-child(1) {
  border-top-color: var(--p1);
  box-shadow: var(--shadow), inset 0 0 0 9999px rgba(111,168,220,0.03);
}
.setup-box:nth-child(1):hover { box-shadow: 0 8px 24px var(--p1-glow); }
.setup-box:nth-child(1) h2 { color: var(--p1); }

.setup-box:nth-child(2) {
  border-top-color: var(--p2);
  box-shadow: var(--shadow), inset 0 0 0 9999px rgba(224,102,102,0.03);
}
.setup-box:nth-child(2):hover { box-shadow: 0 8px 24px var(--p2-glow); }
.setup-box:nth-child(2) h2 { color: var(--p2); }

.setup-box label { display: block; font-size: 12px; margin: 8px 0 4px; color: var(--ink-dim); }
.setup-box input[type="text"] {
  width: 100%;
  font-size: 13px;
  padding: 6px 8px;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.setup-box input[type="text"]:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 8px var(--cyan-soft);
}
.setup-box input[type="file"] {
  width: 100%;
  font-size: 12px;
  color: var(--ink-dim);
}
.setup-box input[type="file"]::file-selector-button {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 10px;
  margin-right: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.setup-box input[type="file"]::file-selector-button:hover {
  border-color: var(--cyan);
  background: var(--panel-2);
}

.preview { margin-top: 10px; font-size: 12px; color: var(--ok); min-height: 20px; line-height: 1.5; }
.preview img { max-width: 60px; display: block; margin-top: 6px; border-radius: 6px; }

.sample { margin: 14px 0; font-size: 12px; color: var(--ink-dim); }
.sample summary { cursor: pointer; padding: 4px 0; }
.sample pre {
  background: #0a0e13;
  border: 1px solid var(--line);
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  color: #cfe3ea;
}
.error { color: #f0a0a0; font-size: 13px; margin-top: 8px; white-space: pre-line; }

/* ============================================================
   バトル画面
   ============================================================ */
.field {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border-radius: var(--radius);
  padding: 14px;
  margin: 12px 0;
  position: relative;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.field.enemy {
  border-left: 4px solid var(--p2);
  box-shadow: var(--shadow), inset 3px 0 12px -6px var(--p2-glow);
}
.field.ally {
  border-left: 4px solid var(--p1);
  box-shadow: var(--shadow), inset 3px 0 12px -6px var(--p1-glow);
}

.sprite {
  position: absolute; top: 14px;
  width: 64px; height: 64px; object-fit: contain;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.5));
}
/* 敵(2P)=右にスプライト / 味方(1P)=左にスプライト */
.field.enemy .sprite { right: 14px; }
.field.ally  .sprite { left: 18px; }

/* スプライトぶんの余白を確保して重なりを防ぐ(左右で切替) */
.field.enemy .poke-info,
.field.enemy .hp-text { padding-right: 90px; padding-left: 0; }
.field.ally  .poke-info,
.field.ally  .hp-text { padding-left: 90px; padding-right: 0; }

.poke-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.name { font-weight: bold; font-size: 16px; letter-spacing: 0.03em; }

/* --- タイプバッジ --- */
.types { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.type-badge {
  font-size: 11px;
  font-weight: bold;
  color: #fff;
  padding: 2px 9px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15), 0 1px 3px rgba(0,0,0,0.4);
  text-shadow: 0 1px 1px rgba(0,0,0,0.35);
}

.hp-bar {
  height: 12px;
  background: #0d1219;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.6);
}
/* HPバーはスプライトぶんの外側マージンで避ける(左右で切替) */
.field.enemy .hp-bar { margin-right: 90px; margin-left: 0; }
.field.ally  .hp-bar { margin-left: 90px; margin-right: 0; }
.hp-fill { height: 100%; width: 100%; background: var(--ok); transition: width 0.4s, background 0.4s; }
.hp-text { font-size: 12px; text-align: right; margin-top: 4px; color: var(--ink-dim); }

/* --- ターンバナー(プレイヤーカラーで切替) --- */
.turn-banner {
  text-align: center;
  font-weight: bold;
  letter-spacing: 0.05em;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 10px;
  background: linear-gradient(90deg, var(--p1-deep), var(--p1));
  box-shadow: 0 0 16px var(--p1-glow);
  transition: background 0.25s, box-shadow 0.25s;
}
.turn-banner.p1 {
  background: linear-gradient(90deg, var(--p1-deep), var(--p1));
  box-shadow: 0 0 16px var(--p1-glow);
}
.turn-banner.p2 {
  background: linear-gradient(90deg, var(--p2-deep), var(--p2));
  box-shadow: 0 0 16px var(--p2-glow);
}

/* --- 技ボタン(タイプ色で全体を塗る) --- */
.moves { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.moves button {
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  text-align: left;
  /* 下の暗いレイヤーを重ねて、タイプ背景色でも文字を読めるように */
  background-image: linear-gradient(rgba(0,0,0,0.32), rgba(0,0,0,0.5));
  transition: transform 0.12s, box-shadow 0.2s, filter 0.15s;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.moves button:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.12);
  box-shadow: 0 0 16px var(--cyan-soft);
}
.moves button:disabled { opacity: 0.5; cursor: not-allowed; }
.move-type { font-size: 11px; display: block; margin-top: 3px; font-weight: normal; opacity: 0.95; }

/* --- 受け渡し画面 --- */
#handoff-phase { text-align: center; padding: 36px 0; }
.handoff-msg {
  font-size: 18px; font-weight: bold; margin-bottom: 24px; line-height: 1.7;
  text-shadow: 0 0 12px var(--cyan-soft);
}

/* --- 共通ボタン --- */
#handoff-btn, #next-btn, #reset-btn, #start-btn {
  padding: 11px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--p1), var(--p1-deep));
  color: #fff;
  cursor: pointer;
  font-size: 15px;
  letter-spacing: 0.04em;
  margin: 6px 0;
  transition: transform 0.12s, box-shadow 0.2s, border-color 0.2s;
}
#handoff-btn:hover, #next-btn:hover, #reset-btn:hover, #start-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--cyan);
  box-shadow: 0 0 18px var(--cyan-soft);
}

#start-btn {
  display: block; width: 100%; margin: 16px 0;
  background: linear-gradient(90deg, var(--p1-deep), var(--p2-deep));
  font-weight: bold;
  letter-spacing: 0.14em;
  text-shadow: 0 0 10px rgba(0,0,0,0.4);
}
#start-btn:disabled {
  background: #3a4453;
  color: var(--ink-dim);
  cursor: not-allowed;
  opacity: 0.7;
  border-color: var(--line);
}

#reset-btn {
  background: linear-gradient(180deg, #55606e, #3f4855);
}

/* --- ログ --- */
.log {
  background: #0a0e13;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  height: 150px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.7;
  margin-top: 12px;
  box-shadow: inset 0 0 12px rgba(0,0,0,0.4);
}
.log div { border-bottom: 1px solid #171f29; padding: 3px 0; }
.log div:last-child { border-bottom: none; }

/* ============================================================
   タイプ別カラー(バッジ・技ボタン共通)
   ============================================================ */
.t-ノーマル   { background:#9099a1; }
.t-ほのお     { background:#ff7b3a; }
.t-みず       { background:#3a97ff; }
.t-でんき     { background:#f2c700; color:#fff; }
.t-くさ       { background:#4caf50; }
.t-こおり     { background:#57c6d4; }
.t-かくとう   { background:#d63b3b; }
.t-どく       { background:#9b52c4; }
.t-じめん     { background:#d4a13a; }
.t-ひこう     { background:#8fa9f0; }
.t-エスパー   { background:#ff5f8f; }
.t-むし       { background:#94b12a; }
.t-いわ       { background:#b8a038; }
.t-ゴースト   { background:#5a5aa0; }
.t-ドラゴン   { background:#5b45d6; }
.t-あく       { background:#5a5049; }
.t-はがね     { background:#7f9aa8; }
.t-フェアリー { background:#f08ad0; }
