:root {
  --bg: #0f1320;
  --panel: #1a2030;
  --text: #e9edf6;
  --muted: #8b96ad;
  --atk: #eb5757;
  --def: #56a8f5;
  --sp: #c084fc;
  --hp: #6fcf97;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(120% 100% at 50% 0%, #1a2236 0%, var(--bg) 65%);
  color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  display: flex; justify-content: center;
}
.wrap { width: 100%; max-width: 480px; padding: 24px 16px 40px; }

.screen { animation: fadeIn .35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

h1 { margin: 0; font-size: 2rem; letter-spacing: .06em; text-align: center; }
h2 { margin: 0 0 4px; font-size: 1.4rem; text-align: center; }
h3 { margin: 0 0 8px; font-size: .82rem; color: var(--muted); letter-spacing: .08em; }
.sub { color: var(--muted); margin: 8px 0 0; font-size: .9rem; text-align: center; line-height: 1.6; }

/* ホーム */
.home { text-align: center; padding-top: 40px; }
.home-emoji { font-size: 4.5rem; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-10px) rotate(6deg); } }

.big-btn {
  display: block; margin: 28px auto 0;
  background: linear-gradient(180deg, #6fcf97, #4bbf7a); color: #0c2018;
  border: none; border-radius: 12px; padding: 14px 36px;
  font-size: 1.05rem; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 18px rgba(79, 191, 122, .3);
}
.big-btn:disabled { background: #2a3346; color: var(--muted); box-shadow: none; cursor: not-allowed; }
.big-btn:not(:disabled):active { transform: scale(.96); }
.text-btn {
  display: block; margin: 14px auto 0; background: none; border: none;
  color: var(--muted); font-size: .85rem; cursor: pointer; text-decoration: underline;
}

/* アバター選択 */
.select { text-align: center; padding-top: 20px; }
.avatar-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin: 20px 0 4px;
}
.avatar-grid button {
  aspect-ratio: 1; font-size: 2rem; background: var(--panel);
  border: 2px solid #2a3346; border-radius: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s, border-color .15s;
}
.avatar-grid button:hover { transform: translateY(-3px); }
.avatar-grid button.sel { border-color: var(--hp); background: #233; transform: translateY(-3px); box-shadow: 0 0 0 3px rgba(111,207,151,.25); }

/* バトル: アリーナ */
.arena {
  background: var(--panel); border-radius: 16px; padding: 16px;
  margin: 6px 0 14px; display: flex; flex-direction: column; gap: 10px;
}
.vs { text-align: center; font-weight: 800; color: var(--muted); font-size: .78rem; letter-spacing: .2em; }
.fighter { display: flex; align-items: center; gap: 12px; }
.ava {
  font-size: 2.4rem; width: 56px; height: 56px; flex: 0 0 56px;
  display: flex; align-items: center; justify-content: center;
  background: #11151f; border-radius: 14px;
}
.finfo { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.who { font-weight: 700; font-size: .92rem; }
.fighter.cpu .who { color: var(--atk); }
.fighter.you .who { color: var(--hp); }
.hpbar { height: 14px; background: #11151f; border-radius: 8px; overflow: hidden; }
.hpfill { height: 100%; width: 100%; background: linear-gradient(90deg, #6fcf97, #4bbf7a); transition: width .4s ease; }
.fighter.cpu .hpfill { background: linear-gradient(90deg, #eb5757, #c43d3d); }
.hpnum { font-size: .8rem; color: var(--muted); }
.shield { color: var(--def); font-weight: 700; margin-left: 4px; }

/* ヒット演出 */
.fighter.hit { animation: shake .4s; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-7px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(3px); }
}
.ava.flash { animation: flashRed .45s; }
@keyframes flashRed { 0%,100% { background: #11151f; } 35% { background: #5a2230; } }
.ava.heal { animation: flashGreen .45s; }
@keyframes flashGreen { 0%,100% { background: #11151f; } 35% { background: #1f4a33; } }

/* 浮かぶダメージ数字 */
.fighter { position: relative; }
.float {
  position: absolute; left: 18px; top: 0; font-weight: 800; font-size: 1.2rem;
  pointer-events: none; animation: floatUp 1s ease forwards;
}
.float.dmg { color: #ff8a8a; }
.float.heal { color: #8af0b0; }
.float.shield { color: #9ec9ff; font-size: 1rem; }
@keyframes floatUp { 0% { opacity: 0; transform: translateY(8px); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(-34px); } }

/* いまの状況 */
.now {
  background: #11151f; border-radius: 12px; padding: 12px 14px;
  margin-bottom: 16px; min-height: 76px;
}
.now-rows { display: flex; flex-direction: column; gap: 8px; }
.now-row { display: flex; gap: 8px; align-items: baseline; font-size: .92rem; animation: fadeIn .3s ease; }
.now-row .tag {
  flex: 0 0 auto; font-size: .72rem; font-weight: 700; padding: 2px 8px;
  border-radius: 999px; background: #2a3346; color: var(--text);
}
.now-row.you .tag { background: rgba(111,207,151,.2); color: var(--hp); }
.now-row.cpu .tag { background: rgba(235,87,87,.2); color: var(--atk); }
.now-row.sys { color: var(--muted); }
.now-row .txt { line-height: 1.5; }

/* 手札 */
.hand { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.card {
  width: 96px; background: var(--panel); border: 2px solid #2a3346;
  border-radius: 12px; padding: 12px 8px; cursor: pointer; text-align: center;
  display: flex; flex-direction: column; gap: 6px;
  transition: transform .08s, border-color .15s; animation: dealIn .3s ease;
}
@keyframes dealIn { from { opacity: 0; transform: translateY(14px) scale(.9); } to { opacity: 1; transform: none; } }
.card .ico { font-size: 1.7rem; }
.card .ctype { font-size: .82rem; font-weight: 700; }
.card .cval { font-size: .78rem; color: var(--muted); }
.card.atk { border-color: var(--atk); } .card.atk .ctype { color: var(--atk); }
.card.def { border-color: var(--def); } .card.def .ctype { color: var(--def); }
.card.sp { border-color: var(--sp); } .card.sp .ctype { color: var(--sp); }
.card:hover { transform: translateY(-4px); }
.card:active { transform: scale(.95); }
.card[disabled] { opacity: .45; pointer-events: none; }

.controls { text-align: center; margin-top: 22px; }
.foot { margin-top: 22px; color: var(--muted); font-size: .76rem; text-align: center; }

/* 履歴 */
.history { margin-top: 18px; }
.history summary { color: var(--muted); font-size: .85rem; cursor: pointer; }
.log {
  margin-top: 8px; background: #11151f; border-radius: 10px; padding: 10px 12px;
  font-size: .82rem; display: flex; flex-direction: column; gap: 4px;
  max-height: 180px; overflow-y: auto;
}
.log .line { color: var(--muted); }
.log .line.turn { color: var(--text); font-weight: 700; margin-top: 4px; }

@media (prefers-reduced-motion: reduce) {
  .hpfill, .card { transition: none; }
  .home-emoji, .screen, .fighter.hit, .ava.flash, .ava.heal, .float, .now-row, .card { animation: none; }
  .float { display: none; }
}
