/* =========================================
   ゆめかわスイカゲーム — スタイル
   ========================================= */

:root {
  --mint-light: #D4F5E9;
  --mint-base:  #B6E5D8;
  --mint-dark:  #7DC9B0;
  --pink-light: #FFE4F0;
  --pink-base:  #FFB6D9;
  --pink-dark:  #D470A0;
  --cream:      #FFE8D4;
  --yellow:     #FFF4B3;
  --purple:     #C9B6FF;
  --gold:       #FFE5A3;
  --text-dark:  #8B5A8C;

  --shadow-soft: 0 6px 18px rgba(212, 112, 160, 0.18);
  --shadow-pop:  0 10px 28px rgba(212, 112, 160, 0.28);

  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  font-family: 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN',
               'Yu Gothic', 'Meiryo', sans-serif;
  font-weight: 700;
  color: var(--text-dark);
  background: linear-gradient(180deg, var(--pink-light) 0%, var(--mint-light) 100%);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ===== 画面切替 ===== */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.screen.is-active { display: flex; }

/* ===== ボタン共通 ===== */
.btn {
  font-family: inherit;
  font-weight: 800;
  font-size: 18px;
  color: var(--text-dark);
  background: #fff;
  border: 3px solid var(--pink-base);
  border-radius: var(--radius-md);
  padding: 14px 28px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-pop);
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: var(--shadow-soft);
}
.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.btn--primary {
  background: linear-gradient(180deg, #fff 0%, var(--pink-light) 100%);
  border-color: var(--pink-dark);
}
.btn--ghost {
  background: rgba(255,255,255,0.7);
  border-color: var(--mint-dark);
}
.btn--small {
  font-size: 14px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
}

/* =========================================
   タイトル画面
   ========================================= */
#screen-title .title-wrap {
  width: min(440px, 92vw);
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(4px);
  border: 4px solid #fff;
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  box-shadow: var(--shadow-pop);
  text-align: center;
  position: relative;
}
#screen-title .title-wrap::before,
#screen-title .title-wrap::after {
  content: "♡";
  position: absolute;
  font-size: 26px;
  color: var(--pink-base);
  opacity: .8;
}
#screen-title .title-wrap::before { top: 10px; left: 16px; }
#screen-title .title-wrap::after  { bottom: 10px; right: 16px; }

.title-logo {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 0 20px;
  line-height: 1.1;
  position: relative;
}
.title-logo__sub {
  font-size: 22px;
  color: var(--mint-dark);
  letter-spacing: 0.08em;
}
.title-logo__main {
  font-size: 38px;
  color: var(--pink-dark);
  text-shadow: 2px 2px 0 #fff, 4px 4px 0 var(--pink-light);
  letter-spacing: 0.02em;
}
.title-logo__deco {
  position: absolute;
  top: -10px;
  right: 14px;
  font-size: 26px;
  color: var(--pink-base);
  transform: rotate(15deg);
}

.title-score {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  background: #fff;
  border: 3px dashed var(--pink-base);
  border-radius: 999px;
  padding: 8px 22px;
  margin-bottom: 22px;
}
.title-score__label { font-size: 14px; color: var(--mint-dark); }
.title-score__value { font-size: 22px; color: var(--pink-dark); }

.title-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
}

.title-note {
  margin: 20px 0 0;
  font-size: 13px;
  color: var(--text-dark);
  opacity: .7;
}

/* =========================================
   ゲーム画面
   ========================================= */
#screen-game {
  justify-content: flex-start;
  padding: 8px;
  gap: 8px;
}

.game-header {
  width: min(440px, 96vw);
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: center;
}
.game-header__score,
.game-header__high {
  background: #fff;
  border: 3px solid var(--pink-base);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
}
.game-header__high { border-color: var(--mint-dark); }
.game-header__label {
  font-size: 11px;
  color: var(--mint-dark);
  letter-spacing: 0.06em;
}
.game-header__score .game-header__label { color: var(--pink-dark); }
.game-header__value {
  font-size: 22px;
  color: var(--text-dark);
}
.game-header__next {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #fff;
  border: 3px solid var(--purple);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
}
.game-header__next-box {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--purple);
}

