/* =========================================================================
 *  合成大西瓜 · 样式（移动端优先）
 * ========================================================================= */

:root {
  --ink:        #4a3222;
  --ink-soft:   #a28a76;
  --card:       #fffdf8;
  --accent-a:   #ffa04a;
  --accent-b:   #ff5f5f;
  --accent-dk:  #d9502c;
  --shadow-1:   0 2px 0 rgba(180, 140, 100, .16), 0 6px 16px rgba(190, 140, 90, .16);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(120% 70% at 50% -12%, #fffaf2 0%, #ffeada 48%, #ffd9b8 100%);
  background-attachment: fixed;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* ---------------------------------------------------------------- 布局 */
.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ---------------------------------------------------------------- 顶栏 */
.hud {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 10px 16px 4px;
}

.hud-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 56px;
}
.hud-cell.right { align-items: flex-end; }

.hud-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  color: var(--ink-soft);
  opacity: .9;
}

.hud-value {
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.score-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex: 1 1 auto;
}

.score {
  font-size: clamp(30px, 9.2vw, 42px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  color: #4a3222;
  text-shadow: 0 2px 0 rgba(255, 255, 255, .85);
}

.score.bump { animation: bump .22s cubic-bezier(.2, 1.4, .4, 1); }

@keyframes bump {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.14); }
  100% { transform: scale(1); }
}

.combo-tag {
  height: 15px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  color: #ff6a3d;
  opacity: 0;
  transform: translateY(-3px) scale(.9);
  transition: opacity .15s ease, transform .15s ease;
}
.combo-tag.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.hud-cell.right {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.next-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.next-chip {
  position: relative;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.next-chip img {
  width: 78%;
  height: 78%;
  object-fit: contain;
  display: none;
}
.next-chip img.on { display: block; }

.next-chip i {
  display: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ddd;
}
.next-chip i.on { display: block; }

.icon-btn {
  width: 36px;
  height: 36px;
  margin-top: 13px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: var(--card);
  color: var(--ink-soft);
  box-shadow: var(--shadow-1);
  cursor: pointer;
  transition: transform .1s ease, opacity .15s ease;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn.off { opacity: .45; }
.icon-btn.off .wave { display: none; }

/* ---------------------------------------------------------------- 舞台 */
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 2px 12px 10px;
}

canvas#game {
  display: block;
  border-radius: 26px;
  box-shadow: 0 12px 34px rgba(178, 116, 62, .22),
              0 1px 0 rgba(255, 255, 255, .9) inset;
  touch-action: none;
}

/* ---------------------------------------------------------------- 遮罩 */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(255, 240, 226, .74);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  transition: opacity .26s ease, visibility .26s ease;
}
.loading-box {
  text-align: center;
  padding: 0 22px;
  max-width: 300px;
}
.loading-text {
  font-size: 15px;
  color: #8a6038;
  line-height: 1.95;
}
.loading-text b { color: #cf5220; font-weight: 700; }
.loading-text .sub {
  display: block;
  margin-top: 6px;
  font-size: 11.5px;
  color: #a9855f;
  word-break: break-all;
}

.overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.panel {
  width: 100%;
  max-width: 320px;
  padding: 24px 22px 20px;
  text-align: center;
  border-radius: 28px;
  background: linear-gradient(180deg, #fffdf8 0%, #fff4e6 100%);
  box-shadow: 0 20px 44px rgba(160, 100, 60, .24),
              0 0 0 2px rgba(255, 255, 255, .85) inset;
  animation: panel-in .38s cubic-bezier(.2, 1.25, .4, 1) both;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(14px) scale(.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.btn {
  width: 100%;
  border: 0;
  border-radius: 18px;
  padding: 15px 20px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .06em;
  color: #fff;
  background: linear-gradient(180deg, var(--accent-a), var(--accent-b));
  box-shadow: 0 5px 0 var(--accent-dk), 0 12px 22px rgba(220, 90, 60, .3);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .08s ease, box-shadow .08s ease;
}
.btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--accent-dk), 0 6px 12px rgba(220, 90, 60, .26);
}

.over-title {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: .04em;
}

.badge {
  display: inline-block;
  margin-bottom: 10px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffc24a, #ff8a1f);
  box-shadow: 0 4px 10px rgba(230, 140, 40, .3);
  animation: badge-in .4s .12s cubic-bezier(.2, 1.4, .4, 1) both;
}
.badge.hidden { display: none; }
@keyframes badge-in {
  from { opacity: 0; transform: scale(.6); }
  to   { opacity: 1; transform: scale(1); }
}

.final {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin: 14px 0 4px;
}
.final span {
  font-size: 11px;
  letter-spacing: .14em;
  color: var(--ink-soft);
}
.final b {
  font-size: 46px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #ff9b52, #ff4f5e);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.final-best {
  margin-bottom: 20px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.final-best b { color: var(--ink); font-weight: 800; }

/* 横屏 / 矮屏微调 */
@media (max-height: 640px) {
  .hud { padding-top: 6px; }
  .score { font-size: 26px; }
  .panel { padding: 18px 18px 16px; }
}
