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

body {
  font-family: "Microsoft YaHei", "PingFang SC", "KaiTi", serif;
  background: #87c8f0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  user-select: none;
}

/* ========== 邱乙恩专属背景 ========== */
/* 邱=山丘暖褐 | 乙=草木青绿 | 恩=暖阳金辉 */

.bg-scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

/* 天空：恩泽暖阳 */
.bg-sky {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 75% 15%, rgba(255, 220, 150, 0.55) 0%, transparent 60%),
    linear-gradient(180deg,
      #fce4b8 0%,
      #a8d8f0 35%,
      #7ec8e8 65%,
      #5aad7a 100%
    );
}

/* 太阳：恩 */
.bg-sun {
  position: absolute;
  top: 6%;
  right: 14%;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff8e0 30%, #ffd080 70%, rgba(255, 180, 60, 0) 100%);
  box-shadow: 0 0 60px 20px rgba(255, 200, 100, 0.45);
  animation: sun-glow 4s ease-in-out infinite;
}

@keyframes sun-glow {
  0%, 100% { box-shadow: 0 0 60px 20px rgba(255, 200, 100, 0.45); transform: scale(1); }
  50%      { box-shadow: 0 0 80px 30px rgba(255, 210, 120, 0.6); transform: scale(1.05); }
}

/* 云朵 */
.bg-cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.75);
  border-radius: 50px;
  filter: blur(1px);
}

.bg-cloud::before,
.bg-cloud::after {
  content: '';
  position: absolute;
  background: inherit;
  border-radius: 50%;
}

.bg-cloud-1 {
  width: 100px; height: 32px;
  top: 12%; left: 8%;
  animation: cloud-drift 28s linear infinite;
}
.bg-cloud-1::before { width: 44px; height: 44px; top: -20px; left: 14px; }
.bg-cloud-1::after  { width: 56px; height: 36px; top: -14px; right: 10px; }

.bg-cloud-2 {
  width: 80px; height: 26px;
  top: 20%; left: 55%;
  animation: cloud-drift 36s linear infinite reverse;
  opacity: 0.7;
}
.bg-cloud-2::before { width: 36px; height: 36px; top: -16px; left: 10px; }
.bg-cloud-2::after  { width: 46px; height: 30px; top: -10px; right: 8px; }

.bg-cloud-3 {
  width: 60px; height: 20px;
  top: 8%; left: 35%;
  animation: cloud-drift 22s linear infinite;
  opacity: 0.5;
}
.bg-cloud-3::before { width: 28px; height: 28px; top: -12px; left: 8px; }
.bg-cloud-3::after  { width: 34px; height: 22px; top: -8px; right: 6px; }

@keyframes cloud-drift {
  0%   { transform: translateX(0); }
  100% { transform: translateX(60px); }
}

/* 五彩气球 */
.bg-balloon {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 1;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.12));
}

.balloon-body {
  position: relative;
  border-radius: 50% 50% 50% 50% / 55% 55% 45% 45%;
  box-shadow:
    inset -6px -10px 14px rgba(0, 0, 0, 0.12),
    inset 8px 8px 16px rgba(255, 255, 255, 0.45);
}

.balloon-body::before {
  content: '';
  position: absolute;
  top: 18%;
  left: 22%;
  width: 28%;
  height: 20%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  transform: rotate(-25deg);
}

.balloon-knot {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 7px solid rgba(0, 0, 0, 0.15);
  margin-top: -2px;
}

.balloon-string {
  width: 1px;
  background: linear-gradient(180deg, rgba(255,255,255,0.6), rgba(255,255,255,0.2));
  transform-origin: top center;
}

