/* ═══════════════════════════════════════════════════════════════
   墨韵·调色 (Ink Color Mix) — Complete Stylesheet
   ═══════════════════════════════════════════════════════════════ */

/* ── Reset ── */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #f5f0e6;
  touch-action: none;
  font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', serif;
}

/* ── Keyframe Animations ── */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes slideDown {
  from { transform: translateY(-30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes scaleIn {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes bounceIn {
  0% { transform: scale(0); }
  50% { transform: scale(1.15); }
  70% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 15px rgba(180,140,60,0.3); }
  50% { box-shadow: 0 0 30px rgba(180,140,60,0.6); }
}

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

@keyframes ripple {
  0% { transform: scale(0); opacity: 0.6; }
  100% { transform: scale(2.5); opacity: 0; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(15px, -10px) scale(1.05); }
  66% { transform: translate(-10px, 5px) scale(0.95); }
  100% { transform: translate(0, 0) scale(1); }
}

@keyframes starPop {
  0% { transform: scale(0) rotate(-30deg); opacity: 0; }
  60% { transform: scale(1.3) rotate(5deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

@keyframes confetti {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

@keyframes inkFloat {
  0% { transform: translateY(0) scale(1); opacity: 0.5; }
  50% { transform: translateY(-20px) scale(1.1); opacity: 0.7; }
  100% { transform: translateY(0) scale(1); opacity: 0.5; }
}

@keyframes watercolorIn {
  0% { transform: scale(0) rotate(-10deg); opacity: 0; }
  60% { transform: scale(1.1) rotate(3deg); opacity: 0.8; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

@keyframes numberPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

@keyframes bgBlob1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -20px) scale(1.1); }
  50% { transform: translate(-10px, 15px) scale(0.9); }
  75% { transform: translate(20px, 10px) scale(1.05); }
}

@keyframes bgBlob2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(-25px, 15px) scale(0.95); }
  50% { transform: translate(15px, -10px) scale(1.1); }
  75% { transform: translate(-15px, -20px) scale(1); }
}

/* ── App Container ── */
#app {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background: linear-gradient(170deg, #f8f3e9 0%, #f0e8d8 50%, #e8dfd0 100%);
}

/* ── Paper texture overlay ── */
#app::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  background-size: 256px 256px;
}

/* ── Background Blobs ── */
.bg-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}

.bg-blob-1 {
  width: 200px;
  height: 200px;
  background: #e8a0a0;
  top: 10%;
  left: -5%;
  animation: bgBlob1 12s ease-in-out infinite;
}

.bg-blob-2 {
  width: 180px;
  height: 180px;
  background: #a0c8e8;
  top: 40%;
  right: -8%;
  animation: bgBlob2 15s ease-in-out infinite;
}

.bg-blob-3 {
  width: 160px;
  height: 160px;
  background: #e8d8a0;
  bottom: 10%;
  left: 20%;
  animation: bgBlob1 18s ease-in-out infinite reverse;
}

/* ── Screens ── */
.screen {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
  transform: translateX(30px);
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.screen.slide-left {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-30px);
}

/* ── Overlays ── */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(40, 30, 20, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.overlay-card {
  background: rgba(255, 252, 245, 0.97);
  border-radius: 20px;
  padding: 28px 24px;
  width: 85%;
  max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  transform: translateY(60px);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.overlay.active .overlay-card {
  transform: translateY(0);
}

.overlay-card-center {
  text-align: center;
}

/* ── Buttons ── */
.game-btn {
  border: none;
  outline: none;
  cursor: pointer;
  font-family: inherit;
  border-radius: 14px;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.game-btn:active {
  transform: scale(0.93) !important;
}

.game-btn .ripple-circle {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  transform: scale(0);
  animation: ripple 0.5s ease-out forwards;
  pointer-events: none;
}

.btn-primary {
  background: linear-gradient(135deg, #b8405a, #d4607a);
  color: #fff;
  box-shadow: 0 4px 15px rgba(184, 64, 90, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(184, 64, 90, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(200, 190, 175, 0.8);
  color: #4a3828;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.btn-secondary:hover {
  background: rgba(210, 200, 185, 0.9);
}

.btn-gold {
  background: linear-gradient(135deg, #d4a843, #e8c060);
  color: #4a3828;
  box-shadow: 0 4px 15px rgba(212, 168, 67, 0.3);
}

/* ── Splash Screen ── */
#screen-splash .splash-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#screen-splash .splash-logo {
  font-size: 56px;
  font-weight: 700;
  color: #3a2a1a;
  animation: watercolorIn 1s ease-out forwards;
  text-shadow: 2px 2px 8px rgba(0,0,0,0.08);
}

#screen-splash .splash-sub {
  font-size: 28px;
  color: #8a7560;
  margin-top: 8px;
  opacity: 0;
  animation: fadeIn 0.8s ease-out 0.6s forwards;
}

#screen-splash .splash-inks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.splash-ink {
  position: absolute;
  border-radius: 50%;
  opacity: 0.3;
  animation: inkFloat 4s ease-in-out infinite;
}

/* ── Menu Screen ── */
#screen-menu .menu-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#screen-menu .menu-title {
  font-size: 42px;
  font-weight: 700;
  color: #3a2a1a;
  animation: float 4s ease-in-out infinite;
  text-shadow: 1px 1px 4px rgba(0,0,0,0.06);
}

#screen-menu .menu-subtitle {
  font-size: 15px;
  color: #a09080;
  margin-top: 4px;
  animation: fadeIn 0.6s ease-out 0.3s both;
}

.menu-colors {
  display: flex;
  gap: 20px;
  margin: 30px 0;
  animation: fadeIn 0.8s ease-out 0.5s both;
}

.menu-color-dot {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  box-shadow: 0 3px 12px rgba(0,0,0,0.15);
  animation: float 3s ease-in-out infinite;
}

.menu-color-dot:nth-child(1) {
  background: radial-gradient(circle at 35% 35%, #f06060, #c03030);
  animation-delay: 0s;
}

.menu-color-dot:nth-child(2) {
  background: radial-gradient(circle at 35% 35%, #f0d840, #c0a020);
  animation-delay: 0.5s;
}

.menu-color-dot:nth-child(3) {
  background: radial-gradient(circle at 35% 35%, #6080f0, #3050c0);
  animation-delay: 1s;
}

.menu-btns {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 70%;
  max-width: 260px;
  animation: slideUp 0.6s ease-out 0.7s both;
}

.menu-btns .game-btn {
  padding: 14px 0;
  font-size: 17px;
}

.menu-footer {
  position: absolute;
  bottom: 30px;
  font-size: 12px;
  color: #c0b8a8;
  animation: fadeIn 1s ease-out 1.2s both;
}

.sound-toggle {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(200,190,175,0.6);
  border: none;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.2s;
  animation: fadeIn 0.5s ease-out 1s both;
}

.sound-toggle:active {
  transform: scale(0.9);
}

/* ── Level Select Screen ── */
.level-header {
  width: 100%;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.level-header .back-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(200,190,175,0.7);
  border: none;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
  color: #4a3828;
}

.level-header .back-btn:active {
  transform: scale(0.9);
}

.level-header h2 {
  font-size: 20px;
  color: #3a2a1a;
  font-weight: 600;
}

.level-scroll {
  flex: 1;
  width: 100%;
  overflow-y: auto;
  padding: 0 16px 30px;
  -webkit-overflow-scrolling: touch;
}

.chapter-title {
  font-size: 15px;
  color: #8a7560;
  margin: 16px 0 10px;
  padding-left: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chapter-title::before,
.chapter-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, #d0c8b8, transparent);
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.level-card {
  aspect-ratio: 1;
  border-radius: 14px;
  position: relative;
  background: rgba(255,252,245,0.9);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  animation: scaleIn 0.4s ease-out forwards;
}

.level-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

.level-card:active {
  transform: scale(0.95);
}

.level-card.locked {
  background: rgba(220,215,205,0.6);
  cursor: default;
}

.level-card.locked:hover {
  transform: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.level-card .lv-color {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.level-card .lv-num {
  font-size: 12px;
  color: #6a5a4a;
  margin-top: 4px;
  font-weight: 600;
}

.level-card .lv-stars {
  font-size: 10px;
  color: #d4a843;
  margin-top: 2px;
  letter-spacing: 1px;
}

.level-card .lv-lock {
  font-size: 22px;
  color: #b0a898;
}

.level-card .lv-name {
  font-size: 10px;
  color: #a09080;
  margin-top: 4px;
}

/* ── Game Screen ── */
.game-header {
  width: 100%;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,252,245,0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(200,190,175,0.3);
  z-index: 2;
}

.game-header .back-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(200,190,175,0.5);
  border: none;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
  color: #4a3828;
}

.game-header .back-btn:active {
  transform: scale(0.9);
}

.game-header .level-title {
  font-size: 16px;
  color: #3a2a1a;
  font-weight: 600;
}

.game-header .pause-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(200,190,175,0.5);
  border: none;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
  color: #4a3828;
}

.game-header .pause-btn:active {
  transform: scale(0.9);
}

.game-canvas-area {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 0;
}

#mix-canvas {
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.drop-info {
  width: 100%;
  padding: 8px 20px;
  display: flex;
  justify-content: center;
  gap: 20px;
  font-size: 13px;
  color: #6a5a4a;
}

.drop-info .drop-count {
  display: flex;
  align-items: center;
  gap: 4px;
}

.drop-info .drop-count .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot-red { background: #e04040; }
.dot-yellow { background: #e0c030; }
.dot-blue { background: #4060e0; }

.drop-info .drop-count .num {
  font-weight: 700;
  min-width: 14px;
  text-align: center;
  transition: transform 0.2s;
}

.drop-info .drop-count .num.pop {
  animation: numberPop 0.3s ease;
}

.drop-info .drop-total {
  font-weight: 600;
  color: #8a7560;
  background: rgba(200,190,175,0.3);
  padding: 2px 10px;
  border-radius: 10px;
}

.action-buttons {
  width: 100%;
  padding: 8px 20px 24px;
  display: flex;
  justify-content: center;
  gap: 10px;
}

.action-buttons .game-btn {
  padding: 10px 20px;
  font-size: 14px;
  min-width: 80px;
}

.action-buttons .confirm-btn {
  min-width: 120px;
}

/* ── Tutorial ── */
.tutorial-bubble {
  position: absolute;
  z-index: 20;
  background: rgba(255,252,245,0.97);
  border-radius: 16px;
  padding: 14px 18px;
  max-width: 260px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  font-size: 14px;
  color: #3a2a1a;
  line-height: 1.6;
  animation: scaleIn 0.3s ease-out;
  text-align: center;
}

.tutorial-bubble::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid rgba(255,252,245,0.97);
}

.tutorial-bubble .tutorial-ok {
  margin-top: 10px;
  padding: 6px 20px;
  border-radius: 10px;
  background: #d4a843;
  color: #4a3828;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  transition: transform 0.15s;
}

.tutorial-bubble .tutorial-ok:active {
  transform: scale(0.93);
}

.tutorial-highlight {
  position: absolute;
  z-index: 19;
  border: 3px solid #d4a843;
  border-radius: 16px;
  animation: pulseGlow 1.5s ease-in-out infinite;
  pointer-events: none;
}

/* ── Win Overlay ── */
.win-title {
  font-size: 26px;
  font-weight: 700;
  color: #3a2a1a;
  animation: bounceIn 0.5s ease-out;
}

.win-stars {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 16px 0;
}

.win-stars .star {
  font-size: 36px;
  color: #d4a843;
  opacity: 0;
  text-shadow: 0 2px 8px rgba(212,168,67,0.3);
}

.win-stars .star.active {
  animation: starPop 0.5s ease-out forwards;
}

.win-stars .star.inactive {
  color: #d8d0c0;
  opacity: 1;
}

.win-match {
  font-size: 28px;
  font-weight: 700;
  margin: 8px 0;
}

.win-colors {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin: 12px 0;
}

.win-color-item {
  text-align: center;
}

.win-color-item .wc {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  margin: 0 auto;
}

.win-color-item .wl {
  font-size: 11px;
  color: #a09080;
  margin-top: 4px;
}

.win-btns {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.win-btns .game-btn {
  flex: 1;
  padding: 12px 0;
  font-size: 15px;
}

/* ── Fail Overlay ── */
.fail-title {
  font-size: 24px;
  font-weight: 700;
  color: #3a2a1a;
  animation: shake 0.5s ease;
}

.fail-sub {
  font-size: 14px;
  color: #8a7560;
  margin: 8px 0 4px;
}

.fail-match {
  font-size: 20px;
  font-weight: 600;
  color: #b8405a;
  margin: 8px 0;
}

.fail-encourage {
  font-size: 13px;
  color: #a09080;
  margin: 4px 0 16px;
}

.fail-btns {
  display: flex;
  gap: 10px;
}

.fail-btns .game-btn {
  flex: 1;
  padding: 12px 0;
  font-size: 15px;
}

/* ── FX Canvas ── */
#fx-canvas {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}

/* ── Confetti pieces ── */
.confetti-piece {
  position: fixed;
  z-index: 101;
  pointer-events: none;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

/* ── Responsive ── */
@media (max-height: 600px) {
  .game-canvas-area {
    flex: 0.8;
  }
}

@media (min-width: 500px) {
  /* wider screens can have slightly larger elements if needed */
}
