:root {
  --wood: #c98d4f;
  --wood-dark: #8a5528;
  --wood-light: #e8c08a;
  --cream: #fff7e6;
  --cream-2: #f6e7c8;
  --slot: #cfe0b4;
  --slot-edge: #b9cf98;
  --text: #6b4220;
  --green: #5cbf3a;
  --green-dark: #3e9a23;
  --gap: 0px;
  --cell: 64px;
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse at 50% -10%, #e9f7ff 0%, #bfe6ff 30%, transparent 60%),
    linear-gradient(180deg, #bfe6ff 0%, #d9f0c4 38%, #a8d982 100%);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

button { font: inherit; color: inherit; cursor: pointer; border: 0; }

.app {
  height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 14px max(12px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

/* ---------- top ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; }
.round-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(#fff9ec, #f1dcb5);
  box-shadow: 0 3px 0 #c9a46c, 0 5px 10px rgba(0,0,0,.15);
  font-size: 24px; font-weight: 800; line-height: 1;
}
.round-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #c9a46c; }
.round-btn.hidden { visibility: hidden; }
.level-sign {
  padding: 8px 18px; white-space: nowrap; border-radius: 12px;
  background: linear-gradient(#c88a4c, #a8692f);
  border: 3px solid #7e4a1e;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.25), 0 4px 8px rgba(0,0,0,.2);
  color: #fff7e2; font-size: 20px; font-weight: 900; letter-spacing: 2px;
  text-shadow: 0 2px 0 #6c3c14;
}

/* ---------- score & combo ---------- */
.hud { position: relative; height: 58px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; flex-shrink: 0; }
.hud .score { grid-column: 2; grid-row: 1; }
.hud .combo { grid-row: 1; }
.score {
  position: relative; display: flex; align-items: baseline; gap: 6px;
  padding: 3px 16px 5px; border-radius: 999px;
  background: rgba(255,250,235,.85); box-shadow: 0 2px 0 #d8b98a, 0 3px 8px rgba(0,0,0,.12);
}
.score small { font-size: 13px; font-weight: 800; color: #9a6b3c; }
.score b { font-size: 24px; font-weight: 900; font-variant-numeric: tabular-nums; color: #6b4220; min-width: 1.5em; text-align: center; }
.score.bump b { animation: bump .3s ease-out; }
@keyframes bump { 40% { transform: scale(1.25); color: #e8590c; } }
.score-pop {
  position: absolute; left: 100%; top: -4px; margin-left: 4px;
  font: 900 18px/1 "ZCOOL QingKe HuangYou", system-ui, sans-serif; color: #ff7a00;
  text-shadow: 0 1px 0 #fff, 0 0 6px rgba(255,180,0,.8);
  pointer-events: none; animation: pop-up .8s ease-out forwards;
}
@keyframes pop-up { 0% { transform: translateY(8px) scale(.6); opacity: 0; } 20% { transform: translateY(0) scale(1.15); opacity: 1; } 100% { transform: translateY(-22px); opacity: 0; } }
/* 棋盘上撞击点冒出的得分 */
.hit-pop {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap; z-index: 6;
  font: 900 calc(var(--cell) * .46)/1 "ZCOOL QingKe HuangYou", system-ui, sans-serif; color: #fff1a8;
  -webkit-text-stroke: 4px #b23a06; paint-order: stroke fill;
  filter: drop-shadow(0 2px 0 #7a2400) drop-shadow(0 0 6px rgba(255,150,0,.8));
  pointer-events: none; animation: hit-pop .9s ease-out forwards;
}
@keyframes hit-pop { 0% { transform: translate(-50%, -30%) scale(.5); opacity: 0; } 18% { transform: translate(-50%, -60%) scale(1.2); opacity: 1; } 100% { transform: translate(-50%, -160%) scale(1); opacity: 0; } }

/* 连击火焰字：底层是烧焦的字，上层是火焰字；
   倒计时 = 火焰层 clip-path 从上往下收（--burn: 0 → 100%），燃烧线由 fx.js 喷火星 */
.combo {
  grid-column: 3; justify-self: center; position: relative; margin-top: 4px;
  pointer-events: none; opacity: 0; transition: opacity .2s;
}
.combo.on { opacity: 1; }
.combo.out { opacity: 0; transition: opacity .5s .15s; }
.combo-fx { position: absolute; left: -30px; top: -40px; width: calc(100% + 60px); height: calc(100% + 60px); }
.combo-text {
  position: relative; white-space: nowrap;
  font-family: "ZCOOL QingKe HuangYou", "PingFang SC", system-ui, sans-serif;
  font-size: clamp(32px, 10vw, 46px); line-height: 1; font-weight: 400; font-style: italic; letter-spacing: 1px;
  padding: 2px 4px;
}
.combo-text small { font-size: .62em; margin-left: 2px; }
.combo-base, .combo-fire { display: block; }
.combo-base {
  color: #3b1a10;
  -webkit-text-stroke: 2px #1c0a05; paint-order: stroke fill;
  text-shadow: 0 2px 0 rgba(0,0,0,.25);
  opacity: .82;
}
.combo-fire {
  position: absolute; inset: 0; padding: inherit;
  clip-path: inset(var(--burn, 0%) -20px -20px -20px);
  background: linear-gradient(0deg, #ff2a00 0%, #ff7a00 30%, #ffc400 60%, #fff6b0 85%, #ffffff 100%);
  background-size: 100% 220%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 1.5px rgba(160,30,0,.9);
  filter: drop-shadow(0 0 6px rgba(255,120,0,.95)) drop-shadow(0 0 14px rgba(255,60,0,.6));
  animation: blaze .5s ease-in-out infinite alternate;
}
@keyframes blaze { from { background-position: 0 0%; } to { background-position: 0 30%; } }
.combo.surge .combo-text { animation: surge .35s cubic-bezier(.2,1.6,.4,1); }
@keyframes surge { 0% { transform: scale(.6) rotate(-6deg); } 100% { transform: none; } }
/* 快烧完时加速闪烁 */
.combo.hurry .combo-fire { animation-duration: .15s; }

/* ---------- board ---------- */
.board-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.board {
  position: relative;
  padding: 10px;
  border-radius: 20px;
  background: linear-gradient(#e7b97c, #c98d4f);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.4), 0 0 0 3px #b07338, 0 8px 18px rgba(80,40,0,.3);
}
.slots, .tracks, .tiles, .fx { position: absolute; inset: 10px; }
.fx-canvas { position: absolute; pointer-events: none; }
#fx-over { z-index: 5; } /* 在方块（z-index 1~4）之上：火舌、裂纹、火星 */
/* 细进度条：贴在棋盘上沿上方 */
.progress {
  position: absolute; left: 14px; right: 14px; top: -11px; height: 5px;
  border-radius: 999px; background: rgba(255,255,255,.55);
  box-shadow: inset 0 1px 1px rgba(0,0,0,.12);
  overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, #8ee063, #5cbf3a);
  transition: width .35s ease;
}
.slots {
  position: relative; inset: auto; display: grid; gap: 0;
  border-radius: 12px; background: var(--slot);
  box-shadow: inset 0 2px 6px rgba(80,110,40,.25);
}
.slot { width: var(--cell); height: var(--cell); }
.tracks, .fx { pointer-events: none; }

.tile {
  position: absolute; left: 0; top: 0;
  width: var(--cell); height: var(--cell);
  padding: calc(var(--gap) / 2);
  transition: transform .18s cubic-bezier(.3,.7,.4,1);
  will-change: transform;
  cursor: grab;
  z-index: 1;
}
.tile.dragging { transition: none; z-index: 3; cursor: grabbing; }
.tile .face, .frag .face {
  position: relative;
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: url(assets/tile.webp) center / 100% 100% no-repeat;
  filter: drop-shadow(0 3px 3px rgba(90,60,20,.22));
  transition: filter .15s, transform .15s;
}
.tile .face img, .frag .face img {
  width: 76%; height: 76%;
  margin-top: -4%;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
}
.tile .face::after {
  content: ""; position: absolute; inset: 1px; border-radius: 22%;
  box-shadow: 0 0 0 3px transparent; transition: box-shadow .15s; pointer-events: none;
}
.tile.selected .face { transform: translateY(-2px); }
.tile.tile.selected .face::after { box-shadow: 0 0 0 3px #7ee04f, 0 0 14px 4px rgba(126,224,79,.75); }
.tile.tile.target .face::after { box-shadow: 0 0 0 3px #ffd34d, 0 0 16px 5px rgba(255,200,40,.8); }
.tile.choice { cursor: pointer; }
.tile.choice .face { animation: choice .8s ease-in-out infinite; }
@keyframes choice { 50% { transform: scale(1.08); } }
.tile.tile.group .face::after { box-shadow: 0 0 0 2px rgba(126,224,79,.85); }
.tile.hint .face { animation: hint 0.9s ease-in-out 3; }
.tile.shake .face { animation: shake .35s; }
.tile.crush { pointer-events: none; }
.tile.crush .face { animation: crush .36s ease-in forwards; }
.tile.appear .face { animation: appear .3s ease-out; }

@keyframes hint { 50% { transform: scale(1.12); filter: drop-shadow(0 0 8px rgba(255,190,30,.95)); } }
@keyframes shake { 20%,60% { transform: translateX(-5px); } 40%,80% { transform: translateX(5px); } }
@keyframes crush { 30% { transform: scale(1.18); filter: brightness(1.3); } 100% { transform: scale(.2) rotate(25deg); opacity: 0; } }
@keyframes appear { from { transform: scale(.4); opacity: 0; } }

/* tracks */
/* 十字轨道：半透明粗虚线，所有方向同一颜色 */
.track {
  position: absolute;
  --dash: rgba(255, 255, 255, .72);
  --dash-len: calc(var(--cell) * .16);
  border-radius: 999px;
  filter: drop-shadow(0 0 2px rgba(90, 60, 20, .25));
}
.track.h { background: repeating-linear-gradient(90deg, var(--dash) 0 var(--dash-len), transparent var(--dash-len) calc(var(--dash-len) * 1.8)); }
.track.h.rev { transform: scaleX(-1); }
.track.v.rev { transform: scaleY(-1); }
.track.v { background: repeating-linear-gradient(180deg, var(--dash) 0 var(--dash-len), transparent var(--dash-len) calc(var(--dash-len) * 1.8)); }
.ghost {
  position: absolute; width: var(--cell); height: var(--cell);
  padding: calc(var(--gap) / 2);
}
.ghost::before {
  content: ""; display: block; height: 100%; border-radius: 12px;
  border: 3px dashed #ffb02e; background: rgba(255,210,80,.25);
  animation: pulse 0.9s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .35; } }

/* fx */
.frag {
  position: absolute; left: 0; top: 0;
  width: var(--cell); height: var(--cell);
  will-change: transform, opacity;
}
.impact {
  position: absolute; transform: translate(-50%, -50%) scale(.3);
  border-radius: 50%;
  background: radial-gradient(circle, #fffbe0 0%, rgba(255,230,120,.85) 30%, rgba(255,200,60,0) 70%);
  animation: impact .35s ease-out forwards;
}
@keyframes impact { 30% { opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1.2); opacity: 0; } }
.shard {
  position: absolute; border-radius: 2px;
  animation: shard .55s cubic-bezier(.2,.6,.4,1) forwards;
}
@keyframes shard {
  from { transform: translate(-50%, -50%) rotate(0); opacity: 1; }
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--rot)); opacity: 0; }
}

/* ---------- bottom ---------- */
.actions { display: flex; justify-content: space-around; gap: 10px; }
.action-btn {
  flex: 1; max-width: 120px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; border-radius: 18px;
  font-weight: 800; font-size: 15px; color: #fff;
  text-shadow: 0 1px 0 rgba(0,0,0,.25);
}
.action-btn .ico { font-size: 24px; line-height: 1.1; }
.action-btn:active { transform: translateY(3px); }
.action-btn:disabled { filter: grayscale(.7); opacity: .6; }
.action-btn.yellow { background: linear-gradient(#ffd75e, #f2a51e); box-shadow: 0 4px 0 #c27a0c; }
.action-btn.green  { background: linear-gradient(#86e070, #43b33a); box-shadow: 0 4px 0 #2d8526; }
.action-btn.blue   { background: linear-gradient(#7cc6ff, #3a8ef0); box-shadow: 0 4px 0 #2462b8; }

/* toast & modal */
.toast {
  position: fixed; left: 50%; top: 18%;
  transform: translate(-50%, -10px);
  padding: 10px 18px; border-radius: 999px;
  background: rgba(70,40,15,.88); color: #fff; font-weight: 700; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  white-space: nowrap; z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.modal {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(40,30,10,.45);
  padding: 16px;
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(340px, 100%);
  padding: 22px 20px 18px; text-align: center;
  border-radius: 22px; background: var(--cream);
  border: 4px solid var(--wood);
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
  animation: appear .25s ease-out;
}
.modal-emoji { font-size: 56px; }
.modal-card h2 { margin: 6px 0; font-size: 24px; }
.modal-card p { margin: 0 0 14px; font-weight: 600; white-space: pre-line; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.modal-actions .action-btn { flex: 1 1 120px; flex-direction: row; justify-content: center; padding: 10px 0; }
.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 14px; max-height: 50vh; overflow: auto; padding: 4px; }
.level-grid button {
  aspect-ratio: 1; border-radius: 12px; font-weight: 800; font-size: 16px;
  background: linear-gradient(#fffaf0, #f0dcb4); box-shadow: 0 3px 0 #d0b07a;
}
.level-grid button.current { background: linear-gradient(#a6ec86, #5cbf3a); color: #fff; box-shadow: 0 3px 0 #3e9a23; }
.level-grid button:disabled { opacity: .4; }

/* ---------- items ---------- */
/* 道具块：底板交给 Canvas 粒子层（fx.js）整块绘制，这里只把奶油底板去掉 */
.tile[data-fx="fire"] .face, .tile[data-fx="portal"] .face,
.tile[data-fx="cham"] .face, .tile[data-fx="split"] .face { background: none; filter: none; }
.tile .badge { display: none; }

/* 着火：图标被烤焦、微微颤动 */
.tile.fx-fire { cursor: not-allowed; }
.tile.fx-fire .face img { filter: brightness(.55) saturate(1.3) sepia(.5) contrast(1.15); animation: heat .12s steps(2) infinite; }
@keyframes heat { 50% { transform: translate(.5px, -.5px); } }
/* 空间门：图标被吸着缓慢旋转、缩小 */
.tile.fx-portal .face img { animation: vortex 3s linear infinite; filter: drop-shadow(0 0 4px rgba(120,220,255,.9)); }
@keyframes vortex { 0% { transform: rotate(0) scale(.86); } 50% { transform: rotate(180deg) scale(.74); } 100% { transform: rotate(360deg) scale(.86); } }
/* 百变：图标带白色描边光 */
.tile.fx-cham .face img { filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 4px rgba(255,255,255,.8)); }
/* 分裂：图标轻微抖动，像要裂开 */
.tile.fx-split .face img { animation: crackle 1.6s ease-in-out infinite; }
@keyframes crackle { 0%, 80%, 100% { transform: none; } 84% { transform: translate(-1px, 0) rotate(-2deg); } 88% { transform: translate(1px, 0) rotate(2deg); } 92% { transform: translate(-1px, 0); } }

.tile.fx-new .face { animation: itempop .45s ease-out; }
@keyframes itempop { 0% { transform: scale(1); } 40% { transform: scale(1.18); filter: brightness(1.3); } 100% { transform: scale(1); } }
.tile.morph .face { animation: morph .35s ease-in-out; }
@keyframes morph { 50% { transform: rotateY(90deg) scale(.9); } }

.steam {
  position: absolute; transform: translate(-50%, -50%) scale(.4); border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.95) 0%, rgba(230,240,255,.6) 40%, rgba(255,255,255,0) 70%);
  animation: steam .6s ease-out forwards;
}
@keyframes steam { 100% { transform: translate(-50%, -90%) scale(1.3); opacity: 0; } }
.warp {
  position: absolute; transform: translate(-50%, -50%) scale(.2); border-radius: 50%;
  background: radial-gradient(circle, rgba(140,120,255,.9) 0%, rgba(49,208,255,.5) 45%, rgba(0,0,0,0) 70%);
  animation: warp .45s ease-out forwards;
}
@keyframes warp { 60% { opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1.2) rotate(180deg); opacity: 0; } }

/* ---------- modal content ---------- */
.modal-body:empty { display: none; }
.modal-body { margin-bottom: 14px; }
.mode-list { display: grid; gap: 10px; }
.mode-card {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-align: left;
  border-radius: 16px; background: linear-gradient(#fffaf0, #f3e2bf); box-shadow: 0 3px 0 #d0b07a;
}
.mode-card:active { transform: translateY(2px); }
.mode-ico { font-size: 32px; }
.mode-text { display: flex; flex-direction: column; gap: 2px; }
.mode-text b { font-size: 17px; }
.mode-text small, .item-row small { color: #8a6a48; font-weight: 600; }
.rank-row { display: flex; justify-content: space-between; padding: 10px 4px; border-bottom: 1px dashed #e2c99b; font-weight: 700; }
.muted { color: #8a6a48; font-size: 13px; margin: 10px 0 0; }
.item-list { text-align: left; }
.item-row { display: flex; gap: 10px; align-items: center; padding: 6px 0; text-align: left; }
.item-row > span:last-child { display: flex; flex-direction: column; }
.item-badge {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; font-size: 20px;
  background: url(assets/tile.webp) center / 100% 100%;
}
.modal-card { max-height: 90dvh; overflow: auto; }

/* ---------- views & tab bar ---------- */
.view[hidden] { display: none !important; }
.view-game { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; position: relative; }
.view-panel {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y;
  padding: 14px; border-radius: 20px;
  background: rgba(255,250,236,.92);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.6), 0 0 0 3px #e2c99b, 0 8px 18px rgba(80,40,0,.18);
}
.tabbar {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; flex-shrink: 0;
  padding: 6px; border-radius: 18px;
  background: linear-gradient(#fff9ec, #f1dcb5);
  box-shadow: 0 3px 0 #c9a46c, 0 6px 14px rgba(0,0,0,.15);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px 0 5px; border-radius: 12px; background: transparent;
  font-size: 12px; font-weight: 800; color: #9a6b3c;
  transition: background .15s, color .15s, transform .1s;
}
.tab .ico { width: 30px; height: 30px; object-fit: contain; display: block; margin: 0 auto; filter: grayscale(.5); opacity: .8; transition: filter .15s, transform .15s; }
.tab.on { background: linear-gradient(#ffd75e, #f2a51e); color: #6b3a08; box-shadow: 0 2px 0 #c27a0c; }
.tab.on .ico { filter: none; opacity: 1; transform: translateY(-1px) scale(1.08); }
.tab:active { transform: translateY(1px); }

/* ---------- panels ---------- */
.panel-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.panel-head b { font-size: 19px; }
.panel-head small, .muted { color: #8a6a48; font-weight: 600; font-size: 13px; }
.center { text-align: center; }
.panel-actions { display: flex; gap: 10px; margin: 12px 0; }
.panel-actions .action-btn { flex: 1; flex-direction: row; justify-content: center; padding: 10px 0; font-weight: 800; color: #fff; }
.room-list { display: grid; gap: 8px; }
.room-card {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left;
  padding: 10px 12px; border-radius: 14px; background: #fff;
  box-shadow: 0 2px 0 #e2c99b, 0 3px 8px rgba(0,0,0,.06);
}
.room-card:disabled { opacity: .55; }
.room-card:not(:disabled):active { transform: translateY(2px); }
.room-main, .room-side { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.room-main b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-main small { color: #8a6a48; font-weight: 600; font-size: 12px; }
.room-side { align-items: flex-end; flex-shrink: 0; }
.room-side small { font-size: 12px; font-weight: 800; padding: 1px 8px; border-radius: 999px; }
.room-side .open { background: #dff5d2; color: #2d8526; }
.room-side .busy { background: #ffe1cc; color: #c2410c; }
.room-side .full { background: #eee; color: #888; }

.seats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seat {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px;
  border-radius: 14px; background: #fff; box-shadow: 0 2px 0 #e2c99b;
}
.seat.me { box-shadow: 0 0 0 2px #5cbf3a, 0 2px 0 #3e9a23; }
.seat.empty { background: rgba(255,255,255,.4); box-shadow: none; border: 2px dashed #e2c99b; color: #c3a57a; }
.seat-ava {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(#ffd75e, #f2a51e); color: #fff; font-size: 20px; font-weight: 900;
  text-shadow: 0 1px 0 #c27a0c;
}
.seat.empty .seat-ava { background: #f3e6cc; color: #c3a57a; text-shadow: none; }
.seat-name { font-weight: 800; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-tag { font-size: 12px; font-weight: 700; color: #8a6a48; min-height: 1em; }

.rank-row.me { background: #fff3c4; border-radius: 8px; padding-left: 8px; padding-right: 8px; }
.rank-no { display: inline-block; width: 1.8em; font-style: normal; color: #c27a0c; }
.rank-body { margin-top: 10px; }

/* 分段按钮 */
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: #f3e6cc; }
.seg button { flex: 1; padding: 7px 0; border-radius: 9px; background: transparent; font-weight: 800; font-size: 14px; color: #9a6b3c; }
.seg button.on { background: #fff; color: #6b4220; box-shadow: 0 2px 0 #e2c99b; }

/* 表单 */
.form, .settings { display: grid; gap: 12px; text-align: left; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 800; color: #8a6a48; }
.field input {
  font: inherit; font-weight: 700; color: var(--text);
  padding: 10px 12px; border-radius: 12px; border: 2px solid #e2c99b; background: #fff; outline: none;
  user-select: text; -webkit-user-select: text;
}
.field input:focus { border-color: #f2a51e; }
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-radius: 12px; background: #fff; font-weight: 800; }
.toggle input { display: none; }
.toggle i { position: relative; width: 46px; height: 26px; border-radius: 999px; background: #ddd; transition: background .2s; }
.toggle i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.toggle input:checked + i { background: #5cbf3a; }
.toggle input:checked + i::after { transform: translateX(20px); }
.settings .action-btn { flex-direction: row; justify-content: center; padding: 10px 0; color: #fff; font-weight: 800; }

/* 对战：对手实时分数 */
.rivals { grid-column: 1; grid-row: 1; justify-self: start; display: grid; gap: 1px; font-size: 11px; font-weight: 800; }
.rival { display: grid; grid-template-columns: 1.2em minmax(0, 5.5em) auto; gap: 4px; align-items: center; padding: 0 6px; border-radius: 6px; background: rgba(255,250,235,.75); }
.rival i { font-style: normal; color: #c27a0c; }
.rival b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.rival em { font-style: normal; font-variant-numeric: tabular-nums; }
.rival.me { background: #fff3c4; color: #c2410c; }
.rival.off { opacity: .5; }

/* 对战：开局倒数 */
.countdown {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 20; pointer-events: none;
  font: 900 96px/1 "ZCOOL QingKe HuangYou", system-ui, sans-serif; color: #fff1a8;
  -webkit-text-stroke: 6px #b23a06; paint-order: stroke fill;
  filter: drop-shadow(0 4px 0 #7a2400) drop-shadow(0 0 18px rgba(255,150,0,.8));
}
.countdown[hidden] { display: none; }
.countdown.tick { animation: cd-tick .9s ease-out; }
@keyframes cd-tick { 0% { transform: scale(1.8); opacity: 0; } 25% { transform: scale(1); opacity: 1; } 100% { transform: scale(.9); opacity: .9; } }

/* ---------- 闯关倒计时 ---------- */
.timer {
  grid-column: 3; grid-row: 1; justify-self: end; margin-right: 6px;
  --pct: 1; position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 4px; padding: 5px 12px 5px 9px; border-radius: 999px;
  font-weight: 900; font-size: 17px; color: #5a3410; font-variant-numeric: tabular-nums;
  background: #fff6df; box-shadow: 0 3px 0 #c9a46c, inset 0 0 0 2px #f0d39a;
}
.timer::before { /* 剩余时间条 */
  content: ""; position: absolute; left: 0; bottom: 0; height: 4px; width: calc(var(--pct) * 100%);
  background: linear-gradient(90deg, #6cc84a, #f3c33a); transition: width .2s linear;
}
.timer i { font-style: normal; font-size: 15px; }
.timer b { position: relative; }
.timer.low { color: #fff; background: #e9483a; box-shadow: 0 3px 0 #a6261b, inset 0 0 0 2px #ff8a7a; animation: timer-pulse .5s ease-in-out infinite alternate; }
.timer.low::before { background: #ffd2c8; }
@keyframes timer-pulse { to { transform: scale(1.08); } }

/* ---------- 关卡地图 ---------- */
.level-map { margin-bottom: 12px; }
.map-head { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; gap: 6px; margin-bottom: 10px; }
.map-head div { display: flex; flex-direction: column; }
.map-head small { font-size: 12px; color: #9a6b3c; font-weight: 700; }
.map-nav { height: 40px; border-radius: 12px; font-size: 24px; font-weight: 900; background: linear-gradient(#fffaf0, #f0dcb4); box-shadow: 0 3px 0 #d0b07a; }
.map-nav:disabled { opacity: .35; }
.level-map .level-grid { margin-bottom: 8px; max-height: none; }
.level-map .level-grid button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; aspect-ratio: auto; height: 58px; }
.level-map .level-grid button i { font-style: normal; font-size: 10px; color: #f0a515; letter-spacing: -1px; }
.level-map .level-grid button em { position: absolute; top: -6px; right: -4px; font-style: normal; font-size: 9px; padding: 1px 4px; border-radius: 6px; background: #8a5cf0; color: #fff; }
.level-map .level-grid button.boss { background: linear-gradient(#ffe2a3, #f2b64e); box-shadow: 0 3px 0 #c27a0c; }
.level-map .level-grid button.next { outline: 3px solid #5cbf3a; outline-offset: 1px; }
.level-map .level-grid button.current i { color: #fff8c8; }
.map-foot { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.map-jump { padding: 6px 10px; border-radius: 10px; font-weight: 800; background: #5cbf3a; color: #fff; box-shadow: 0 2px 0 #3e9a23; }

/* ---------- 固定件：石砖 / 水管 / 火箭发射台 ---------- */
.tile.fixture { cursor: default; z-index: 1; }
.tile.fixture .face { background: none; box-shadow: none; }
.tile.fixture .face::after { display: none; }
.tile.fixture .face img { width: 100%; height: 100%; margin-top: 0; filter: drop-shadow(0 2px 2px rgba(0,0,0,.25)); }
.tile.fixture-pipe .face img { transition: none; }
.pad-count {
  position: absolute; right: -2px; bottom: -2px; z-index: 2;
  padding: 0 4px; border-radius: 8px; font-size: calc(var(--cell) * .22); font-weight: 900; line-height: 1.4;
  background: #2f2f46; color: #fff; box-shadow: 0 1px 0 rgba(0,0,0,.3); pointer-events: none;
}
.tile.fixture.launch .face { animation: pad-launch .45s ease-out; }
@keyframes pad-launch { 0% { transform: scale(1); } 30% { transform: scale(.88) translateY(2px); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
.rocket { position: absolute; left: 0; top: 0; z-index: 8; pointer-events: none; will-change: transform; }
.rocket img { width: 100%; height: 100%; object-fit: contain; display: block; position: relative; z-index: 1; }
.rocket-flame {
  position: absolute; left: 50%; top: 82%; width: 38%; height: 55%; transform: translateX(-50%);
  border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%;
  background: radial-gradient(ellipse at 50% 20%, #fff7b0, #ffb02e 45%, rgba(255,80,20,0) 75%);
  animation: rocket-flame .08s linear infinite alternate;
}
@keyframes rocket-flame { to { transform: translateX(-50%) scaleY(1.35); opacity: .8; } }
.tile.in-pipe { z-index: 0 !important; transition: none !important; }
.item-badge img { width: 30px; height: 30px; object-fit: contain; }

/* ---------- 账号 / 排行榜身份 ---------- */
.who { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 9em; }
.ava { width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; display: inline-grid; place-items: center; font-size: 17px; line-height: 1; background: #fff3d6; box-shadow: inset 0 0 0 2px #f0d39a; object-fit: cover; }
.ava.guest { font-size: 13px; font-weight: 900; color: #9a6b3c; }
.who.big .ava { width: 44px; height: 44px; font-size: 28px; }
.who.big .who-name { font-size: 18px; font-weight: 900; }
.flag { font-size: 16px; line-height: 1; }
.rank-row.sticky { position: sticky; bottom: 0; margin-top: 8px; }
.login-card, .account-card { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px; border-radius: 16px; background: #fff9ec; box-shadow: 0 3px 0 #e2c896; text-align: center; }
.login-card small, .account-card small { color: #9a6b3c; }
.account-actions { display: flex; gap: 8px; width: 100%; }
.account-actions .action-btn { flex: 1; flex-direction: row; justify-content: center; padding: 8px 0; }
.login-card .action-btn, .account-card .action-btn { flex: none; width: 100%; max-width: 180px; padding: 10px 0; }
