* {
  box-sizing: border-box;
}

:root {
  --bg1: #fff7ed;
  --bg2: #ffe4e6;
  --card: rgba(255, 255, 255, 0.82);
  --text: #2b1b12;
  --muted: #7c5b4b;
  --primary: #ff6b00;
  --primary-dark: #dd4b00;
  --gold: #ffc83d;
  --line: rgba(255, 125, 0, 0.22);
  --shadow: 0 18px 45px rgba(120, 45, 0, 0.16);
}

html {
  touch-action: manipulation;
}

body {
  margin: 0;
  overflow-x: hidden;
  min-height: 100vh;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 200, 61, 0.48), transparent 32%),
    radial-gradient(circle at bottom right, rgba(255, 107, 0, 0.28), transparent 35%),
    linear-gradient(135deg, var(--bg1), var(--bg2));
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

.game-page {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 24px;
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary-dark);
  font-weight: 700;
  letter-spacing: 1px;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 6vw, 64px);
  line-height: 1;
  letter-spacing: 2px;
}

.subtitle {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

.home-link {
  flex: 0 0 auto;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #ff9f1c);
  text-decoration: none;
  font-weight: 700;
  padding: 12px 18px;
  border-radius: 999px;
  box-shadow: 0 10px 22px rgba(255, 107, 0, 0.28);
}

.hero-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.brand-home {
  color: inherit;
  text-decoration: none;
}

.game-layout {
  display: grid;
  grid-template-columns: 230px minmax(320px, 1fr) 260px;
  gap: 20px;
  align-items: start;
}

.panel,
.board-wrap {
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.panel {
  padding: 18px;
}

.score-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  margin-bottom: 12px;
  border-radius: 18px;
  background: rgba(255, 246, 226, 0.85);
  border: 1px solid rgba(255, 168, 0, 0.25);
}

.score-card span {
  color: var(--muted);
  font-weight: 700;
}

.score-card strong {
  font-size: 28px;
  color: var(--primary-dark);
}

.primary-btn {
  width: 100%;
  border: 0;
  cursor: pointer;
  margin: 8px 0 16px;
  padding: 14px 18px;
  border-radius: 18px;
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #ff9f1c);
  box-shadow: 0 12px 20px rgba(255, 107, 0, 0.28);
}

.primary-btn:active {
  transform: translateY(1px);
}

.tips {
  color: var(--muted);
  line-height: 1.7;
  font-size: 14px;
}

.tips h2,
.reward-panel h2 {
  margin: 6px 0 10px;
  color: var(--text);
  font-size: 20px;
}

.board-wrap {
  padding: 18px;
}

.message-bar {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: 18px;
  color: var(--primary-dark);
  font-weight: 800;
  background: rgba(255, 248, 220, 0.9);
  border: 1px dashed rgba(255, 107, 0, 0.32);
  text-align: center;
}

.board {
  width: 100%;
  max-width: 560px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  gap: 7px;
  padding: 10px;
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(255, 175, 75, 0.85), rgba(255, 80, 80, 0.75)),
    rgba(255, 255, 255, 0.5);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
  overflow: hidden;
}

