* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  background: #1b1d24;
  color: #f2f2f0;
  min-height: 100vh;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 24px 16px 60px; }

h1 { font-size: 22px; font-weight: 700; margin: 0 0 10px; color: #ffb27a; text-align: center; }
h2 { font-size: 19px; font-weight: 700; margin: 0 0 10px; color: #ffb27a; }
h3 { font-size: 14px; color: #ffb27a; margin: 14px 0 6px; }
p.lead { font-size: 13px; color: #9a9ba5; line-height: 1.7; margin: 0 0 18px; text-align: center; }
p.hint { font-size: 12px; color: #6a6b76; }
p.hint.center { text-align: center; }

.screen { display: none; }
.screen.active { display: block; }

.menu { display: flex; flex-direction: column; gap: 10px; max-width: 360px; margin: 0 auto; }

.btn {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-radius: 14px;
  background: #24262f;
  color: #f2f2f0;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,0.25);
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: linear-gradient(135deg, #ffb27a, #ff8a5c); color: #1b1d24; }
.btn-ghost { background: transparent; color: #9a9ba5; box-shadow: none; }

.help-box {
  max-width: 480px;
  margin: 16px auto 0;
  background: #24262f;
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 13px;
  color: #d3d4da;
  line-height: 1.7;
}
.help-box ul { margin: 0 0 6px; padding-left: 18px; }
.type-cycle { font-size: 14px; text-align: center; }

/* --- モンスター作成画面 --- */
#screen-create { max-width: 420px; margin: 0 auto; }
.file-btn {
  display: block;
  text-align: center;
  padding: 14px;
  border-radius: 14px;
  background: #24262f;
  color: #ffb27a;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 14px;
}
.file-btn input { display: none; }
#photoPreview {
  display: block;
  max-width: 100%;
  max-height: 220px;
  margin: 0 auto 14px;
  border-radius: 12px;
  object-fit: contain;
}
#createResult { margin-top: 18px; }
#monsterPreviewCanvas {
  display: block;
  margin: 0 auto;
  background: radial-gradient(ellipse at center, #2c3550 0%, #1b1d24 80%);
  border-radius: 16px;
}
.type-chip {
  display: block;
  width: fit-content;
  margin: 10px auto 16px;
  padding: 6px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
}
.stat-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 12px; color: #9a9ba5; }
.stat-row span { width: 64px; flex-shrink: 0; }
.stat-bar { flex: 1; height: 10px; border-radius: 6px; background: #24262f; overflow: hidden; }
.stat-fill { height: 100%; border-radius: 6px; }
.stat-fill.hp { background: #4caf50; }
.stat-fill.atk { background: #ff5a3c; }
.stat-fill.def { background: #3fa9ff; }
.stat-fill.spd { background: #ffd23f; }

#monsterNameInput {
  display: block;
  width: 100%;
  margin: 16px 0;
  padding: 12px 14px;
  border-radius: 10px;
  border: none;
  background: #24262f;
  color: #f2f2f0;
  font-size: 14px;
}
.row-buttons { display: flex; gap: 10px; }
.row-buttons .btn { width: auto; flex: 1; }

/* --- バトル画面 --- */
#screen-battle { max-width: 760px; }
.battle-hud { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.hud-side { flex: 1; }
.hud-side.right { text-align: right; }
.hud-name { font-size: 12px; color: #d3d4da; margin-bottom: 4px; }
.hud-stage { font-size: 12px; color: #ffb27a; font-weight: 700; white-space: nowrap; }
.hp-bar { height: 12px; border-radius: 6px; background: #24262f; overflow: hidden; }
.hp-fill { height: 100%; background: linear-gradient(90deg, #4caf50, #8bd66b); transition: width 120ms linear; }
.hp-fill.enemy { background: linear-gradient(90deg, #ff5a3c, #ff8a5c); }
.meter-bar { height: 7px; border-radius: 4px; background: #24262f; overflow: hidden; margin-top: 4px; }
.meter-fill { height: 100%; background: linear-gradient(90deg, #3fa9ff, #8b5fd6); width: 0%; transition: width 120ms linear; }

#battleCanvas {
  display: block;
  width: 100%;
  height: auto;
  max-width: 720px;
  margin: 0 auto;
  border-radius: 16px;
  background: #1b1d24;
  touch-action: none;
}

.touch-controls {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 14px;
  gap: 12px;
}
.dpad, .actions { display: flex; gap: 10px; }
.ctrl-btn {
  border: none;
  border-radius: 14px;
  background: #24262f;
  color: #f2f2f0;
  font-weight: 700;
  font-size: 14px;
  width: 64px;
  height: 56px;
  touch-action: none;
  user-select: none;
  box-shadow: 0 6px 14px rgba(0,0,0,0.3);
}
.ctrl-btn:active { transform: scale(0.94); }
.ctrl-btn.attack { background: linear-gradient(135deg, #ff8a5c, #ff5a3c); color: #1b1d24; width: 76px; height: 68px; }
.ctrl-btn.special { background: linear-gradient(135deg, #8b5fd6, #3fa9ff); color: #fff; }
.ctrl-btn.guard { background: #2c3550; }

@media (max-width: 480px) {
  .ctrl-btn { width: 56px; height: 50px; font-size: 12px; }
  .ctrl-btn.attack { width: 66px; height: 60px; }
}
