/* 游戏页：机柜、屏幕、HUD、覆盖层、虚拟按键 */

body.gamepage {
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255, 255, 255, .9), transparent 60%),
    radial-gradient(90% 70% at 50% 110%, var(--wash, #FCE7E1), transparent 65%),
    var(--paper);
  overscroll-behavior: none;
}

/* ---------- 顶栏 ---------- */
.gp-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px clamp(10px, 3vw, 22px);
  position: relative;
  z-index: 30;
}
.gp-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-weight: 900;
  font-size: 13.5px;
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
}
.gp-back:active { transform: translate(2px, 2px); box-shadow: none; }
.gp-id { display: flex; align-items: baseline; gap: 8px; margin-right: auto; min-width: 0; }
.gp-id b {
  font-size: clamp(15px, 2.4vw, 19px);
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gp-id i {
  font-style: normal;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
  color: var(--ink-3);
}
.gp-tools { display: flex; gap: 4px; }
.gp-tools .iconbtn { border: 2px solid var(--paper-4); background: var(--paper); width: 38px; height: 38px; }

/* ---------- 舞台 ---------- */
.gp-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 0 clamp(8px, 2.5vw, 22px) 4px;
  position: relative;
  z-index: 1;
}
.gp-hud {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 clamp(2px, 1vw, 8px);
  height: 38px;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
}
.hud__left { display: flex; align-items: baseline; gap: 4px; }
.hud__score {
  font-size: clamp(22px, 3.4vw, 30px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.hud__label { font-size: 11px; font-weight: 900; color: var(--ink-3); letter-spacing: .1em; }
.hud__combo {
  font-size: 12px;
  font-weight: 900;
  color: var(--red);
  background: var(--red-soft);
  border: 2px solid var(--red);
  border-radius: 999px;
  padding: 2px 10px;
  animation: pop .18s var(--bounce);
}
.hud__combo b { font-size: 14px; }
.hud__right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.hud__lives { display: inline-flex; gap: 2px; color: var(--red); }
.hud__lives svg { width: 16px; height: 16px; }
.hud__best { font-size: 11.5px; font-weight: 800; color: var(--ink-3); }

.gp-board {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}
.gp-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-height: 100%;
  min-height: 0;
}
.gp-screen {
  position: relative;
  display: flex;
  min-height: 0;
}
#cv {
  display: block;
  border: 3px solid var(--line);
  border-radius: clamp(14px, 2vw, 22px);
  box-shadow: 0 14px 30px rgba(43, 33, 27, .16), 0 2px 0 rgba(255, 255, 255, .7) inset;
  background: #FFF7EC;
  touch-action: none;
  max-width: 100%;
  max-height: 100%;
  cursor: pointer;
}

