/* ==================================================
   ぬりえランド - Stylesheet
   子供向け塗り絵PWAアプリ
================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --c-pink: #ffb3d1;
  --c-pink-deep: #ff7ab0;
  --c-yellow: #fff3a0;
  --c-mint: #a8f0d1;
  --c-sky: #b3e0ff;
  --c-lavender: #d4b3ff;
  --c-cream: #fff8e7;
  --c-text: #4a3a5c;
  --c-text-soft: #7a6a8c;
  --c-shadow: 0 4px 0 rgba(120, 80, 140, 0.15);
  --c-shadow-hover: 0 6px 0 rgba(120, 80, 140, 0.2);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'M PLUS Rounded 1c', 'Hiragino Sans', sans-serif;
  font-weight: 700;
  color: var(--c-text);
  background: linear-gradient(135deg, #fff0f6 0%, #f0f8ff 50%, #fff8e7 100%);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

/* ============ Screen 共通 ============ */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; flex-direction: column; }

/* ============ ホーム画面 ============ */
#screen-home { background: linear-gradient(135deg, #fff0f6 0%, #f0f8ff 50%, #fff8e7 100%); }

.home-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.floating-shape {
  position: absolute;
  font-size: 3rem;
  animation: float 8s ease-in-out infinite;
  opacity: 0.5;
}
.shape1 { top: 8%;  left: 5%;  animation-delay: 0s;   }
.shape2 { top: 15%; right: 8%; animation-delay: 1.2s; font-size: 2.5rem;}
.shape3 { top: 60%; left: 4%;  animation-delay: 2.4s; font-size: 2.8rem;}
.shape4 { top: 70%; right: 6%; animation-delay: 3.6s; }
.shape5 { top: 35%; left: 10%; animation-delay: 4.8s; font-size: 2.2rem;}
.shape6 { top: 45%; right: 12%; animation-delay: 6s;  font-size: 2.5rem;}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0); }
  25%      { transform: translateY(-20px) rotate(5deg); }
  50%      { transform: translateY(-10px) rotate(-5deg); }
  75%      { transform: translateY(-25px) rotate(3deg); }
}

.home-content {
  position: relative;
  z-index: 1;
  padding: 24px 20px 32px;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 100%;
}

.title {
  text-align: center;
  font-size: clamp(2.4rem, 7vw, 4rem);
  font-weight: 900;
  letter-spacing: 0.05em;
  line-height: 1.1;
  margin-top: 8px;
}