/* 气球颜色与位置 — 缓缓上升 */
.bg-balloon-1 { left: 6%;  animation: balloon-rise-1 48s linear infinite; }
.bg-balloon-1 .balloon-body { width: 42px; height: 52px; background: linear-gradient(145deg, #ff7b7b, #e84545); }
.bg-balloon-1 .balloon-string { height: 55px; animation: string-sway 5s ease-in-out infinite; }

.bg-balloon-2 { left: 22%; animation: balloon-rise-2 55s linear 8s infinite; }
.bg-balloon-2 .balloon-body { width: 34px; height: 42px; background: linear-gradient(145deg, #ffe066, #f5a623); }
.bg-balloon-2 .balloon-string { height: 42px; animation: string-sway 6s ease-in-out 0.5s infinite reverse; }

.bg-balloon-3 { left: 48%; animation: balloon-rise-3 42s linear 16s infinite; }
.bg-balloon-3 .balloon-body { width: 46px; height: 56px; background: linear-gradient(145deg, #7ec8ff, #3d9ee8); }
.bg-balloon-3 .balloon-string { height: 60px; animation: string-sway 7s ease-in-out 1.5s infinite; }

.bg-balloon-4 { right: 18%; animation: balloon-rise-4 50s linear 24s infinite; }
.bg-balloon-4 .balloon-body { width: 38px; height: 48px; background: linear-gradient(145deg, #ff9ed8, #e85aab); }
.bg-balloon-4 .balloon-string { height: 48px; animation: string-sway 5.5s ease-in-out 2s infinite reverse; }

.bg-balloon-5 { right: 6%;  animation: balloon-rise-5 58s linear 32s infinite; }
.bg-balloon-5 .balloon-body { width: 32px; height: 40px; background: linear-gradient(145deg, #8fe88f, #4caf50); }
.bg-balloon-5 .balloon-string { height: 38px; animation: string-sway 6.5s ease-in-out 0.8s infinite; }

.bg-balloon-6 { left: 68%; animation: balloon-rise-6 45s linear 40s infinite; }
.bg-balloon-6 .balloon-body { width: 30px; height: 38px; background: linear-gradient(145deg, #c9a0ff, #8b5cf6); }
.bg-balloon-6 .balloon-string { height: 35px; animation: string-sway 8s ease-in-out 3s infinite reverse; }

@keyframes balloon-rise-1 {
  0%   { transform: translate(0, 110vh) rotate(-4deg); opacity: 0; }
  5%   { opacity: 0.82; }
  90%  { opacity: 0.82; }
  100% { transform: translate(20px, -25vh) rotate(3deg); opacity: 0; }
}
@keyframes balloon-rise-2 {
  0%   { transform: translate(0, 110vh) rotate(3deg); opacity: 0; }
  5%   { opacity: 0.75; }
  90%  { opacity: 0.75; }
  100% { transform: translate(-25px, -25vh) rotate(-2deg); opacity: 0; }
}
@keyframes balloon-rise-3 {
  0%   { transform: translate(0, 110vh) rotate(-2deg); opacity: 0; }
  5%   { opacity: 0.8; }
  90%  { opacity: 0.8; }
  100% { transform: translate(15px, -25vh) rotate(4deg); opacity: 0; }
}
@keyframes balloon-rise-4 {
  0%   { transform: translate(0, 110vh) rotate(4deg); opacity: 0; }
  5%   { opacity: 0.78; }
  90%  { opacity: 0.78; }
  100% { transform: translate(-18px, -25vh) rotate(-3deg); opacity: 0; }
}
@keyframes balloon-rise-5 {
  0%   { transform: translate(0, 110vh) rotate(-3deg); opacity: 0; }
  5%   { opacity: 0.7; }
  90%  { opacity: 0.7; }
  100% { transform: translate(22px, -25vh) rotate(2deg); opacity: 0; }
}
@keyframes balloon-rise-6 {
  0%   { transform: translate(0, 110vh) rotate(2deg); opacity: 0; }
  5%   { opacity: 0.65; }
  90%  { opacity: 0.65; }
  100% { transform: translate(-12px, -25vh) rotate(-4deg); opacity: 0; }
}

@keyframes string-sway {
  0%, 100% { transform: rotate(0deg); }
  50%      { transform: rotate(6deg); }
}

/* 山丘：邱 */
.bg-hill {
  position: absolute;
  bottom: 0;
  border-radius: 50% 50% 0 0;
}

.bg-hill-far {
  width: 140%;
  height: 38%;
  left: -20%;
  background: linear-gradient(180deg, #8fbc7a 0%, #6a9e62 100%);
  opacity: 0.55;
}

.bg-hill-mid {
  width: 120%;
  height: 30%;
  left: -10%;
  background: linear-gradient(180deg, #6aad5e 0%, #4d8f48 100%);
  opacity: 0.75;
}

.bg-hill-near {
  width: 110%;
  height: 22%;
  left: -5%;
  background: linear-gradient(180deg, #56a04a 0%, #3d7a38 100%);
}

/* 草地纹理：乙 */
.bg-grass {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 18%;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0px, transparent 18px,
      rgba(255,255,255,0.04) 18px, rgba(255,255,255,0.04) 20px
    ),
    linear-gradient(0deg, #2e6b30 0%, #3d8a40 40%, transparent 100%);
}

/* 名字水印 */
.bg-name {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(5rem, 18vw, 9rem);
  font-family: "KaiTi", "STKaiti", "楷体", serif;
  font-weight: bold;
  color: rgba(255, 255, 255, 0.07);
  letter-spacing: 0.35em;
  white-space: nowrap;
  text-shadow: 0 2px 20px rgba(255, 220, 150, 0.15);
  pointer-events: none;
}

/* 装饰羊 */
.bg-sheep {
  position: absolute;
  font-size: 1.6rem;
  opacity: 0.35;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

.bg-sheep-1 { bottom: 22%; left: 10%; animation: sheep-bob 3s ease-in-out infinite; }
.bg-sheep-2 { bottom: 28%; right: 12%; font-size: 1.2rem; animation: sheep-bob 4s ease-in-out 1s infinite; }
.bg-sheep-3 { bottom: 18%; left: 72%; font-size: 1rem; opacity: 0.25; animation: sheep-bob 3.5s ease-in-out 0.5s infinite; }

@keyframes sheep-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* 飘叶：乙 */
.bg-leaf {
  position: absolute;
  font-size: 1.1rem;
  opacity: 0.4;
}

.bg-leaf-1 { top: 30%; left: 18%; animation: leaf-fall 12s linear infinite; }
.bg-leaf-2 { top: 22%; left: 68%; animation: leaf-fall 16s linear 4s infinite; font-size: 0.9rem; }
.bg-leaf-3 { top: 38%; left: 45%; animation: leaf-fall 14s linear 8s infinite; font-size: 0.8rem; }

@keyframes leaf-fall {
  0%   { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  10%  { opacity: 0.4; }
  90%  { opacity: 0.3; }
  100% { transform: translate(40px, 120px) rotate(180deg); opacity: 0; }
}

#app {
  width: 100%;
  max-width: 420px;
  height: 100vh;
  max-height: 780px;
  position: relative;
  z-index: 1;
}

/* ---- 背景音乐按钮 ---- */
.btn-music {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-music:hover {
  transform: scale(1.1);
  background: #fff;
}

.btn-music.muted {
  opacity: 0.65;
}

/* ---- 屏幕切换 ---- */
.screen {
  display: none;
  flex-direction: column;
  height: 100%;
  padding: 16px;
}

.screen.active {
  display: flex;
}

/* ---- 开始界面 ---- */
.title {
  font-size: 2.4rem;
  text-align: center;
  color: #fff;
  text-shadow: 2px 2px 8px rgba(0,0,0,.3), 0 0 30px rgba(255,200,100,.3);
  margin-top: 48px;
}

.subtitle {
  text-align: center;
  color: rgba(255,255,255,.92);
  margin: 8px 0 32px;
  font-size: .88rem;
  text-shadow: 1px 1px 4px rgba(0,0,0,.25);
  letter-spacing: 0.05em;
}

.level-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 8px 16px;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.level-list::-webkit-scrollbar {
  width: 4px;
}

.level-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.35);
  border-radius: 4px;
}

.level-btn {
  background: rgba(255,255,255,.92);
  border: none;
  border-radius: 14px;
  padding: 16px 20px;
  font-size: 1.05rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
  transition: transform .15s, box-shadow .15s;
}

.level-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,.18);
}

.level-btn .difficulty {
  font-size: .8rem;
  color: #888;
}

.level-btn .difficulty.easy { color: #56ab2f; }
.level-btn .difficulty.medium { color: #f5a623; }
.level-btn .difficulty.hard { color: #e74c3c; }
.level-btn .difficulty.extreme { color: #9b59b6; }

/* ---- 游戏头部 ---- */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 12px;
}

.level-name {
  font-size: 1.1rem;
  font-weight: bold;
  color: #fff;
  text-shadow: 1px 1px 3px rgba(0,0,0,.2);
}

.btn-icon {
  background: rgba(255,255,255,.25);
  border: none;
  color: #fff;
  font-size: 1.3rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  transition: background .15s;
}

.btn-icon:hover {
  background: rgba(255,255,255,.4);
}

/* ---- 牌面区域 ---- */
.board {
  flex: 1;
  position: relative;
  background: rgba(255,255,255,.22);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 16px;
  margin-bottom: 12px;
  overflow: hidden;
  backdrop-filter: blur(4px);
  box-shadow: inset 0 2px 12px rgba(255,255,255,.1);
}

/* ---- 单张牌 ---- */
.tile {
  position: absolute;
  width: 52px;
  height: 52px;
  background: #fffef5;
  border: 2px solid #e8dcc8;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, opacity .2s;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}

.tile.clickable {
  border-color: #f5c842;
  box-shadow: 0 3px 10px rgba(245,200,66,.4);
}

.tile.clickable:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 14px rgba(245,200,66,.55);
}

.tile.blocked {
  opacity: .45;
  cursor: not-allowed;
  filter: grayscale(30%);
}

.tile.removing {
  animation: pop-out .3s ease forwards;
}

@keyframes pop-out {
  0%   { transform: scale(1); opacity: 1; }
  50%  { transform: scale(1.3); opacity: .6; }
  100% { transform: scale(0); opacity: 0; }
}

.tile.entering {
  animation: pop-in .25s ease;
}

@keyframes pop-in {
  0%   { transform: scale(0); }
  70%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* ---- 槽位 ---- */
.slot-area {
  margin-bottom: 10px;
}

.slot-bar {
  display: flex;
  justify-content: center;
  gap: 6px;
  background: rgba(0,0,0,.15);
  border-radius: 14px;
  padding: 10px 8px;
  min-height: 72px;
}

.slot-cell {
  width: 48px;
  height: 48px;
  background: rgba(255,255,255,.12);
  border: 2px dashed rgba(255,255,255,.3);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: background .2s, border-color .2s;
}

.slot-cell.filled {
  background: #fffef5;
  border: 2px solid #e8dcc8;
  border-style: solid;
  box-shadow: 0 2px 4px rgba(0,0,0,.1);
}

.slot-cell.danger {
  border-color: #e74c3c;
  background: rgba(231,76,60,.15);
  animation: pulse-danger .6s ease infinite;
}

@keyframes pulse-danger {
  0%, 100% { box-shadow: 0 0 0 0 rgba(231,76,60,.4); }
  50%      { box-shadow: 0 0 8px 2px rgba(231,76,60,.5); }
}

.slot-hint {
  text-align: center;
  font-size: .78rem;
  color: rgba(255,255,255,.7);
  margin-top: 4px;
  min-height: 1.2em;
}

/* ---- 道具栏 ---- */
.props-bar {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding-bottom: 8px;
}

.btn-prop {
  background: rgba(255,255,255,.85);
  border: none;
  border-radius: 12px;
  width: 72px;
  height: 56px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 1.2rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
  transition: transform .12s, opacity .12s;
}

.btn-prop span { line-height: 1; }
.btn-prop small { font-size: .65rem; color: #666; }

.btn-prop:hover:not(:disabled) {
  transform: translateY(-2px);
}

.btn-prop:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* ---- 弹窗 ---- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #fff;
  border-radius: 20px;
  padding: 32px 28px;
  text-align: center;
  max-width: 300px;
  width: 85%;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
  animation: modal-in .3s ease;
}

@keyframes modal-in {
  from { transform: scale(.8); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.modal-content h2 {
  font-size: 1.6rem;
  margin-bottom: 8px;
}

.modal-content p {
  color: #666;
  margin-bottom: 24px;
  font-size: .95rem;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.btn-primary, .btn-secondary {
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  font-size: .95rem;
  cursor: pointer;
  transition: transform .12s;
}

.btn-primary {
  background: #56ab2f;
  color: #fff;
}

.btn-secondary {
  background: #eee;
  color: #333;
}

.btn-primary:hover, .btn-secondary:hover {
  transform: scale(1.05);
}
