/* ============================================================================
   咩咩连连看 — 羊了个羊风 · 轻松休闲写意
   ========================================================================== */

:root {
  --cream: #FFF6E7;
  --cream-2: #FFEFD9;
  --card: #FFFDF8;
  --ink: #5C4A3D;
  --ink-soft: #9A8471;
  --coral: #FF8FAB;
  --coral-deep: #F76E8E;
  --sunny: #FFD166;
  --mint: #7FD8BE;
  --sky: #8ECAE6;
  --grape: #C3AED6;
  --line: #F3DFC2;
  --radius: 18px;
  --shadow-soft: 0 10px 30px rgba(190, 140, 90, .16);
}

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

[hidden] { display: none !important; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

body {
  background: linear-gradient(175deg, #FFF3DC 0%, var(--cream-2) 34%, #FFE4E0 72%, #FFDDE7 100%);
}

button {
  font-family: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}

/* ---------------------------------------------------------------- 背景场景 */

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

.sun {
  position: absolute;
  top: 6vh;
  right: 10vw;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #FFF3B8, #FFD166 70%);
  box-shadow: 0 0 46px rgba(255, 209, 102, .65);
  animation: sunBreath 6s ease-in-out infinite;
}

.cloud {
  position: absolute;
  width: 130px;
  height: 44px;
  background: rgba(255, 255, 255, .85);
  border-radius: 40px;
  filter: blur(.4px);
}
.cloud::before, .cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 50%;
}
.cloud::before { width: 56px; height: 56px; left: 20px; top: -26px; }
.cloud::after  { width: 40px; height: 40px; left: 64px; top: -18px; }
.c1 { top: 12%; animation: drift 52s linear infinite; }
.c2 { top: 30%; transform: scale(.66); opacity: .8; animation: drift 74s linear infinite reverse; }
.c3 { top: 52%; transform: scale(.45); opacity: .6; animation: drift 95s linear infinite; }

.hill {
  position: absolute;
  bottom: -12vh;
  width: 70vw;
  height: 30vh;
  border-radius: 50% 50% 0 0;
}
.h1 { left: -18vw; background: rgba(127, 216, 190, .5); }
.h2 { right: -22vw; background: rgba(142, 202, 230, .38); }

@keyframes drift {
  from { left: -160px; }
  to   { left: 110vw; }
}
@keyframes sunBreath {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

/* ---------------------------------------------------------------- 布局骨架 */

#app {
  position: relative;
  z-index: 1;
  height: 100dvh;
  max-width: 540px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 6px) 10px calc(env(safe-area-inset-bottom) + 8px);
}

.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* ---------------------------------------------------------------- 首页 */

#home {
  justify-content: center;
  gap: 12px;
  overflow-y: auto;
  padding-bottom: 4px;
}

.logo-block { text-align: center; }

.mascot {
  font-size: 52px;
  line-height: 1;
  animation: mascotBounce 2.6s ease-in-out infinite;
  filter: drop-shadow(0 8px 10px rgba(180, 120, 80, .25));
}

.logo {
  margin-top: 4px;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(180deg, #FF9FB6, #F76E8E 60%, #E85D80);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 6px 14px rgba(247, 110, 142, .22);
}
.logo i {
  font-style: normal;
  font-size: 22px;
  color: var(--ink);
  -webkit-text-fill-color: var(--ink);
  margin-left: 2px;
}

.tagline {
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 1px;
}

.mode-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mode-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--card);
  border-radius: var(--radius);
  border: 2px solid #fff;
  border-left: 6px solid var(--accent, var(--coral));
  box-shadow: var(--shadow-soft);
  text-align: left;
  transition: transform .15s ease, box-shadow .15s ease;
}
.mode-card:active { transform: scale(.97); }
@media (hover: hover) {
  .mode-card:hover { transform: translateY(-3px); box-shadow: 0 16px 34px rgba(190, 140, 90, .24); }
}