.title-char {
  display: inline-block;
  animation: bounce 2s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.1s);
  text-shadow: 0 4px 0 rgba(255,150,200,0.4), 0 8px 16px rgba(255,150,200,0.3);
}
.title-char:nth-child(1) { color: #ff6b9d; }
.title-char:nth-child(2) { color: #ffa84a; }
.title-char:nth-child(3) { color: #ffd93d; }
.title-char:nth-child(4) { color: #6bcf7f; }
.title-char:nth-child(5) { color: #4a9eff; }
.title-char:nth-child(6) { color: #b86bff; }

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}

.subtitle {
  text-align: center;
  font-size: clamp(1rem, 3vw, 1.3rem);
  color: var(--c-text-soft);
  margin-bottom: 4px;
}

/* ============ キャラクターグリッド ============ */
.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  width: 100%;
}

.char-card {
  background: white;
  border-radius: 28px;
  padding: 16px 12px 18px;
  box-shadow: var(--c-shadow);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 4px solid white;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
}
.char-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--card-bg, linear-gradient(135deg, #fff0f6, #f0f8ff));
  z-index: 0;
}
.char-card > * { position: relative; z-index: 1; }

.char-card:hover, .char-card:active {
  transform: translateY(-4px);
  box-shadow: var(--c-shadow-hover);
}
.char-card:active { transform: translateY(0) scale(0.97); }

.char-card-thumb {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.char-card-thumb svg { width: 90%; height: 90%; pointer-events: none; }
.char-card-thumb svg * { pointer-events: none; cursor: default !important; }

.char-card-name {
  font-size: 1.05rem;
  font-weight: 900;
  text-align: center;
  color: var(--c-text);
}

/* ============ Home bottom buttons ============ */
.home-bottom {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.btn-bottom {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 18px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 900;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--c-shadow);
  transition: transform 0.15s, box-shadow 0.15s;
  color: white;
  position: relative;
  white-space: nowrap;
}
.btn-gallery { background: linear-gradient(135deg, #ff9a6b 0%, #ffb84a 100%); }
.btn-zukan   { background: linear-gradient(135deg, #b86bff 0%, #ff6b9d 100%); }
.btn-party   { background: linear-gradient(135deg, #ff6b9d 0%, #ffd93d 100%); }
.btn-free    { background: linear-gradient(135deg, #4a9eff 0%, #6bcf7f 100%); }

.btn-bottom:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(120,80,140,0.15); }
.btn-icon { font-size: 1.3rem; }

.badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #ff4081;
  color: white;
  font-size: 0.85rem;
  font-weight: 900;
  min-width: 24px;
  height: 24px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border: 2px solid white;
}
.badge:empty, .badge[data-count="0"] { display: none; }

/* ============ 塗り絵画面 ============ */
#screen-coloring { background: linear-gradient(135deg, #fff8e7 0%, #fff0f6 100%); }

.paint-header {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  gap: 10px;
  flex-shrink: 0;
}

.paint-title {
  flex: 1;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--c-pink-deep);
}

.btn-back, .btn-action {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 14px;
  background: var(--c-cream);
  font-size: 1.4rem;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(120,80,140,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  transition: transform 0.1s, box-shadow 0.1s;
}
.btn-back { background: linear-gradient(135deg, #ffd6e7, #ffc4dd); }
.btn-back:active, .btn-action:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(120,80,140,0.1);
}
.paint-actions { display: flex; gap: 8px; }
.btn-action.btn-save { background: linear-gradient(135deg, #a8f0d1, #6bcf9f); }
.btn-action.btn-trash { background: linear-gradient(135deg, #ffb3b3, #ff8585); }
.btn-action.btn-challenge { background: linear-gradient(135deg, #fff8a0, #ffd93d); }
.btn-action.btn-challenge.active { background: linear-gradient(135deg, #ff8c1a, #ff4757); }

/* おだいバー */
.challenge-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #fff8a0, #ffd93d);
  border-bottom: 3px solid #ffb84a;
  flex-shrink: 0;
  animation: slidedown 0.4s ease;
}
.challenge-bar[hidden] { display: none !important; }
@keyframes slidedown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.challenge-icon { font-size: 1.6rem; }
.challenge-info { flex: 1; min-width: 0; }
.challenge-name { font-weight: 900; color: #c43030; font-size: 0.95rem; }
.challenge-status { font-size: 0.8rem; color: #8b5a2b; font-weight: 700; }
.challenge-quit {
  border: none;
  background: white;
  color: var(--c-text-soft);
  font-family: inherit;
  font-weight: 900;
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(120,80,140,0.1);
}

/* おだいダイアログ */
.challenge-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}
.challenge-item {
  text-align: left;
  border: 3px solid #ffd93d;
  background: linear-gradient(135deg, #fff8e7, #fff);
  font-family: inherit;
  font-weight: 900;
  padding: 12px 14px;
  border-radius: 14px;
  cursor: pointer;
  color: var(--c-text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.challenge-item:active { transform: scale(0.97); }
.challenge-item.cleared::after {
  content: '⭐';
  margin-left: auto;
  font-size: 1.4rem;
}
.challenge-emoji { font-size: 1.8rem; flex-shrink: 0; }
.challenge-title { font-size: 1rem; }
.challenge-desc { font-size: 0.8rem; color: var(--c-text-soft); font-weight: 700; }

/* 色swatch：禁止状態 */
.color-swatch.forbidden {
  opacity: 0.3;
  filter: grayscale(0.7);
  cursor: not-allowed;
}
.color-swatch.forbidden::before {
  content: '✕';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: #c43030;
  font-weight: 900;
  text-shadow: 0 1px 2px white;
}

/* 揺れアニメーション（違反時） */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}
.shake { animation: shake 0.4s ease; }

/* ============ Paint Main ============ */
.paint-main {
  flex: 1;
  display: flex;
  flex-direction: row;
  gap: 0;
  overflow: hidden;
}

.canvas-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  min-height: 0;
  min-width: 0;
}

.canvas-container {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  background: white;
  border-radius: 24px;
  box-shadow: 0 8px 24px rgba(120,80,140,0.15);
  border: 6px solid white;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.canvas-container svg {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
.canvas-container svg path,
.canvas-container svg circle,
.canvas-container svg rect,
.canvas-container svg ellipse,
.canvas-container svg polygon {
  cursor: pointer;
}
.canvas-container svg path.locked,
.canvas-container svg circle.locked,
.canvas-container svg rect.locked,
.canvas-container svg ellipse.locked,
.canvas-container svg polygon.locked {
  cursor: default;
}

/* ============ Palette area ============ */
.palette-area {
  width: 280px;
  background: white;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 12px;
  box-shadow: -4px 0 12px rgba(0,0,0,0.05);
  overflow-y: auto;
  flex-shrink: 0;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: var(--c-cream);
  padding: 6px;
  border-radius: 16px;
}

.mode-btn {
  border: none;
  background: transparent;
  padding: 10px 4px;
  border-radius: 12px;
  font-family: inherit;
  font-weight: 900;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--c-text-soft);
  transition: background 0.15s, color 0.15s;
}
.mode-btn span:first-child { font-size: 1.4rem; }
.mode-btn.active {
  background: white;
  color: var(--c-pink-deep);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.color-palette {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.color-swatch {
  aspect-ratio: 1;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.1);
  transition: transform 0.1s;
  padding: 0;
}
.color-swatch:hover { transform: scale(1.05); }
.color-swatch:active { transform: scale(0.92); }
.color-swatch.selected {
  transform: scale(1.15);
  box-shadow: 0 0 0 3px white, 0 0 0 6px var(--c-pink-deep), inset 0 -3px 0 rgba(0,0,0,0.1);
}
.color-swatch.selected::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: white;
  text-shadow: 0 0 4px rgba(0,0,0,0.5);
  font-weight: 900;
}
.color-swatch.color-white { border: 2px solid #ddd; }
.color-swatch.color-white.selected::after { color: var(--c-text); text-shadow: none; }

.brush-label {
  font-size: 0.9rem;
  color: var(--c-text-soft);
  display: block;
  text-align: center;
}

.brush-slider {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(to right, #ffd6e7, var(--c-pink-deep));
  border-radius: 4px;
  outline: none;
}
.brush-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  background: white;
  border: 3px solid var(--c-pink-deep);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.brush-slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  background: white;
  border: 3px solid var(--c-pink-deep);
  border-radius: 50%;
  cursor: pointer;
}

.brush-controls, .stamp-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--c-cream);
  border-radius: 14px;
}
.brush-controls[hidden], .stamp-controls[hidden] { display: none; }

.stamp-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.stamp-item {
  aspect-ratio: 1;
  border: 3px solid transparent;
  background: white;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.1s;
}
.stamp-item:active { transform: scale(0.92); }
.stamp-item.selected {
  border-color: var(--c-pink-deep);
  transform: scale(1.05);
}

/* ============ Celebration ============ */
.celebration {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.celebration.show { display: flex; }

.celebration-star {
  position: absolute;
  font-size: 2rem;
  animation: pop-star 1.5s ease-out forwards;
  pointer-events: none;
}
@keyframes bannerPop {
  0%   { transform: translate(-50%, -50%) scale(0) rotate(-15deg); opacity: 0; }
  20%  { transform: translate(-50%, -50%) scale(1.2) rotate(5deg); opacity: 1; }
  40%  { transform: translate(-50%, -50%) scale(1) rotate(-3deg); opacity: 1; }
  90%  { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.1) translateY(-30px); opacity: 0; }
}
@keyframes pop-star {
  0%   { transform: scale(0) rotate(0deg);   opacity: 1; }
  50%  { transform: scale(1.5) rotate(180deg); opacity: 1; }
  100% { transform: scale(0.5) rotate(360deg) translateY(-200px); opacity: 0; }
}

.effect-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}

/* ============ ギャラリー ============ */
#screen-gallery { background: linear-gradient(135deg, #fff0f6 0%, #fff8e7 100%); }

.gallery-header {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  gap: 10px;
  flex-shrink: 0;
}

.gallery-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  padding: 20px;
  overflow-y: auto;
  align-content: start;
}

.gallery-item {
  background: white;
  border-radius: 20px;
  padding: 12px;
  box-shadow: var(--c-shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}
.gallery-item-img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 14px;
  background: var(--c-cream);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.gallery-item-img img { width: 100%; height: 100%; object-fit: contain; }
.gallery-item-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}
.gallery-item-name { font-weight: 900; color: var(--c-text); }
.gallery-item-date { color: var(--c-text-soft); font-size: 0.75rem; }
.gallery-item-actions {
  display: flex;
  gap: 6px;
}
.gallery-mini-btn {
  flex: 1;
  border: none;
  background: var(--c-cream);
  padding: 8px 4px;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
}
.gallery-mini-btn.share    { background: linear-gradient(135deg, #ff8db4, #ff6b9d); color: white; }
.gallery-mini-btn.download { background: linear-gradient(135deg, #a8f0d1, #6bcf9f); color: white; }
.gallery-mini-btn.delete   { background: linear-gradient(135deg, #ffd0d0, #ffb0b0); color: #c43030; }

.gallery-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
  color: var(--c-text-soft);
  gap: 8px;
}
.gallery-empty[hidden] { display: none !important; }
.gallery-grid[hidden] { display: none !important; }
.empty-icon { font-size: 4rem; margin-bottom: 16px; }

/* ============ Dialog ============ */
.dialog {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: dialog-fade 0.3s ease;
}
.dialog[hidden] { display: none !important; }
@keyframes dialog-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.dialog-content {
  background: white;
  border-radius: 28px;
  padding: 28px 24px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  animation: dialog-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes dialog-pop {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.celebration-stars {
  display: flex;
  justify-content: center;
  gap: 4px;
  font-size: 2rem;
  margin-bottom: 12px;
}
.celebration-stars span {
  animation: bounce 1s ease-in-out infinite;
}
.celebration-stars span:nth-child(2) { animation-delay: 0.1s; }
.celebration-stars span:nth-child(3) { animation-delay: 0.2s; }
.celebration-stars span:nth-child(4) { animation-delay: 0.3s; }
.celebration-stars span:nth-child(5) { animation-delay: 0.4s; }

.dialog-title {
  font-size: 1.5rem;
  color: var(--c-pink-deep);
  margin-bottom: 8px;
}
.dialog-text {
  color: var(--c-text-soft);
  margin-bottom: 16px;
}

.save-preview {
  width: 200px;
  height: 200px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: var(--c-cream);
  border: 4px solid var(--c-pink);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.save-preview img, .save-preview svg { width: 100%; height: 100%; object-fit: contain; }

.dialog-buttons {
  display: flex;
  gap: 10px;
  flex-direction: column;
}

.btn-dialog {
  padding: 14px 20px;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 900;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: white;
  box-shadow: var(--c-shadow);
  transition: transform 0.15s;
}
.btn-dialog:active { transform: translateY(2px); }
.btn-download { background: linear-gradient(135deg, #4a9eff 0%, #6bcf7f 100%); }
.btn-share    { background: linear-gradient(135deg, #ff6b9d 0%, #ff4757 100%); }
.btn-close    { background: linear-gradient(135deg, #ff9a6b, #ffb84a); }

/* ============ 子供向けダイアログ ============ */
.kid-dialog { padding: 24px 20px; }
.kid-dialog-emoji {
  font-size: 4rem;
  text-align: center;
  margin-bottom: 8px;
  animation: bounce 1.5s ease-in-out infinite;
}
.kid-dialog-msg {
  text-align: center;
  font-size: 1.2rem;
  color: var(--c-text);
  font-weight: 900;
  margin-bottom: 20px;
  line-height: 1.5;
  white-space: pre-line;
}
.btn-yes { background: linear-gradient(135deg, #6bcf7f, #4ad88a); color: white; }
.btn-no  { background: linear-gradient(135deg, #ffd0d0, #ffb0b0); color: #c43030; }

/* ============ ずかん画面 ============ */
#screen-zukan { background: linear-gradient(135deg, #f0e0ff 0%, #fff0f6 100%); }
.zukan-progress {
  background: linear-gradient(135deg, #b86bff, #ff6b9d);
  color: white;
  font-weight: 900;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 1rem;
  box-shadow: 0 3px 0 rgba(120,80,140,0.15);
}
.zukan-comp-banner {
  background: linear-gradient(135deg, #ffd93d, #ff8c1a);
  color: white;
  text-align: center;
  padding: 14px;
  font-size: 1.2rem;
  font-weight: 900;
  box-shadow: 0 4px 12px rgba(255,150,50,0.3);
  animation: bounce 1.5s ease-in-out infinite;
}
.zukan-comp-banner[hidden] { display: none !important; }
.zukan-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  padding: 16px;
  overflow-y: auto;
  align-content: start;
}
.zukan-card {
  background: white;
  border-radius: 20px;
  padding: 10px;
  box-shadow: var(--c-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  cursor: pointer;
  border: 3px solid white;
  transition: transform 0.15s;
}
.zukan-card:active { transform: scale(0.97); }
.zukan-card.locked { opacity: 0.6; filter: grayscale(0.8); }
.zukan-card.locked::after {
  content: '？';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 900;
  color: var(--c-text-soft);
  border-radius: 20px;
  pointer-events: none;
}
.zukan-thumb {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-cream);
  border-radius: 12px;
  pointer-events: none;
}
.zukan-thumb svg { width: 90%; height: 90%; pointer-events: none; }
.zukan-thumb svg * { pointer-events: none; }
.zukan-name {
  font-size: 0.95rem;
  font-weight: 900;
  text-align: center;
  color: var(--c-text);
}
.zukan-level {
  display: flex;
  gap: 2px;
  align-items: center;
  font-size: 0.85rem;
}
.zukan-star { color: #ffd93d; text-shadow: 0 1px 0 #d4a000; font-size: 1.05rem; }
.zukan-star.empty { color: #ddd; text-shadow: none; }
.zukan-count {
  font-size: 0.8rem;
  color: var(--c-text-soft);
}

/* ============ パーティー画面 ============ */
#screen-party { background: var(--c-cream); }
.party-header {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  gap: 10px;
  flex-shrink: 0;
  z-index: 5;
}
.party-actions { display: flex; gap: 8px; }
.party-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  margin: 12px;
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(120,80,140,0.15);
  border: 6px solid white;
  min-height: 0;
  background: white;
}
.party-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.party-bg svg { width: 100%; height: 100%; display: block; }
.party-items {
  position: absolute;
  inset: 0;
  touch-action: none;
}
.party-item {
  position: absolute;
  cursor: grab;
  transition: outline 0.15s;
  outline: 0 dashed transparent;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.25));
}
.party-item.selected {
  outline: 4px dashed #ff4081;
  outline-offset: 4px;
}
.party-item img {
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.party-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  text-align: center;
  color: var(--c-text-soft);
  gap: 8px;
  pointer-events: none;
  background: rgba(255,255,255,0.7);
}
.party-empty[hidden] { display: none !important; }
.party-item-controls {
  display: flex;
  gap: 6px;
  padding: 8px 14px;
  background: white;
  border-top: 2px solid var(--c-cream);
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: center;
}
.party-item-controls[hidden] { display: none !important; }
.party-ctrl-btn {
  border: none;
  background: var(--c-cream);
  font-family: inherit;
  font-weight: 900;
  font-size: 0.9rem;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  color: var(--c-text);
  box-shadow: 0 2px 0 rgba(120,80,140,0.1);
}
.party-ctrl-btn:active { transform: translateY(1px); }
.party-ctrl-remove { background: linear-gradient(135deg, #ffd0d0, #ffb0b0); color: #c43030; }

/* 吹き出し */
.party-bubble {
  position: absolute;
  background: white;
  border: 3px solid #5a4a6a;
  border-radius: 18px;
  padding: 8px 14px;
  font-size: 1rem;
  font-weight: 900;
  color: #5a4a6a;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  pointer-events: none;
  z-index: 2;
}
.party-bubble::after {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 30px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 12px solid #5a4a6a;
}
.party-bubble::before {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 33px;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 9px solid white;
  z-index: 1;
}

/* セリフダイアログ */
.talk-presets {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.talk-preset {
  border: 2px solid #ffd0e0;
  background: white;
  font-family: inherit;
  font-weight: 900;
  font-size: 0.95rem;
  padding: 12px 8px;
  border-radius: 12px;
  cursor: pointer;
  color: var(--c-text);
}
.talk-preset:active { transform: scale(0.95); background: #fff0f6; }
.talk-custom {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  align-items: center;
}
.talk-custom input {
  flex: 1;
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  padding: 10px 12px;
  border: 2px solid var(--c-pink);
  border-radius: 12px;
  outline: none;
  color: var(--c-text);
  min-width: 0;
}
.talk-custom input:focus { border-color: var(--c-pink-deep); }
.btn-talk-set {
  background: linear-gradient(135deg, #4a9eff 0%, #6bcf7f 100%);
  padding: 10px 16px !important;
  margin: 0 !important;
  font-size: 0.95rem !important;
}
.btn-talk-clear {
  background: linear-gradient(135deg, #ffd0d0, #ffb0b0);
  color: #c43030 !important;
  margin-bottom: 8px;
}

/* ============ 背景選択 ============ */
.bg-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.bg-option {
  border: 4px solid white;
  border-radius: 14px;
  background: var(--c-cream);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  aspect-ratio: 4/3;
  position: relative;
  box-shadow: 0 3px 0 rgba(120,80,140,0.1);
}
.bg-option.selected { border-color: var(--c-pink-deep); transform: scale(1.04); }
.bg-option svg { width: 100%; height: 100%; pointer-events: none; }
.bg-option-label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(255,255,255,0.85);
  color: var(--c-text);
  font-weight: 900;
  padding: 4px;
  text-align: center;
  font-size: 0.9rem;
}

/* ============ パーティー：作品選択ピッカー ============ */
.pick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
  max-height: 60vh;
  overflow-y: auto;
}
.pick-item {
  border: 3px solid white;
  background: var(--c-cream);
  border-radius: 12px;
  cursor: pointer;
  aspect-ratio: 1;
  padding: 4px;
  overflow: hidden;
}
.pick-item:active { transform: scale(0.95); }
.pick-item img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.pick-empty {
  text-align: center;
  padding: 20px;
  color: var(--c-text-soft);
  font-weight: 700;
}
.pick-empty[hidden] { display: none !important; }

/* ============ ホームのキャラカード：ずかん表示 ============ */
.char-card-stars {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(255,255,255,0.9);
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 1px;
  z-index: 2;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.char-card-stars span { color: #ffd93d; text-shadow: 0 1px 0 #d4a000; }

/* ============ Responsive ============ */
@media (max-width: 768px) {
  .palette-area { width: 240px; padding: 10px; gap: 10px; }
  .color-palette { grid-template-columns: repeat(4, 1fr); }
}

@media (orientation: portrait) and (max-width: 900px) {
  .paint-main { flex-direction: column; }
  .palette-area {
    width: 100%;
    height: auto;
    max-height: 35vh;
    flex-direction: column;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
  }
  .color-palette { grid-template-columns: repeat(8, 1fr); }
  .canvas-wrap { padding: 10px; }
}

@media (max-width: 500px) {
  .character-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .home-content { padding: 16px 12px 24px; }
  .palette-area { max-height: 38vh; }
  .color-palette { grid-template-columns: repeat(6, 1fr); }
}
