* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #8ED4F5;
  color: #3A2416;
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
button, input { font-family: inherit; }
input { user-select: text; }
button { cursor: pointer; }
#app {
  position: relative;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}
#cv {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}
[hidden] { display: none !important; }

.mp-icon { width: 22px; height: 22px; }
.hot { color: #E23B4A; }
.gold { color: #E09A12; }

#hud {
  position: absolute;
  z-index: 3;
  top: calc(8px + env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.pill {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 4px 8px;
  flex: 0 1 auto;
  border-radius: 999px;
  background: rgba(255, 248, 240, 0.94);
  box-shadow: 0 4px 12px rgba(70, 30, 10, 0.16);
  color: #3A2416;
  font-weight: 800;
}
.pill b { font-size: 15px; font-variant-numeric: tabular-nums; }
.pill b.danger { color: #E23B4A; }
.btn-pill {
  border: 0;
  margin-left: auto;
  padding: 4px 10px;
}
#btn-pause { margin-left: 0; }
#hud .btn-pill:first-of-type { margin-left: auto; }
#btn-speed { margin-left: auto; }
#btn-pause, #btn-speed { min-width: 36px; justify-content: center; }
#btn-speed:active, #btn-pause:active { transform: scale(0.96); }

#play-ui {
  position: absolute;
  z-index: 4;
  left: 12px;
  right: 12px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#hint {
  margin: 0;
  text-align: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(40, 20, 0, 0.45);
  pointer-events: none;
}
#next {
  align-self: center;
  min-width: 168px;
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: #FF8A3D;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 5px 0 #D8651C;
}
#next:active { transform: translateY(3px); box-shadow: 0 2px 0 #D8651C; }

#dock { display: flex; gap: 8px; }
.tw {
  flex: 1;
  min-height: 76px;
  border: 2px solid transparent;
  border-radius: 16px;
  background: #FFF8F0;
  color: #3A2416;
  box-shadow: 0 5px 0 #E7D3C2, 0 8px 16px rgba(70, 30, 10, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
}
.tw b { font-size: 14px; }
.tw em { font-style: normal; font-size: 12px; font-weight: 800; color: #C97812; }
.tw .mp-icon { color: #FF8A3D; }
.tw[data-k="ice"] .mp-icon { color: #3AA7D6; }
.tw[data-k="boom"] .mp-icon { color: #E23D3D; }
.tw.on { border-color: #FF8A3D; }
.tw.poor { opacity: 0.45; }
.tw:active { transform: translateY(2px); box-shadow: 0 2px 0 #E7D3C2; }

.sheet-card, .panel, .card {
  background: #FFF8F0;
  border-radius: 20px;
  box-shadow: 0 10px 28px rgba(70, 30, 10, 0.16);
}
.sheet-card { padding: 12px; }
.sheet-top { display: flex; align-items: center; gap: 10px; }
.sheet-top .mp-icon { width: 28px; height: 28px; color: #FF8A3D; }
.sheet-top b { display: block; font-size: 16px; }
.sheet-top p { margin: 2px 0 0; color: #8A6A52; font-size: 12px; }
.sheet-actions { display: flex; gap: 8px; margin-top: 10px; }
.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 14px;
  background: #FFF1E4;
  color: #3A2416;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.icon-btn:active { transform: scale(0.96); }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 16px;
  background: #FF8A3D;
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  box-shadow: 0 6px 0 #D8651C;
}
.btn .mp-icon { width: 20px; height: 20px; color: #fff; }
.btn:active { transform: translateY(3px); box-shadow: 0 3px 0 #D8651C; }
.btn.ghost {
  background: #FFF8F0;
  color: #3A2416;
  box-shadow: 0 5px 0 #E6D3C0;
  border: 1px solid #F3E4D6;
}
.btn.ghost .mp-icon { color: #FF8A3D; }
.btn.small { min-height: 42px; font-size: 15px; box-shadow: 0 4px 0 #D8651C; }
.btn.ghost.small { box-shadow: 0 4px 0 #E6D3C0; }
.btn:disabled { opacity: 0.45; transform: none; }

#menu, #result {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
}
.logo {
  position: absolute;
  top: calc(11% + env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  text-align: center;
  color: #fff;
  text-shadow: 0 2px 0 rgba(180, 70, 10, 0.35);
}
.logo-badge {
  width: 64px;
  height: 64px;
  margin: 0 auto;
  border-radius: 22px;
  background: #FF8A3D;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 0 #D8651C;
  color: #fff;
}
.logo-badge .mp-icon { width: 34px; height: 34px; }
.logo h1 { margin: 12px 0 0; font-size: 32px; letter-spacing: 0.02em; }
.logo p { margin: 6px 0 0; font-size: 15px; font-weight: 700; }
.panel {
  pointer-events: auto;
  margin: 0 16px calc(14px + env(safe-area-inset-bottom));
  padding: 16px;
  max-height: 68%;
  overflow: auto;
}
.player { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #FFE0C2;
  color: #E36A1A;
  font-weight: 800;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 0 0 auto;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.player-meta { flex: 1; min-width: 0; }
.player-meta input {
  width: 100%;
  border: 0;
  background: transparent;
  color: #3A2416;
  font-size: 18px;
  font-weight: 800;
  padding: 0;
}
.player-meta input:focus { outline: none; }
.player-meta span, .muted, .rate, .fine, .cash-label {
  color: #8A6A52;
  font-size: 12px;
}
.stats { display: flex; gap: 10px; margin: 14px 0; }
.stat {
  flex: 1;
  background: #FFF1E4;
  border-radius: 14px;
  padding: 10px 12px;
}
.stat span { display: block; color: #8A6A52; font-size: 12px; }
.stat b { display: block; margin-top: 2px; font-size: 22px; font-variant-numeric: tabular-nums; }
.panel .btn { margin-top: 10px; }

#pause {
  position: absolute;
  inset: 0;
  z-index: 7;
  background: rgba(40, 22, 10, 0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.pause-card { width: min(100%, 320px); text-align: center; padding: 22px 18px; }
.pause-title { font-size: 22px; }
.pause-card .btn { margin-top: 12px; }

#result .panel { text-align: center; }
.res-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 8px;
  border-radius: 22px;
  background: #FFE7D2;
  color: #FF8A3D;
  display: flex;
  align-items: center;
  justify-content: center;
}
.res-mark .mp-icon { width: 34px; height: 34px; }
.res-mark.bad { background: #FDE2E2; color: #E23B4A; }
#result h2 { margin: 0; font-size: 24px; }
.gain { margin: 12px 0 4px; }
.gain span { display: block; color: #8A6A52; font-size: 12px; }
.gain b {
  display: block;
  font-size: 40px;
  color: #E36A1A;
  font-variant-numeric: tabular-nums;
}
#res-note { margin: 0 0 6px; }

#shop {
  position: absolute;
  inset: 0;
  z-index: 8;
  background: #F3E2CF;
  overflow: auto;
}
.shop-page {
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}
.shop-bar { display: flex; align-items: center; gap: 8px; }
.shop-bar h2 { margin: 0; font-size: 20px; }
.money { display: flex; gap: 10px; margin-top: 14px; }
.card { flex: 1; padding: 14px; }
.card span { display: block; color: #8A6A52; font-size: 12px; }
.card b { display: block; margin-top: 4px; font-size: 22px; font-variant-numeric: tabular-nums; }
.card em { font-style: normal; }
.rate { margin: 12px 4px; }
#shop-progress { margin-top: -6px; font-weight: 700; color: #C97812; }
.stack .btn { margin-top: 8px; }
.cash-label { display: block; margin: 16px 4px 6px; }
.field {
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  border: 1.5px solid #F0D8C4;
  background: #fff;
  padding: 0 14px;
  font-size: 16px;
  color: #3A2416;
}
.field:focus { outline: none; border-color: #FF8A3D; }
#btn-cash { margin-top: 12px; }
#cash-tip { margin: 8px 4px 0; }
#shop h3 { margin: 18px 4px 8px; font-size: 15px; }
.log {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #FFF8F0;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 8px;
  box-shadow: 0 4px 12px rgba(70, 30, 10, 0.06);
}
.log b { font-size: 15px; }
.log span { color: #8A6A52; font-size: 13px; }
.empty { margin: 0; color: #8A6A52; font-size: 13px; }
.fine { margin: 8px 4px 0; line-height: 1.5; }

#toast {
  position: absolute;
  z-index: 20;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  max-width: 84%;
  padding: 12px 16px;
  border-radius: 16px;
  background: rgba(58, 36, 22, 0.94);
  color: #fff;
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

button:focus-visible, input:focus-visible {
  outline: 3px solid rgba(255, 138, 61, 0.55);
  outline-offset: 2px;
}

@media (max-height: 700px) {
  .logo { top: calc(7% + env(safe-area-inset-top)); }
  .logo-badge { width: 54px; height: 54px; border-radius: 18px; }
  .logo-badge .mp-icon { width: 28px; height: 28px; }
  .logo h1 { font-size: 26px; }
  .panel { padding: 14px; max-height: 64%; }
  .stats { margin: 10px 0; }
  .stat { padding: 8px 10px; }
  .stat b { font-size: 19px; }
  .btn { min-height: 46px; font-size: 16px; }
}

@media (max-width: 360px) {
  #hud { left: 8px; right: 8px; gap: 4px; }
  .pill { min-height: 32px; padding: 3px 6px; gap: 3px; }
  .pill .mp-icon { width: 18px; height: 18px; }
  .pill b { font-size: 13px; }
  .btn-pill { min-width: 32px; padding: 3px 8px; }
  #dock { gap: 6px; }
  .tw { min-height: 70px; border-radius: 14px; }
}

@media (max-width: 340px) {
  .stat span { font-size: 11px; }
  .stat b { font-size: 18px; }
  .logo h1 { font-size: 24px; }
  .tw b { font-size: 13px; }
}
