/* ===== Prism Split - Stylesheet ===== */
:root {
  --bg: #0A0E27;
  --bg-2: #141b3d;
  --panel: rgba(20, 27, 61, 0.85);
  --line: rgba(255, 255, 255, 0.1);
  --text: #E8ECF8;
  --text-dim: #8a92b2;
  --accent: #00F0FF;
  --accent-2: #FF00E5;
  --accent-3: #FFEB3B;
  --ok: #00FFA3;
  --ng: #FF4D6D;
  --shadow-glow: 0 0 20px rgba(0, 240, 255, 0.35);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
#app {
  position: relative;
  width: 100vw;
  height: 100vh;          /* fallback */
  height: 100dvh;         /* 動的ビューポート: スマホURLバー対応 */
  overflow: hidden;
}

/* Screens */
.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.screen.active { display: flex; }

/* ===== Menu ===== */
#screen-menu {
  align-items: center;
  justify-content: center;
  text-align: center;
  background: radial-gradient(ellipse at center, #1a2255 0%, #0A0E27 70%);
}
.menu-bg {
  position: absolute; inset: 0;
  background: url('../assets/images/menu_background.png') center/cover;
  opacity: 0.35;
  pointer-events: none;
}
.title-logo {
  width: 180px; max-width: 60vw;
  margin-top: 12vh;
  filter: drop-shadow(0 0 20px rgba(0, 240, 255, 0.5));
  animation: float 4s ease-in-out infinite;
  position: relative;
}
.title {
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  margin-top: 12px;
  background: linear-gradient(90deg, #00F0FF, #FF00E5, #FFEB3B);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 40px rgba(0, 240, 255, 0.3);
  position: relative;
}
.tagline {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-top: 6px;
  letter-spacing: 0.1em;
  position: relative;
}
.mascot-menu {
  width: 160px; max-width: 45vw;
  margin-top: 20px;
  position: relative;
  animation: float 3s ease-in-out infinite;
}
.menu-buttons {
  margin-top: auto;
  margin-bottom: 12vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 80%;
  max-width: 280px;
  position: relative;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ===== Buttons ===== */
.btn {
  padding: 14px 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s, background 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, #00F0FF, #FF00E5);
  border: none;
  color: #0A0E27;
  box-shadow: var(--shadow-glow);
}
.btn-ghost { background: transparent; }
.btn-icon {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
}

/* ===== Top Bar ===== */
.top-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
  z-index: 10;
}
.top-bar h2 { font-size: 1.1rem; font-weight: 700; flex: 1; text-align: center; }
.spacer { width: 42px; }
.stage-info { flex: 1; text-align: center; }
.stage-name { font-size: 1rem; font-weight: 700; }
.stage-desc { font-size: 0.72rem; color: var(--text-dim); margin-top: 2px; }

/* ===== Stage Select ===== */
.stage-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  align-content: start;
}
.stage-card {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
}
.stage-card:active { transform: scale(0.97); }
.stage-card.cleared { border-color: var(--ok); box-shadow: 0 0 12px rgba(0, 255, 163, 0.25); }
.stage-card.locked { opacity: 0.35; cursor: not-allowed; }
.stage-card .num { font-size: 1.4rem; font-weight: 900; color: var(--accent); }
.stage-card .name { font-size: 0.7rem; color: var(--text-dim); text-align: center; padding: 0 4px; }
.stage-card .check { font-size: 1rem; color: var(--ok); }

/* ===== Game Screen ===== */
#screen-game {
  background: var(--bg);
  background-image: url('../assets/images/game_background.png');
  background-size: cover;
  background-position: center;
  background-blend-mode: multiply;
}
.game-area {
  flex: 1 1 auto;
  min-height: 0;          /* flexコンテナ内で縮小を許可 */
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 8px;
  overflow: hidden;
}
#game-canvas {
  max-width: 100%;
  max-height: 100%;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px;
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.1);
  touch-action: none;
}