/* ---------- 覆盖层 ---------- */
.gp-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  line-height: 1.5;
  display: grid;
  place-items: center;
  padding: clamp(10px, 2vw, 24px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .18s ease, visibility .18s;
  background: rgba(255, 251, 245, .55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  overflow: auto;
  overscroll-behavior: contain;
}
.gp-overlay[data-open="1"] { opacity: 1; visibility: visible; }

.panel {
  width: min(520px, 100%);
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: 26px;
  box-shadow: 8px 10px 0 rgba(43, 33, 27, .13);
  padding: clamp(18px, 3vw, 28px);
  text-align: center;
  animation: pop .26s var(--bounce);
  position: relative;
}
.panel h1 { font-size: clamp(26px, 4.6vw, 38px); }
.panel h2 { font-size: clamp(20px, 3.4vw, 26px); }
.panel__kicker {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .18em;
  color: var(--red);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.panel__joke { color: var(--ink-2); font-size: 13.5px; margin-top: 6px; }
.panel__char {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 4px;
  padding: 8px 10px;
  border: 2px dashed var(--paper-4);
  border-radius: 16px;
  background: var(--paper-2);
  text-align: left;
}
.panel__char img { width: 58px; height: 58px; object-fit: contain; flex: 0 0 auto; }
.panel__char > div { display: flex; flex-direction: column; line-height: 1.3; }
.panel__char b { font-size: 13.5px; }
.panel__char span { font-size: 11.5px; color: var(--ink-2); }
.panel__char .btn { margin-left: auto; }
.panel__howto {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 0;
  margin: 14px 0 4px;
}
.panel__howto li {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--ink-2);
  background: var(--paper-3);
  border-radius: 999px;
  padding: 3px 9px;
}
.panel__actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
}
.panel__tip { font-size: 11px; color: var(--ink-3); margin-top: 10px; }
.panel__stats {
  display: flex;
  justify-content: center;
  gap: clamp(14px, 4vw, 34px);
  margin: 18px 0 4px;
}
.panel__stats > div { display: flex; flex-direction: column; gap: 2px; }
.panel__stats span { font-size: 11px; font-weight: 800; color: var(--ink-3); letter-spacing: .08em; }
.panel__stats b { font-size: clamp(20px, 3vw, 26px); font-weight: 900; font-variant-numeric: tabular-nums; }
.panel__newbest { color: var(--red); font-weight: 900; font-size: 12.5px; margin-top: 8px; }
.panel__daily {
  margin-top: 10px;
  padding: 7px 10px;
  border: 2px dashed #D9B23A;
  background: #FFF7DC;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 800;
  color: #7A5A00;
}
.panel__daily .linklike { font-size: 12px; color: var(--red); border-color: var(--red); margin-left: 6px; }
.panel__board {
  list-style: none;
  margin: 12px 0 0;
  padding: 8px 10px;
  border-top: 2px dashed var(--paper-4);
  border-bottom: 2px dashed var(--paper-4);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.panel__board li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-2);
  padding: 2px 4px;
  border-radius: 8px;
}
.panel__board li > span {
  width: 18px;
  font-weight: 900;
  color: var(--ink-3);
  font-size: 11px;
}
.panel__board li > b { font-size: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
.panel__board li > i { margin-left: auto; font-style: normal; font-size: 11px; color: var(--ink-3); }
.panel__board li.is-me { background: var(--red-soft); }
.panel__board li.is-me > b { color: var(--red); }
.panel__next {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 2px dashed var(--paper-4);
  text-decoration: none;
  font-size: 12.5px;
  color: var(--ink-2);
}
.panel__next b { font-size: 13px; color: var(--ink); }
.panel__next i { margin-left: auto; font-style: normal; color: var(--red); font-weight: 900; }
.panel--result.is-win { box-shadow: 8px 10px 0 rgba(200, 22, 30, .18); }
.panel__burst {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 34px;
  filter: drop-shadow(0 3px 4px rgba(43, 33, 27, .2));
}

/* ---------- 虚拟按键 ---------- */
.gp-pad {
  flex: 0 0 auto;
  width: 100%;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 4px;
  pointer-events: none;
}
.gp-pad > * { pointer-events: auto; }
.pad__dpad {
  position: relative;
  width: 132px;
  height: 132px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 3px;
}
.pad__key {
  border: 2.5px solid var(--line);
  background: rgba(255, 251, 245, .94);
  color: var(--ink);
  border-radius: 14px;
  font-size: 19px;
  font-weight: 900;
  display: grid;
  place-items: center;
  box-shadow: 0 3px 0 rgba(43, 33, 27, .18);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  padding: 0;
}
.pad__key[data-on="1"] { transform: translateY(2px); box-shadow: 0 1px 0 rgba(43, 33, 27, .18); background: var(--paper-3); }
.pad__key.up { grid-area: 1 / 2; }
.pad__key.left { grid-area: 2 / 1; }
.pad__key.right { grid-area: 2 / 3; }
.pad__key.down { grid-area: 3 / 2; }
.pad__buttons { display: flex; gap: 10px; align-items: flex-end; }
.pad__key.jump {
  width: 84px; height: 84px; border-radius: 50%;
  background: var(--red); color: #fff; font-size: 17px;
  box-shadow: 0 4px 0 var(--red-dark);
}
.pad__key.switch {
  width: 66px; height: 66px; border-radius: 50%;
  background: var(--paper); font-size: 16px;
}
.pad__tap {
  width: 100%;
  height: 62px;
  border-radius: 16px;
  border: 2.5px dashed var(--line);
  background: rgba(255, 251, 245, .8);
  font-weight: 900;
  font-size: 14px;
  color: var(--ink-2);
  touch-action: none;
}
@media (pointer: coarse), (max-width: 900px) {
  .gp-pad { display: flex; }
  .gp-board { align-items: flex-start; }
  .gp-frame { padding-top: 4px; gap: 8px; }
}

/* 手机横屏：按键浮在画面下方，画面尽量占满高度 */
@media (pointer: coarse) and (orientation: landscape) and (max-width: 1200px) {
  .gp-frame { position: relative; justify-content: center; }
  .gp-pad {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 4px;
    z-index: 15;
    padding: 0 10px;
  }
  .gp-pad .pad__dpad { width: 108px; height: 108px; opacity: .88; }
  .gp-pad .pad__key.jump { width: 72px; height: 72px; font-size: 15px; opacity: .92; }
  .gp-pad .pad__key.switch { width: 58px; height: 58px; opacity: .9; }
  .rotatehint { display: none; }
}

/* ---------- 底部提示 ---------- */
.gp-foot {
  flex: 0 0 auto;
  height: 26px;
  display: grid;
  place-items: center;
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 700;
  letter-spacing: .02em;
  padding-bottom: 2px;
}
@media (max-width: 760px) {
  .gp-foot { display: none; }
}

/* ---------- 贴纸弹出 ---------- */
.stickerpop {
  position: fixed;
  left: 50%;
  top: 14px;
  z-index: 200;
  transform: translate(-50%, -140%) rotate(-3deg);
  transition: transform .38s var(--bounce);
  background: #FFF7DC;
  border: 3px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}
.stickerpop[data-on="1"] { transform: translate(-50%, 0) rotate(-2deg); }
.stickerpop__k { font-size: 9.5px; font-weight: 900; letter-spacing: .18em; color: var(--red); }
.stickerpop b { font-size: 13.5px; }

/* 手机竖屏提示（放在画面正上方，不挡任何东西） */
.rotatehint {
  flex: 0 0 auto;
  border: 2px solid var(--line);
  background: #FFF7DC;
  color: var(--ink);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 11.5px;
  font-weight: 900;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  white-space: nowrap;
}
.rotatehint span { color: var(--red); margin-left: 4px; }

/* 手机横屏时压缩顶栏 */
@media (max-height: 520px) and (orientation: landscape) {
  .gp-bar { padding: 5px 10px; }
  .gp-id b { font-size: 14px; }
  .gp-hud { height: 28px; }
  .hud__score { font-size: 20px; }
  .gp-foot { display: none; }
  .panel { padding: 14px 18px; }
  .panel__char { display: none; }
  .panel__howto { margin: 8px 0 0; }
  .panel__actions { margin-top: 10px; }
  .panel h1 { font-size: 24px; }
}