.cell {
  border: 0;
  cursor: pointer;
  border-radius: 18px;
  font-size: clamp(24px, 5vw, 44px);
  line-height: 1;
  background: linear-gradient(145deg, #ffffff, #eef6ff);
  box-shadow:
    inset 0 -5px 0 rgba(0, 0, 0, 0.08),
    0 8px 14px rgba(107, 45, 0, 0.16);
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
  user-select: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  padding: 0;
}


/* 不同图标使用不同底色，避免黄色星星、闪电和淡黄色背景混在一起 */
.cell.icon-0 {
  background: linear-gradient(145deg, #fff1f0, #ffd0c7);
}

.cell.icon-1 {
  background: linear-gradient(145deg, #2f2a72, #635bff);
}

.cell.icon-2 {
  background: linear-gradient(145deg, #e0f7ff, #8bdfff);
}

.cell.icon-3 {
  background: linear-gradient(145deg, #17324d, #2f80ed);
}

.cell.icon-4 {
  background: linear-gradient(145deg, #eaffea, #9ce69c);
}

.cell.icon-5 {
  background: linear-gradient(145deg, #f0f4ff, #b9c8ff);
}

.cell:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
}

.cell.selected {
  outline: 4px solid var(--gold);
  transform: scale(1.08);
  box-shadow:
    0 0 0 6px rgba(255, 200, 61, 0.26),
    0 12px 24px rgba(255, 107, 0, 0.28);
}

.cell.matched {
  animation: pop 0.28s ease forwards;
}

.cell.new {
  animation: dropIn 0.28s ease;
}

.reward-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.reward-list li {
  padding: 12px;
  margin-bottom: 10px;
  border-radius: 16px;
  color: var(--muted);
  background: rgba(255, 246, 226, 0.8);
  border: 1px solid rgba(255, 168, 0, 0.22);
}

.reward-list li.done {
  color: var(--primary-dark);
  font-weight: 800;
  background: rgba(255, 225, 150, 0.78);
}

.toast {
  position: fixed;
  left: 50%;
  top: 28px;
  z-index: 20;
  transform: translate(-50%, -120px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  min-width: min(420px, calc(100vw - 36px));
  padding: 18px 22px;
  border-radius: 22px;
  color: #fff;
  text-align: center;
  font-size: 22px;
  font-weight: 900;
  background: linear-gradient(135deg, #ff6b00, #ff2d55);
  box-shadow: 0 18px 38px rgba(150, 34, 0, 0.28);
  transition: all 0.28s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

@keyframes pop {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  70% {
    transform: scale(1.28) rotate(6deg);
    opacity: 0.85;
  }
  100% {
    transform: scale(0.2);
    opacity: 0;
  }
}

@keyframes dropIn {
  from {
    transform: translateY(-26px) scale(0.9);
    opacity: 0.5;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@media (max-width: 980px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .panel {
    order: 2;
  }

  .board-wrap {
    order: 1;
  }

  .reward-panel {
    order: 3;
  }

  .board {
    width: 100%;
    max-width: 560px;
  }
}

@media (max-width: 620px) {
  .game-page {
    width: min(100% - 18px, 1180px);
    padding-top: 12px;
  }

  .hero {
    display: block;
    padding: 18px;
    border-radius: 22px;
  }

  .home-link {
    display: inline-block;
    margin-top: 16px;
  }

  .board-wrap {
    padding: 10px;
  }

  .board {
    gap: 5px;
    padding: 7px;
    border-radius: 18px;
  }

  .cell {
    border-radius: 12px;
  }

  .toast {
    top: 14px;
    font-size: 18px;
  }
}

/* v1.2 手机竖屏修复：防止棋盘右侧超出屏幕 */
@media (max-width: 620px) {
  .game-page {
    width: 100%;
    padding: 8px 8px 28px;
  }

  .hero {
    display: block;
    padding: 16px;
    border-radius: 22px;
  }

  .home-link {
    display: inline-block;
    margin-top: 16px;
  }

  .game-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .board-wrap {
    width: 100%;
    min-width: 0;
    padding: 8px;
    border-radius: 20px;
  }

  .message-bar {
    font-size: 18px;
    line-height: 1.5;
    padding: 9px 10px;
  }

  .board {
    width: 100%;
    max-width: 100%;
    aspect-ratio: 1 / 1;
    gap: 5px;
    padding: 7px;
    border-radius: 18px;
  }

  .cell {
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border-radius: 12px;
    font-size: clamp(22px, 8vw, 38px);
  }

  .panel {
    min-width: 0;
  }
}

@media (max-width: 380px) {
  .game-page {
    padding-left: 6px;
    padding-right: 6px;
  }

  .board-wrap {
    padding: 6px;
  }

  .board {
    gap: 4px;
    padding: 6px;
  }

  .cell {
    border-radius: 10px;
    font-size: clamp(20px, 7.5vw, 34px);
  }
}