.mode-emoji {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 26px;
  background: color-mix(in srgb, var(--accent, var(--coral)) 16%, white);
}
.mode-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mode-name { font-size: 15.5px; font-weight: 800; }
.mode-desc { font-size: 11px; color: var(--ink-soft); }
.mode-record {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}
.mode-record b { font-size: 13px; font-weight: 800; color: var(--accent, var(--coral)); }
.mode-record i { font-style: normal; font-size: 10.5px; color: var(--ink-soft); }
.mode-arrow {
  flex: none;
  font-size: 22px;
  font-weight: 800;
  color: #D9C4A8;
  line-height: 1;
  margin-left: -2px;
}

.home-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.home-actions .btn { min-width: 0; padding: 8px 16px; font-size: 13px; }
.attribution {
  text-align: center;
  font-size: 10px;
  color: #C9B49B;
  letter-spacing: .5px;
}

/* ---------------------------------------------------------------- 通用按钮 */

.btn {
  min-width: 104px;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  background: linear-gradient(180deg, #FFF6EA, #FFE9CE);
  border: 2px solid #fff;
  box-shadow: 0 4px 0 #EBC99B, 0 8px 16px rgba(190, 140, 90, .18);
  transition: transform .1s, box-shadow .1s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #EBC99B; }
.btn.primary {
  background: linear-gradient(180deg, #FFA8BE, var(--coral) 55%, var(--coral-deep));
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .12);
  box-shadow: 0 4px 0 #D95578, 0 10px 18px rgba(247, 110, 142, .35);
}
.btn.primary:active { box-shadow: 0 1px 0 #D95578; }
.btn.ghost { background: rgba(255, 255, 255, .7); box-shadow: 0 3px 0 #EAD9BF; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  font-size: 16px;
  background: rgba(255, 255, 255, .82);
  border: 2px solid #fff;
  box-shadow: 0 3px 8px rgba(190, 140, 90, .16);
  display: grid;
  place-items: center;
  flex: none;
}
.icon-btn:active { transform: scale(.92); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .85);
  border: 2px solid #fff;
  box-shadow: 0 3px 8px rgba(190, 140, 90, .14);
  font-size: 12.5px;
  font-weight: 800;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- 游戏页顶部 */

.game-top {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 5px;
}
.mode-pill { --accent: var(--coral); color: var(--accent); flex: 1; justify-content: center; overflow: hidden; }

.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 24px;
  padding: 0 2px 4px;
}
.score-pill { color: #E8A23D; font-variant-numeric: tabular-nums; }

.combo-badge {
  font-size: 13px;
  font-weight: 900;
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, #FFB36B, #FF8A3D);
  box-shadow: 0 4px 10px rgba(255, 138, 61, .4);
  opacity: 0;
  transform: scale(.6);
  transition: opacity .18s, transform .18s;
}
.combo-badge.show { opacity: 1; transform: scale(1) rotate(-3deg); }

/* 时间条：羊了个羊式压迫感 */

.timer-wrap { position: relative; padding: 9px 2px 4px; }

.timer-bar {
  height: 10px;
  border-radius: 999px;
  background: #F1E3CB;
  box-shadow: inset 0 1px 3px rgba(160, 110, 60, .22);
  overflow: visible;
}

.timer-fill {
  position: relative;
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6FCEB2, #FFCF5C 62%, #FF9F6E);
  transition: width .35s linear;
}
.timer-fill.warn {
  background: linear-gradient(90deg, #FF9F6E, #F4574D);
  animation: warnBlink .55s ease-in-out infinite alternate;
}

.timer-sheep {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #FFE8C8;
  box-shadow: 0 3px 8px rgba(170, 120, 70, .28);
  display: grid;
  place-items: center;
  font-size: 16px;
  transition: left .35s linear;
  z-index: 2;
}

@keyframes warnBlink {
  from { filter: brightness(1); }
  to   { filter: brightness(1.18); }
}

/* ---------------------------------------------------------------- 棋盘 */

#board-area {
  position: relative;
  flex: 1;
  min-height: 0;
}

#board {
  position: absolute;
  border-radius: 18px;
  background:
    radial-gradient(circle at 22% 18%, rgba(255, 255, 255, .9), transparent 46%),
    linear-gradient(180deg, rgba(255, 253, 246, .96), rgba(255, 240, 219, .96));
  border: 3px solid #fff;
  box-shadow: var(--shadow-soft), inset 0 0 0 2px #FFE8C8;
}

#lines {
  position: absolute;
  pointer-events: none;
  overflow: visible;
  z-index: 30;
}

.tile {
  position: absolute;
  display: grid;
  place-items: center;
  border-radius: 22%;
  background: linear-gradient(180deg, #FFFFFF 20%, #FFF2DD);
  border: 2px solid #FFE2BC;
  box-shadow: 0 2.5px 0 #EFCC9E, 0 4px 8px rgba(170, 120, 70, .15);
  transition: transform .13s ease, box-shadow .13s ease, filter .18s, border-color .13s;
  z-index: 1;
}
.tile img { width: 72%; height: 72%; pointer-events: none; }

.tile.selected {
  transform: translateY(-4px) scale(1.07);
  border-color: var(--coral);
  box-shadow: 0 0 0 3px var(--coral), 0 9px 14px rgba(247, 110, 142, .3);
  z-index: 5;
}

.tile.hint { animation: hintPulse .85s ease-in-out infinite; }

.tile.matched {
  animation: matchedPop .36s ease forwards;
  pointer-events: none;
}

.tile.shake { animation: shake .4s ease; }

@keyframes hintPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 209, 102, .0), 0 3px 0 #EFCC9E; transform: scale(1); }
  50% { box-shadow: 0 0 0 6px rgba(255, 209, 102, .75), 0 3px 0 #EFCC9E; transform: scale(1.05); }
}
@keyframes matchedPop {
  40% { transform: scale(1.22) rotate(6deg); opacity: 1; }
  100% { transform: scale(.25) rotate(-14deg); opacity: 0; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px) rotate(-3deg); }
  55% { transform: translateX(5px) rotate(3deg); }
  80% { transform: translateX(-3px); }
}