.game-stage {
  flex: 1;
  width: min(440px, 96vw);
  display: flex;
  align-items: center;
  justify-content: center;
}
.game-stage__inner {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  max-height: calc(100vh - 160px);
  background: linear-gradient(180deg, #fff 0%, var(--pink-light) 100%);
  border: 6px solid #fff;
  outline: 3px solid var(--pink-base);
  outline-offset: -9px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.game-stage__inner::before,
.game-stage__inner::after {
  content: "♡";
  position: absolute;
  font-size: 18px;
  color: var(--pink-base);
  z-index: 2;
  pointer-events: none;
}
.game-stage__inner::before { top: 6px; left: 10px; }
.game-stage__inner::after  { top: 6px; right: 10px; }

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.game-stage__overline {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 2px dashed var(--pink-dark);
  opacity: .55;
  pointer-events: none;
  transition: opacity .2s ease;
}
.game-stage__overline.is-warning {
  border-top: 3px dashed #FF4D7E;
  box-shadow: 0 0 16px rgba(255, 77, 126, 0.6);
  animation: overlineBlink 0.45s ease-in-out infinite alternate;
}
@keyframes overlineBlink {
  from { opacity: 0.45; }
  to   { opacity: 1.0;  }
}

.game-footer {
  width: min(440px, 96vw);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

/* =========================================
   音量パネル / ミュートボタン
   ========================================= */
.audio-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  background: rgba(255,255,255,0.65);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 2px solid var(--mint-base);
}

.audio-btn {
  font-family: inherit;
  font-weight: 800;
  font-size: 13px;
  background: #fff;
  border: 2px solid var(--mint-dark);
  border-radius: 999px;
  padding: 6px 14px;
  color: var(--text-dark);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: background .12s ease, color .12s ease, border-color .12s ease, transform .1s ease;
}
.audio-btn:hover { transform: translateY(-1px); }
.audio-btn:active { transform: translateY(1px); }

.audio-btn[aria-pressed="true"] {
  background: var(--pink-base);
  color: #fff;
  border-color: var(--pink-dark);
  text-shadow: 1px 1px 0 rgba(180,90,130,0.3);
}
.audio-btn--small { font-size: 12px; padding: 5px 12px; }

.audio-icon { font-size: 13px; }
.audio-label { font-size: 13px; }

.audio-slider {
  flex: 1;
  accent-color: var(--pink-base);
  height: 22px;
  cursor: pointer;
}

/* =========================================
   ゲームオーバー オーバーレイ
   ========================================= */
.game-over {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 228, 240, 0.6);
  backdrop-filter: blur(3px);
  z-index: 5;
  padding: 16px;
  animation: gameOverFade .4s ease-out;
}
.game-over[hidden] { display: none; }

@keyframes gameOverFade {
  from { background: rgba(255, 228, 240, 0); }
  to   { background: rgba(255, 228, 240, 0.6); }
}

.game-over__card {
  background: #fff;
  border: 4px solid var(--pink-base);
  border-radius: var(--radius-lg);
  padding: 22px 22px 18px;
  text-align: center;
  box-shadow: var(--shadow-pop);
  width: min(280px, 90%);
  animation: gameOverPop .45s cubic-bezier(.18,.89,.32,1.28);
  position: relative;
}
.game-over__card::before,
.game-over__card::after {
  content: "♡";
  position: absolute;
  font-size: 18px;
  color: var(--pink-base);
  opacity: .8;
}
.game-over__card::before { top: 8px; left: 12px; }
.game-over__card::after  { top: 8px; right: 12px; }

@keyframes gameOverPop {
  0%   { transform: scale(0.6); opacity: 0; }
  60%  { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

.game-over__title {
  margin: 0 0 14px;
  color: var(--pink-dark);
  font-size: 22px;
  letter-spacing: 0.05em;
}

.game-over__scores {
  margin: 0 0 12px;
}
.game-over__row {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  padding: 6px 8px;
  border-bottom: 1px dashed var(--pink-base);
  color: var(--text-dark);
}
.game-over__row:last-child { border-bottom: none; }
.game-over__row span:last-child {
  font-weight: 800;
  color: var(--pink-dark);
  font-size: 18px;
}

.game-over__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(90deg, #FFD27A, #FFB6D9 50%, #C9B6FF);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  padding: 6px 14px;
  border-radius: 999px;
  margin: 4px 0 14px;
  text-shadow: 1px 1px 0 rgba(180, 90, 130, 0.35);
  box-shadow: 0 4px 10px rgba(212,112,160,0.3);
  animation: hsPulse 1.2s ease-in-out infinite alternate;
}
.game-over__badge[hidden] { display: none; }
.game-over__badge-icon { font-size: 12px; }

@keyframes hsPulse {
  from { transform: scale(1)   rotate(-1deg); }
  to   { transform: scale(1.06) rotate(1deg); }
}

.game-over__buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* =========================================
   Lv11合体バースト演出
   ========================================= */
.lv11-burst {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 6;
  overflow: hidden;
}
.lv11-burst[hidden] { display: none; }

.lv11-burst__bg {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  animation: lv11BgFlash 2.1s ease-out forwards;
}
@keyframes lv11BgFlash {
  0%   { background: rgba(255,255,255,0); }
  8%   { background: rgba(255,255,255,0.95); }
  25%  { background: rgba(255,210,240,0.6); }
  45%  { background: rgba(220,235,255,0.45); }
  65%  { background: rgba(255,240,210,0.3); }
  100% { background: rgba(255,255,255,0); }
}

.lv11-burst__msg {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(15px, 4.6vw, 22px);
  font-weight: 800;
  color: var(--pink-dark);
  background: #fff;
  border: 3px dashed var(--pink-base);
  border-radius: var(--radius-lg);
  padding: 12px 20px;
  text-shadow: 1px 1px 0 #fff, 2px 2px 0 var(--pink-light);
  box-shadow: 0 10px 26px rgba(212,112,160,0.35);
  animation: lv11MsgIn 2.1s ease-out forwards;
  text-align: center;
  white-space: nowrap;
  max-width: 92%;
}
.lv11-burst__text { white-space: normal; line-height: 1.25; }

@keyframes lv11MsgIn {
  0%   { transform: scale(0.3) rotate(-12deg); opacity: 0; }
  18%  { transform: scale(1.12) rotate(3deg);  opacity: 1; }
  32%  { transform: scale(1) rotate(0);        opacity: 1; }
  80%  { transform: scale(1) rotate(0);        opacity: 1; }
  100% { transform: scale(0.9) rotate(0);      opacity: 0; }
}

/* =========================================
   進化図鑑
   ========================================= */
#screen-collection { padding: 16px; }

.collection-wrap {
  width: min(440px, 96vw);
  max-height: 96vh;
  background: rgba(255,255,255,0.65);
  border: 4px solid #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}

.collection-title {
  text-align: center;
  margin: 0;
  font-size: 24px;
  color: var(--pink-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.collection-title__deco { color: var(--pink-base); font-size: 18px; }

.collection-progress {
  text-align: center;
  margin: -4px 0 0;
  font-size: 14px;
  color: var(--mint-dark);
  background: #fff;
  border: 2px dashed var(--mint-base);
  border-radius: 999px;
  padding: 4px 14px;
  align-self: center;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.collection-cell {
  background: #fff;
  border: 2px solid var(--pink-base);
  border-radius: var(--radius-sm);
  padding: 8px 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}
.collection-cell--locked {
  background: rgba(255,255,255,0.5);
  border-style: dashed;
  border-color: var(--mint-base);
}
.collection-cell__img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}
.collection-cell__q {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--mint-light);
  color: var(--mint-dark);
  font-size: 28px;
  font-weight: 800;
}
.collection-cell__lv {
  font-size: 11px;
  color: var(--mint-dark);
  letter-spacing: 0.05em;
}
.collection-cell__name {
  font-size: 12px;
  color: var(--text-dark);
  font-weight: 800;
}
.collection-cell--locked .collection-cell__name { color: var(--mint-dark); }

.collection-note {
  font-size: 12px;
  color: var(--text-dark);
  opacity: 0.7;
  text-align: center;
  margin: 0;
}
.collection-note.is-complete {
  color: var(--pink-dark);
  opacity: 1;
  font-weight: 800;
}

/* =========================================
   レスポンシブ
   ========================================= */
@media (max-width: 480px) {
  .title-logo__main { font-size: 30px; }
  .title-logo__sub  { font-size: 18px; }
  .btn { font-size: 16px; padding: 12px 22px; }
  .game-header__value { font-size: 18px; }
  .game-header__next-box { width: 42px; height: 42px; }
  .collection-cell__img,
  .collection-cell__q { width: 56px; height: 56px; }
}
@media (max-width: 360px) {
  .title-logo__main { font-size: 26px; }
  .collection-grid { grid-template-columns: repeat(2, 1fr); }
}
