/* 奶了个奶 · 样式（与奶蛙小游戏系列统一的配色与卡片风格）
 * 三种布局：桌面（左舞台右侧栏）/ 竖屏手机（顶部紧凑状态栏 + 舞台）/ 横屏手机（舞台 + 窄侧栏，道具竖排） */
:root {
  --ink: #4a3325; --ink-soft: #8a7566; --cream: #fff7ec;
  --brand: #ff6b6b; --brand-dark: #e14b4b;
  --card: rgba(255, 255, 255, .74);
  --shadow: 0 18px 50px rgba(126, 84, 44, .18);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; touch-action: manipulation; }
body {
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  background-color: #fff9f1;
  background-image:
    radial-gradient(1200px 700px at 8% -12%, #ffe9bd 0%, transparent 60%),
    radial-gradient(900px 600px at 104% -6%, #d5f0ff 0%, transparent 55%),
    radial-gradient(1000px 780px at 50% 118%, #ffdbe6 0%, transparent 62%);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-text-size-adjust: 100%;
}
button { font-family: inherit; color: inherit; touch-action: manipulation; }

/* ---------- 整体布局：桌面左舞台右侧栏 ---------- */
.app {
  height: 100vh; height: 100dvh; padding: 16px 18px 12px;
  display: flex; justify-content: center; align-items: stretch; gap: 20px;
}
.stage-wrap { flex: 0 1 620px; min-width: 0; min-height: 0; display: flex; }
.stage {
  position: relative; flex: 1; min-width: 0; min-height: 0; border-radius: 24px; overflow: hidden;
  background-color: #fff3df;
  background-image:
    radial-gradient(520px 340px at 50% 8%, rgba(255, 255, 255, .75), transparent 70%),
    repeating-linear-gradient(135deg, rgba(255, 190, 120, .11) 0 16px, transparent 16px 32px);
  box-shadow: 0 26px 64px rgba(122, 80, 40, .3);
  touch-action: none;
}
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: pointer; }

/* ---------- 侧栏 ---------- */
.panel {
  flex: 0 0 300px; display: flex; flex-direction: column; gap: 14px; padding: 22px 20px 16px;
  background: var(--card); border-radius: 24px; box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, .8); align-self: flex-start; max-height: 100%;
}
.head h1 {
  margin: 0; font-size: 26px; line-height: 1.2; letter-spacing: .02em; display: inline-block;
  background: linear-gradient(100deg, #ff7a59, #ff4d6d 55%, #b13bff);
  -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
}
.head .sub { margin: 6px 0 0; font-size: 13px; color: var(--ink-soft); line-height: 1.5; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  background: rgba(255, 255, 255, .82); border-radius: 16px; padding: 10px 12px 8px;
  box-shadow: 0 4px 14px rgba(126, 84, 44, .08);
}
.stat .lb { display: block; font-size: 11px; letter-spacing: .12em; color: var(--ink-soft); white-space: nowrap; }
.stat .vl { display: block; font-size: 26px; font-weight: 800; line-height: 1.25; font-variant-numeric: tabular-nums; }
.stat.best .vl { color: #e79a1f; }
.stat .vl.pop { animation: statpop .35s ease-out; }
@keyframes statpop { 0% { transform: scale(1); } 40% { transform: scale(1.22); } 100% { transform: scale(1); } }

.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  appearance: none; border: 0; cursor: pointer; font-size: 14px; font-weight: 700; text-decoration: none;
  min-height: 44px; padding: 10px 11px; border-radius: 14px; background: #fff; color: var(--ink);
  box-shadow: 0 3px 10px rgba(126, 84, 44, .14); transition: transform .12s, box-shadow .12s;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px) scale(.97); }
.btn.primary {
  color: #fff; background: linear-gradient(135deg, #ff8a5b, #ff6b6b 50%, #e14b4b);
  box-shadow: 0 6px 16px rgba(225, 75, 75, .35);
}
.tips { margin: 0; padding: 0 0 0 18px; font-size: 12.5px; line-height: 1.7; color: var(--ink-soft); }
.tips b { color: var(--ink); }
.foot { margin: auto 0 0; font-size: 11px; color: var(--ink-soft); text-align: center; opacity: .85; }
.foot-m { display: none; margin: 0; text-align: center; font-size: 11px; line-height: 14px; color: var(--ink-soft); flex: 0 0 auto; }

/* ---------- 新手提示（第 1 关开头淡入，点第一张牌后消失）---------- */
.hint {
  position: absolute; left: 50%; top: 8px; z-index: 3; max-width: calc(100% - 20px); padding: 6px 12px; white-space: nowrap;
  border-radius: 14px; background: rgba(255, 255, 255, .9); color: var(--ink); font-size: 12.5px; font-weight: 700;
  line-height: 1.4; text-align: center; box-shadow: 0 6px 18px rgba(126, 84, 44, .18);
  opacity: 0; pointer-events: none; transform: translate(-50%, -6px); transition: opacity .3s, transform .3s;
}
.hint.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 道具栏（舞台底部）---------- */
.powerbar {
  position: absolute; left: 0; right: 0; bottom: 10px; display: flex; justify-content: center; gap: 10px; padding: 0 12px;
}
.pw {
  appearance: none; border: 0; cursor: pointer; flex: 1; max-width: 150px; height: 46px; min-height: 44px; border-radius: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 15px; font-weight: 800; color: #fff; position: relative;
  background: linear-gradient(180deg, #ffb35e, #ff8a4a); box-shadow: 0 5px 0 #d2622b, 0 8px 14px rgba(210, 98, 43, .3);
  transition: transform .1s, box-shadow .1s, filter .2s;
}
.pw[data-pw="moveOut"] { background: linear-gradient(180deg, #6fc8ff, #4a9df0); box-shadow: 0 5px 0 #2f72c2, 0 8px 14px rgba(47, 114, 194, .3); }
.pw[data-pw="shuffle"] { background: linear-gradient(180deg, #c79bff, #9a68f0); box-shadow: 0 5px 0 #6f41bd, 0 8px 14px rgba(111, 65, 189, .3); }
.pw:active { transform: translateY(4px); }
.pw .ic { font-size: 18px; line-height: 1; }
.pw.used, .pw:disabled { filter: grayscale(1) brightness(1.08); opacity: .55; cursor: default; box-shadow: 0 3px 0 #9a9a9a; transform: none; }
.pw.nope { animation: nope .35s; }
@keyframes nope { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ---------- 结束 / 过关浮层 ---------- */
.overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto;
  background: rgba(74, 51, 37, .38); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.ov-card {
  width: min(340px, 100%); margin: auto; text-align: center; padding: 22px 20px 20px; border-radius: 24px;
  background: var(--cream); box-shadow: 0 24px 60px rgba(60, 35, 15, .35);
  transform: scale(.6) translateY(20px); transition: transform .45s cubic-bezier(.2, 1.5, .4, 1);
}
.overlay.show .ov-card { transform: none; }
.ov-emoji { font-size: 44px; line-height: 1; }
.ov-card h2 { margin: 6px 0 2px; font-size: 32px; letter-spacing: .04em; display: inline-block; color: var(--brand-dark); }
.ov-sub { margin: 0 0 12px; font-size: 13.5px; color: var(--ink-soft); }
.ov-scores { display: flex; gap: 10px; margin-bottom: 10px; }
.ov-scores .stat { flex: 1; }
.ov-new { display: none; margin: 0 0 10px; font-size: 15px; font-weight: 800; color: #e79a1f; animation: statpop .8s ease-out infinite alternate; }
.ov-new.show { display: block; }
.ov-btns { display: flex; flex-direction: column; gap: 8px; }
.ov-btns .btn { width: 100%; padding: 12px 14px; font-size: 16px; }
.ov-btns .btn[hidden] { display: none; }

/* ---------- 竖屏手机：顶部一条紧凑状态栏 + 舞台占满其余空间 ---------- */
@media (max-width: 719px) and (max-aspect-ratio: 5/4) {
  .app {
    flex-direction: column; gap: 6px; justify-content: flex-start;
    padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }
  .panel {
    order: -1; flex: 0 0 auto; width: 100%; align-self: stretch; padding: 6px 8px 8px; gap: 6px 8px; max-height: none;
    display: grid; grid-template-columns: 1fr auto; align-items: center; border-radius: 20px;
  }
  .head { grid-column: 1; grid-row: 1; display: flex; align-items: baseline; gap: 8px; min-width: 0; }
  .head h1 { font-size: 20px; white-space: nowrap; }
  .head .sub, .tips, .foot { display: none; }
  .btns { grid-column: 2; grid-row: 1; flex-wrap: nowrap; gap: 8px; }
  .btn { width: 44px; min-height: 44px; height: 44px; padding: 0; font-size: 18px; border-radius: 14px; }
  .btn .tx { display: none; }
  .stats { grid-column: 1 / -1; grid-row: 2; grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .stat { border-radius: 12px; padding: 3px 4px 2px; text-align: center; }
  .stat .lb { font-size: 10px; letter-spacing: .06em; }
  .stat .vl { font-size: 18px; line-height: 1.15; }
  .stage-wrap { flex: 1 1 0; min-height: 0; width: 100%; }
  .stage { border-radius: 20px; }
  .foot-m { display: block; }
  .powerbar { bottom: 8px; gap: 8px; }
  .pw { height: 46px; font-size: 14px; max-width: 130px; }
  .ov-card h2 { font-size: 28px; }
}

/* 竖屏且不够高（360×640、375×667 这类）：标题收起，数据卡和三个小按钮合并成一条，把高度让给牌 */
@media (max-width: 719px) and (max-aspect-ratio: 5/4) and (max-height: 720px) {
  .panel { padding: 6px 8px; gap: 0 8px; }
  .head { display: none; }
  .stats { grid-column: 1; grid-row: 1; gap: 5px; }
  .btns { grid-column: 2; grid-row: 1; gap: 6px; }
  .stat { padding: 4px 2px 3px; }
  .stat .lb { font-size: 9.5px; letter-spacing: .02em; }
  .stat .vl { font-size: 17px; }
  .app { gap: 5px; }
}
@media (max-width: 339px) and (max-aspect-ratio: 5/4) { .stat.best { display: none; } .stats { grid-template-columns: repeat(3, 1fr); } }

/* ---------- 横屏手机 / 很矮的窗口：舞台 + 窄侧栏（道具栏挪进侧栏）；槽竖排在舞台右侧 ---------- */
@media (min-aspect-ratio: 5/4) and (max-height: 560px) {
  .app {
    flex-direction: row; gap: 10px; justify-content: center;
    padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }
  .stage-wrap { flex: 1 1 0; max-width: 760px; }
  .stage { border-radius: 18px; }
  .panel {
    flex: 0 0 172px; width: 172px; align-self: stretch; padding: 8px; gap: 6px; border-radius: 18px; overflow: hidden;
  }
  .head h1 { font-size: 19px; }
  .head .sub, .tips { display: none; }
  .stats { gap: 5px; }
  .stat { border-radius: 12px; padding: 3px 8px 2px; }
  .stat .lb { font-size: 10px; letter-spacing: .06em; }
  .stat .vl { font-size: 18px; line-height: 1.2; }
  .btns { flex-wrap: nowrap; gap: 6px; justify-content: space-between; }
  .btn { flex: 1; min-width: 44px; height: 44px; padding: 0; font-size: 18px; border-radius: 13px; }
  .btn .tx { display: none; }
  .foot { display: block; font-size: 10px; line-height: 1.3; }
  .foot-m { display: none; }
  /* 道具栏被 game.js 挪进侧栏（stage 里不留位置，牌能画得更大） */
  .powerbar { position: static; padding: 0; gap: 6px; justify-content: space-between; margin-top: 4px; }
  .pw { flex: 1; min-width: 44px; max-width: none; height: 48px; border-radius: 14px; }
  .pw .tx { display: none; }
  .pw .ic { font-size: 22px; }
  .ov-card { padding: 14px 16px; }
  .ov-emoji { font-size: 30px; }
  .ov-card h2 { font-size: 24px; margin: 2px 0; }
  .ov-sub { margin-bottom: 8px; }
  .ov-btns .btn { padding: 8px 12px; }
}