/* 连线 */

.link-line { pointer-events: none; transition: opacity .3s; }
.line-main {
  fill: none;
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.line-glow {
  fill: none;
  stroke: rgba(255, 196, 128, .5);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: blur(2.5px);
}
.line-dot {
  fill: #fff;
  stroke: var(--coral);
  stroke-width: 3;
  animation: dotPulse .8s ease-out infinite;
}
@keyframes dotPulse {
  0% { transform: scale(.6); transform-origin: center; transform-box: fill-box; }
  70% { transform: scale(1.25); }
  100% { transform: scale(.6); }
}

/* ---------------------------------------------------------------- 道具 */

.props-row {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 5px 0 2px;
}

.prop-btn {
  position: relative;
  width: 60px;
  padding: 6px 0 5px;
  border-radius: 13px;
  background: var(--card);
  border: 2px solid #fff;
  box-shadow: 0 4px 0 #EBC99B, 0 7px 14px rgba(190, 140, 90, .18);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  transition: transform .1s, box-shadow .1s, filter .15s;
}
.prop-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #EBC99B; }
.prop-btn:disabled { filter: grayscale(.9); opacity: .55; }
.prop-btn.armed {
  border-color: var(--coral);
  box-shadow: 0 0 0 3px rgba(255, 143, 171, .5), 0 4px 0 #EBC99B;
  animation: armedWiggle .6s ease-in-out infinite alternate;
}
.prop-icon { font-size: 20px; line-height: 1.15; }
.prop-label { font-size: 10px; font-weight: 800; color: var(--ink-soft); }

@keyframes armedWiggle {
  from { transform: rotate(-2.5deg); }
  to   { transform: rotate(2.5deg); }
}

/* ---------------------------------------------------------------- 粒子 & 飘字 */

.particle {
  position: absolute;
  width: var(--sz, 8px);
  height: var(--sz, 8px);
  border-radius: 50%;
  pointer-events: none;
  z-index: 40;
  animation: burst .75s ease-out forwards;
}
@keyframes burst {
  from { transform: translate(0, 0) scale(1); opacity: 1; }
  to   { transform: translate(var(--dx), var(--dy)) scale(.15); opacity: 0; }
}

.float-text {
  position: absolute;
  transform: translateX(-50%);
  font-size: 17px;
  font-weight: 900;
  color: var(--coral-deep);
  text-shadow: 0 2px 0 #fff, 0 0 8px rgba(255, 255, 255, .8);
  pointer-events: none;
  z-index: 41;
  animation: floatUp 1s ease-out forwards;
  white-space: nowrap;
}
.float-text.combo { font-size: 19px; color: #FF8A3D; }
.float-text.time { color: #35B98F; font-size: 14px; }
@keyframes floatUp {
  from { transform: translate(-50%, 0); opacity: 1; }
  to   { transform: translate(-50%, -46px); opacity: 0; }
}

/* ---------------------------------------------------------------- 弹层 */

#overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(120, 78, 52, .42);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: grid;
  place-items: center;
  padding: 24px;
}
#overlay[hidden] { display: none; }

.overlay-card {
  width: min(320px, 88vw);
  background: linear-gradient(180deg, #FFFDF8, #FFF3E1);
  border-radius: 30px;
  border: 3px solid #fff;
  box-shadow: 0 24px 60px rgba(120, 70, 40, .35);
  padding: 20px 18px 18px;
  text-align: center;
  animation: cardPop .32s cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes cardPop {
  from { transform: scale(.7); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.overlay-card h2 { font-size: 21px; margin: 6px 0 4px; }
.win-face, .lose-face, .pause-face, .about-face { font-size: 50px; line-height: 1; }

.stars { display: flex; justify-content: center; gap: 6px; margin: 10px 0 4px; min-height: 40px; }
.star {
  font-size: 30px;
  filter: grayscale(1) opacity(.35);
  display: inline-block;
}
.star.on { animation: starPop .5s cubic-bezier(.34, 1.8, .64, 1) forwards; filter: none; }
@keyframes starPop {
  from { transform: scale(0) rotate(-40deg); }
  to   { transform: scale(1.15) rotate(0); }
}

.overlay-card.celebrate { pointer-events: auto; }
.celebrate-line { font-size: 14px; color: var(--ink-soft); margin-top: 4px; }
.celebrate-line b { color: #E8A23D; font-size: 16px; }
.celebrate-next {
  margin-top: 12px;
  font-size: 12.5px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, #FFB36B, #FF8A3D);
  padding: 7px 14px;
  border-radius: 999px;
  display: inline-block;
  animation: nextPulse 1.1s ease-in-out infinite;
}
@keyframes nextPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.final-score { font-size: 15px; color: var(--ink-soft); margin: 6px 0 2px; }
.final-score b { font-size: 24px; color: #E8A23D; margin-left: 4px; }
.lose-reason { font-size: 13.5px; color: var(--ink-soft); margin-bottom: 4px; }

.overlay-btns {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.rule-tip { font-size: 12px; color: var(--ink-soft); margin-top: 14px; line-height: 1.6; }

.run-sub { font-size: 12px; color: var(--ink-soft); margin-bottom: 8px; }
.run-section { text-align: left; margin-top: 8px; }
.run-mode { font-size: 13px; font-weight: 800; color: var(--ink); margin: 4px 0 4px 2px; }
.run-section ul { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.run-section li {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, .75);
  border: 1.5px solid #FFEFD9;
  border-radius: 12px;
  padding: 6px 10px;
}
.run-rank { flex: none; width: 26px; text-align: center; font-weight: 900; color: #C9B49B; font-size: 13px; }
.run-score { flex: 1; font-weight: 900; color: #E8A23D; font-size: 14.5px; }
.run-meta { font-size: 11px; color: var(--ink-soft); }
.run-empty { justify-content: center; color: var(--ink-soft); font-size: 12px; }

.howto-list { text-align: left; display: flex; flex-direction: column; gap: 9px; margin-top: 10px; }
.howto-list p { font-size: 12.5px; line-height: 1.75; color: var(--ink); }

.about-text { font-size: 13.5px; line-height: 1.9; margin-top: 8px; }
.about-fine { font-size: 11px; color: var(--ink-soft); line-height: 1.8; margin-top: 12px; }

/* ---------------------------------------------------------------- Toast */

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 96px);
  transform: translate(-50%, 16px);
  max-width: 82vw;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(92, 74, 61, .92);
  color: #FFF6E7;
  font-size: 13.5px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 99;
  text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- 小屏适配 */

@media (max-width: 375px) {
  .logo { font-size: 30px; }
  .mode-grid { gap: 8px; }
  .prop-btn { width: 56px; }
}

@media (min-width: 700px) {
  #app { max-width: 520px; }
}