/* ===== Palette ===== */
.palette {
  flex: 0 0 auto;         /* 縮小させない: 必ず表示 */
  background: var(--panel);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(6px);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.palette-item {
  position: relative;
  width: 58px; height: 58px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, border-color 0.2s, box-shadow 0.2s;
}
.palette-item:active { transform: scale(0.94); }
.palette-item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.5);
  transform: translateY(-4px);
}
.palette-item.selected::before {
  content: '↓';
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--accent);
  font-size: 1.2rem;
  font-weight: 900;
  animation: bounceDown 0.8s ease-in-out infinite;
}
@keyframes bounceDown {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, 4px); }
}
.palette-item.empty { opacity: 0.3; cursor: not-allowed; }
.palette-item .count {
  position: absolute;
  bottom: -6px; right: -6px;
  background: var(--accent);
  color: #0A0E27;
  font-size: 0.7rem;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
}
.palette-item .label {
  position: absolute;
  top: -18px;
  font-size: 0.6rem;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ===== Clear Screen ===== */
#screen-clear {
  align-items: center;
  justify-content: center;
  text-align: center;
  background: radial-gradient(ellipse at center, #1a2255 0%, #0A0E27 70%);
}
.mascot-clear {
  width: 200px; max-width: 50vw;
  animation: pop 0.5s ease-out;
}
@keyframes pop {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}
.clear-title {
  font-size: 2rem;
  font-weight: 900;
  margin-top: 16px;
  background: linear-gradient(90deg, #00FFA3, #00F0FF);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.clear-stats {
  margin-top: 20px;
  padding: 16px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  min-width: 240px;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.95rem;
}
.stat-row + .stat-row { border-top: 1px solid var(--line); }
.stat-row span:last-child { color: var(--accent); font-weight: 700; }
#screen-clear .menu-buttons {
  margin-top: 28px;
  margin-bottom: 8vh;
}

/* ===== Selection Bar ===== */
.selection-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: linear-gradient(90deg, rgba(0, 240, 255, 0.18), rgba(255, 0, 229, 0.18));
  border-bottom: 1px solid var(--accent);
  backdrop-filter: blur(4px);
  z-index: 5;
  animation: slideDown 0.25s ease-out;
}
.selection-bar.active { display: flex; }
.selection-bar .sel-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
}
.selection-bar #selection-text {
  flex: 1;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
}
.btn-mini {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.4);
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
}
@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===== Palette Hint ===== */
.palette-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-dim);
  padding: 6px 16px 2px;
  letter-spacing: 0.05em;
}
.palette-hint.highlight {
  color: var(--accent);
  animation: pulse-text 1.5s ease-in-out infinite;
}
@keyframes pulse-text {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; text-shadow: 0 0 12px rgba(0, 240, 255, 0.8); }
}

/* ===== Tutorial Overlay ===== */
.tutorial-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(10, 14, 39, 0.7);
  backdrop-filter: blur(3px);
  z-index: 50;
  align-items: flex-end;
  justify-content: center;
  padding: 0 16px 16px;
}
.tutorial-overlay.active { display: flex; animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.tutorial-card {
  width: 100%;
  max-width: 360px;
  background: linear-gradient(180deg, rgba(20, 27, 61, 0.98), rgba(10, 14, 39, 0.98));
  border: 1px solid var(--accent);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 110px; /* パレットの上に配置 */
}
.tutorial-mascot {
  width: 70px;
  height: 70px;
  animation: float 3s ease-in-out infinite;
}
.tutorial-balloon {
  width: 100%;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: center;
}
#tutorial-text {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
}
#tutorial-text b {
  color: var(--accent);
  font-weight: 700;
}
.tutorial-progress {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
}
.tutorial-progress .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
}
.tutorial-progress .dot.active {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
.tutorial-buttons {
  display: flex;
  gap: 10px;
  width: 100%;
  justify-content: center;
}
.btn-small {
  padding: 10px 20px;
  font-size: 0.85rem;
}

/* ===== Ad Slot ===== */
.ad-slot {
  margin: 16px 0;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ad-placeholder {
  border: 1px dashed var(--line);
  border-radius: 8px;
  width: 280px;
}

/* ===== Toast / Message ===== */
.toast {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.85rem;
  z-index: 100;
  pointer-events: none;
  animation: toast 1.8s ease-out forwards;
}
@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, -10px); }
  15%, 85% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -10px); }
}
