* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --theme: #b05a8c;
}

body {
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, #33204a 0%, transparent 60%),
    radial-gradient(ellipse 70% 50% at 90% 110%, #3a1830 0%, transparent 55%),
    linear-gradient(165deg, #191024 0%, #120d18 55%, #1c1026 100%);
  background-attachment: fixed;
  color: #e8dff0;
  font-family: "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

#app { width: 100%; max-width: 960px; padding: 16px; }

.panel {
  position: relative;
  overflow: hidden;
  background: linear-gradient(175deg, rgba(40, 30, 56, 0.92), rgba(26, 19, 36, 0.95));
  border: 1px solid #4a3a60;
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  padding: 28px 24px;
  margin-top: 16px;
}

.center { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.center-text { text-align: center; margin-bottom: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 8px; }
.col { display: flex; flex-direction: column; gap: 12px; align-items: center; }

h1 { font-size: 1.6rem; }

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

.title-screen { padding: 72px 24px; }
.brand { color: #b7a8c9; letter-spacing: 0.25em; font-size: 0.9rem; }
.game-title {
  font-size: 3.4rem;
  letter-spacing: 0.14em;
  background: linear-gradient(180deg, #ffe3f1 10%, #f0a8d0 55%, #c060a0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(240, 130, 190, 0.35));
  animation: title-glow 3.2s ease-in-out infinite alternate;
}
@keyframes title-glow {
  from { filter: drop-shadow(0 0 10px rgba(240, 130, 190, 0.25)); }
  to   { filter: drop-shadow(0 0 26px rgba(240, 130, 190, 0.55)); }
}
.tagline { color: #c9b6da; letter-spacing: 0.1em; }

.game-title.small { font-size: 2.1rem; margin-bottom: 2px; }
.select-heading {
  color: #c9b6da;
  font-size: 1rem;
  font-weight: normal;
  letter-spacing: 0.15em;
  margin-bottom: 18px;
}

/* 花びら演出 */
.petal {
  position: absolute;
  top: -8%;
  pointer-events: none;
  opacity: 0.7;
  animation-name: petal-fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  z-index: 0;
}
.title-screen > *:not(.petal), .clear-screen > *:not(.petal) { position: relative; z-index: 1; }
@keyframes petal-fall {
  0%   { transform: translate(0, -5vh) rotate(0deg); }
  25%  { transform: translate(-3vw, 28vh) rotate(90deg); }
  50%  { transform: translate(3vw, 55vh) rotate(200deg); }
  75%  { transform: translate(-2vw, 80vh) rotate(300deg); }
  100% { transform: translate(2vw, 110vh) rotate(390deg); }
}

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

.btn {
  background: linear-gradient(180deg, #352a46, #281f36);
  color: #e8dff0;
  border: 1px solid #52436a;
  border-radius: 12px;
  padding: 10px 20px;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.15); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(180deg, #b0508a, #7e3060);
  border-color: #d075ab;
  box-shadow: 0 4px 16px rgba(176, 80, 138, 0.35);
}
.btn.big { font-size: 1.3rem; padding: 15px 46px; }
.btn.small { font-size: 0.85rem; padding: 6px 14px; }
.btn.kdp {
  background: linear-gradient(180deg, #3c6842, #2a4a30);
  border-color: #57935f;
  display: block;
  margin: 6px auto;
}

/* じゃんけんボタン */
.btn.hand {
  font-size: 2.2rem;
  padding: 14px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border-color: var(--theme);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
}
.btn.hand:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 0 22px color-mix(in srgb, var(--theme) 55%, transparent);
}
.hand-label { font-size: 0.85rem; color: #c9b6da; }

/* ---- キャラ選択 ---- */

.card-row { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; }
.card {
  background: linear-gradient(180deg, rgba(48, 36, 66, 0.85), rgba(32, 24, 44, 0.9));
  border: 1px solid #443556;
  border-radius: 16px;
  padding: 16px;
  width: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--theme);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--theme) 30%, transparent);
}
.card .catch { color: #d9b8cc; font-size: 0.95rem; }
.card .work { color: #9c8fb0; font-size: 0.8rem; }

/* ---- 立ち絵フレーム ---- */

.portrait-frame {
  padding: 6px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(30, 22, 42, 0.9), rgba(22, 16, 32, 0.95)) padding-box,
    linear-gradient(160deg, color-mix(in srgb, var(--theme) 80%, white 10%), #2c2240 60%, var(--theme)) border-box;
  border: 2px solid transparent;
  box-shadow: 0 0 24px color-mix(in srgb, var(--theme) 25%, transparent);
}
/* 選択カードは顔が見えるよう上半身にクローズアップ(coverで上部を切り抜き)。
   キャラ別の追加ズームは characters.js の cardZoom で指定 */
.portrait-clip { overflow: hidden; border-radius: 10px; }
.portrait { width: 200px; aspect-ratio: 3 / 4; object-fit: cover; object-position: 50% 8%; display: block; }
.battle-portrait { width: min(45vw, 300px); aspect-ratio: 9 / 16; object-fit: contain; display: block; border-radius: 10px; animation: portrait-in 0.35s ease-out; }
.battle-portrait.dimmed { filter: grayscale(0.6) brightness(0.7); }
.battle-frame { margin: 12px auto; width: fit-content; }
.battle-frame.flash { animation: frame-flash 0.7s ease-out; }
@keyframes portrait-in {
  from { opacity: 0.4; transform: scale(0.98); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes frame-flash {
  0%   { box-shadow: 0 0 60px color-mix(in srgb, var(--theme) 90%, white 20%); }
  100% { box-shadow: 0 0 24px color-mix(in srgb, var(--theme) 25%, transparent); }
}

/* ---- バトルUI ---- */

.battle-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  color: #c9b6da;
  font-size: 0.9rem;
}
.battle-name { font-weight: bold; letter-spacing: 0.05em; }
.gauge-label { font-size: 0.75rem; color: #9c8fb0; margin-right: 6px; }

.lives { display: flex; align-items: center; gap: 3px; }
.heart { font-size: 1.15rem; line-height: 1; }
.heart.alive { color: #ff6b9d; text-shadow: 0 0 8px rgba(255, 107, 157, 0.6); }
.heart.dead { color: #4a3d5e; }

.stage-gauge { display: flex; align-items: center; gap: 4px; }
.stage-gauge .seg {
  width: 26px; height: 10px;
  border-radius: 5px;
  background: #34294a;
  border: 1px solid #4a3d5e;
}
.stage-gauge .seg.filled {
  background: linear-gradient(90deg, var(--theme), color-mix(in srgb, var(--theme) 60%, white 25%));
  border-color: var(--theme);
  box-shadow: 0 0 8px color-mix(in srgb, var(--theme) 60%, transparent);
}

.serif { text-align: center; font-size: 1.15rem; min-height: 2.4em; margin: 8px 0; }

/* 手の見せ合い */
.vs-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  min-height: 3.4rem;
}
.vs-hand { font-size: 2.6rem; line-height: 1; }
.vs-hand.pop { animation: hand-pop 0.3s ease-out; }
@keyframes hand-pop {
  0%   { transform: scale(0.3) rotate(-20deg); opacity: 0; }
  70%  { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.vs-label {
  font-size: 1.3rem;
  font-weight: bold;
  letter-spacing: 0.12em;
  min-width: 5.5em;
  text-align: center;
}
.vs-row.win .vs-label { color: #ff9dc4; text-shadow: 0 0 14px rgba(255, 130, 180, 0.8); animation: label-pop 0.4s ease-out; }
.vs-row.lose .vs-label { color: #7d8ec9; }
.vs-row.draw .vs-label { color: #c9b6da; }
.vs-row.idle .vs-label { color: #9c8fb0; font-size: 1rem; font-weight: normal; }
@keyframes label-pop {
  0%   { transform: scale(0.5); opacity: 0; }
  60%  { transform: scale(1.25); }
  100% { transform: scale(1); opacity: 1; }
}

.mercy-hint {
  text-align: center;
  min-height: 1.6em;
  color: #ffd97a;
  text-shadow: 0 0 10px rgba(255, 200, 90, 0.4);
  font-size: 0.95rem;
  animation: mercy-blink 1.2s ease-in-out infinite alternate;
}
.mercy-hint.empty { animation: none; }
@keyframes mercy-blink { from { opacity: 0.75; } to { opacity: 1; } }
.mercy-note { color: #c9b6da; font-size: 0.9rem; }

.hands { margin-top: 4px; }

/* ---- クリア/KDP ---- */

.clear-title {
  font-size: 2.2rem;
  color: #ffc3dd;
  text-shadow: 0 0 20px rgba(255, 140, 190, 0.7);
  animation: label-pop 0.5s ease-out;
}
.kdp-links { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.kdp-link { color: #8fce9a; font-size: 0.85rem; text-decoration: none; }
.kdp-link:hover { text-decoration: underline; }
.kdp-promo {
  background: linear-gradient(180deg, rgba(40, 62, 40, 0.7), rgba(28, 44, 30, 0.8));
  border: 1px solid #3c6842;
  border-radius: 12px;
  padding: 16px 20px;
}
.kdp-promo p { margin-bottom: 8px; }

/* ---- ギャラリー ---- */

.gallery-section { margin-bottom: 28px; }
.gallery-section h2 { font-size: 1.1rem; margin-bottom: 10px; }
.thumb-row { display: flex; flex-wrap: wrap; gap: 10px; }
.thumb {
  width: 90px;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #3a2f4a;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}
.thumb:hover { transform: scale(1.06); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4); }
.thumb.locked {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #241c30;
  color: #5e5372;
  font-size: 1.4rem;
  cursor: default;
}
.thumb.locked:hover { transform: none; box-shadow: none; }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
}
.lightbox-img { max-height: 92vh; max-width: 92vw; object-fit: contain; }

@media (max-width: 640px) {
  .game-title { font-size: 2.3rem; }
  .card { width: 100%; }
  .battle-status { justify-content: center; }
}
