* { box-sizing: border-box; }

:root {
  --orange: #FF8A3D;
  --orange-deep: #F06A22;
  --orange-dark: #B35422;
  --ink: #4A2A16;
  --ink-soft: #8A6246;
  --cream: #FFF6E8;
  --glass: rgba(255, 250, 242, .78);
  --glass-strong: rgba(255, 251, 245, .9);
  --line: rgba(255, 255, 255, .82);
  --shadow-warm: 0 10px 26px rgba(163, 82, 34, .16);
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #FFD9AE;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

/* ---------------- top HUD ---------------- */

.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px 0;
  pointer-events: none;
}

.hud-top {
  position: relative;
  width: 100%;
  min-height: 64px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.player-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  max-width: 152px;
  padding: 5px 13px 5px 5px;
  border-radius: 999px;
  background: linear-gradient(145deg, rgba(255, 252, 246, .9), rgba(255, 242, 225, .74));
  border: 1px solid var(--line);
  box-shadow: var(--shadow-warm), inset 0 1px 0 rgba(255, 255, 255, .95);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  backdrop-filter: blur(14px) saturate(1.1);
  pointer-events: auto;
}

.avatar {
  position: relative;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(160deg, #FFE7C8, #FFD0A0);
  border: 2px solid rgba(255, 255, 255, .98);
  box-shadow: 0 3px 8px rgba(150, 75, 30, .22), 0 0 0 1px rgba(255, 154, 88, .18);
  background-size: cover;
  background-position: center;
}

.avatar svg { width: 100%; height: 100%; display: block; }
.avatar.has-img svg { display: none; }

.player-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.player-name {
  min-width: 0;
  font-size: 12.5px;
  line-height: 1.25;
  font-weight: 800;
  color: #5A341B;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: .01em;
}

.player-tag {
  font-size: 8.5px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: .18em;
  color: rgba(140, 91, 55, .62);
}

.score-board {
  position: absolute;
  left: 50%;
  top: -2px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  filter: drop-shadow(0 6px 14px rgba(173, 83, 33, .14));
}

.score-kicker {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 250, 242, .58);
  border: 1px solid rgba(255, 255, 255, .72);
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: .2em;
  margin-left: .2em;
  color: rgba(111, 63, 30, .68);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.score-kicker .mp-icon { width: 11px; height: 11px; color: var(--orange-deep); }

.score-value {
  margin-top: 1px;
  font-size: 58px;
  line-height: .9;
  font-weight: 900;
  letter-spacing: -.045em;
  font-variant-numeric: tabular-nums;
  color: #4E2B15;
  text-shadow:
    0 1px 0 #FFF9EE,
    0 3px 0 rgba(255, 255, 255, .62),
    0 9px 20px rgba(150, 70, 22, .22);
  transition: transform .12s ease;
}

.score-value.bump { animation: scoreBump .36s cubic-bezier(.2, 1.5, .4, 1); }

@keyframes scoreBump {
  0% { transform: scale(1); }
  38% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

.best-line {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  background: rgba(255, 250, 242, .7);
  border: 1px solid rgba(255, 255, 255, .82);
  font-size: 10.5px;
  font-weight: 800;
  color: rgba(103, 60, 28, .78);
  box-shadow: 0 3px 10px rgba(160, 84, 34, .1);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.best-line .mp-icon { width: 12px; height: 12px; color: #E49A2D; }
.best-line b { font-size: 11.5px; color: #6B3C1D; font-variant-numeric: tabular-nums; }

.round-btn {
  pointer-events: auto;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(255, 252, 246, .9), rgba(255, 242, 225, .72));
  color: #7A4524;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-warm), inset 0 1px 0 rgba(255, 255, 255, .95);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  cursor: pointer;
  transition: transform .12s ease, background .18s ease;
}

.round-btn .mp-icon { width: 21px; height: 21px; }
.round-btn:active { transform: scale(.88); background: rgba(255, 243, 226, .98); }
.round-btn.off { color: #A88C76; }

.combo-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  padding: 4px 11px 4px 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, #FFE9A6, #FFC152);
  border: 1px solid rgba(255, 250, 225, .9);
  color: #7A3E0E;
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: .04em;
  box-shadow: 0 5px 14px rgba(214, 139, 40, .3), inset 0 1px 0 rgba(255, 255, 255, .6);
  opacity: 0;
  transform: translateY(-5px) scale(.88);
  transition: opacity .18s ease, transform .24s cubic-bezier(.2, 1.4, .4, 1);
}

.combo-chip .mp-icon { width: 12px; height: 12px; color: #A45A10; }
.combo-chip.show { opacity: 1; transform: translateY(0) scale(1); }

/* ---------------- bottom controls ---------------- */

.bottom-ui {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  pointer-events: none;
}

.hint-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 15px 7px 8px;
  border-radius: 999px;
  background: rgba(255, 250, 242, .8);
  border: 1px solid rgba(255, 255, 255, .92);
  box-shadow: 0 6px 18px rgba(160, 84, 34, .14), inset 0 1px 0 #fff;
  color: #714322;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .01em;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  animation: hintFloat 2.6s ease-in-out infinite;
  transition: opacity .3s ease, transform .3s ease;
}

.hint-finger {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(145deg, #FFB368, #FF8534);
  box-shadow: 0 3px 8px rgba(226, 106, 36, .3), inset 0 1px 0 rgba(255, 255, 255, .5);
  color: #FFF9EF;
}

.hint-finger .mp-icon { width: 14px; height: 14px; }
.hint-pill.off { opacity: 0; transform: translateY(10px); animation: none; }

@keyframes hintFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.power-card {
  width: min(344px, calc(100vw - 32px));
  padding: 10px 14px 9px;
  border-radius: 22px;
  background: linear-gradient(150deg, rgba(255, 252, 246, .88), rgba(255, 243, 229, .76));
  border: 1px solid rgba(255, 255, 255, .85);
  box-shadow: 0 14px 32px rgba(160, 84, 34, .16), inset 0 1px 0 rgba(255, 255, 255, .95);
  -webkit-backdrop-filter: blur(16px) saturate(1.08);
  backdrop-filter: blur(16px) saturate(1.08);
  transition: transform .18s ease, box-shadow .22s ease, background .22s ease;
}

.power-card.active {
  transform: translateY(-2px) scale(1.016);
  background: linear-gradient(150deg, rgba(255, 253, 248, .94), rgba(255, 242, 225, .86));
  box-shadow: 0 16px 38px rgba(226, 106, 36, .26), 0 0 0 1px rgba(255, 190, 120, .55), inset 0 1px 0 #fff;
}

.power-card.full { animation: fullPulse .55s ease-in-out infinite alternate; }

@keyframes fullPulse {
  from { box-shadow: 0 16px 38px rgba(226, 106, 36, .26), 0 0 0 1px rgba(255, 190, 120, .55), inset 0 1px 0 #fff; }
  to { box-shadow: 0 16px 42px rgba(255, 96, 26, .42), 0 0 0 3px rgba(255, 172, 92, .42), inset 0 1px 0 #fff; }
}

.power-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
}

.power-title {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: .16em;
  color: rgba(110, 63, 31, .74);
}

.power-title .mp-icon { width: 13px; height: 13px; color: var(--orange-deep); }

.power-pct {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .02em;
  color: #C2632A;
  font-variant-numeric: tabular-nums;
}

.power-track {
  position: relative;
  height: 14px;
  border-radius: 999px;
  background: rgba(178, 116, 70, .14);
  box-shadow: inset 0 2px 5px rgba(140, 82, 42, .17), 0 1px 0 rgba(255, 255, 255, .7);
  overflow: visible;
}

.power-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #FFD68A 0%, #FFAE55 34%, #FF8736 68%, #F45E1E 100%);
  box-shadow: 0 0 14px rgba(255, 128, 56, .5), inset 0 1px 0 rgba(255, 255, 255, .45);
  transition: width .05s linear;
}

.power-ticks {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: repeating-linear-gradient(90deg,
    transparent 0,
    transparent calc(10% - 1px),
    rgba(255, 255, 255, .34) calc(10% - 1px),
    rgba(255, 255, 255, .34) 10%);
  pointer-events: none;
}

.power-knob {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 27px;
  height: 27px;
  margin-left: -13.5px;
  border-radius: 50%;
  transform: translateY(-50%) scale(.72);
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #FFFDF7, #FFE6C9);
  border: 2px solid #FFF9EF;
  color: #E06B24;
  box-shadow: 0 4px 10px rgba(190, 90, 30, .32), 0 0 0 1px rgba(255, 160, 88, .28);
  transition: transform .14s ease, left .05s linear;
  pointer-events: none;
}

.power-knob .mp-icon { width: 14px; height: 14px; }
.power-card.active .power-knob { transform: translateY(-50%) scale(1); }

.power-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  color: rgba(126, 82, 50, .5);
}

.power-foot-mid { color: rgba(126, 82, 50, .62); letter-spacing: .04em; }

/* ---------------- result overlay ---------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 42%, rgba(94, 44, 14, .1) 0%, rgba(74, 33, 9, .46) 100%);
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
  opacity: 0;
  transition: opacity .28s ease;
}

.overlay[hidden] { display: none; }
.overlay.show { opacity: 1; }

.result-card {
  position: relative;
  width: min(342px, calc(100vw - 44px));
  padding: 28px 22px 20px;
  border-radius: 30px;
  text-align: center;
  background: linear-gradient(178deg, #FFFDF8 0%, #FFF7EA 56%, #FFEEDA 100%);
  border: 1px solid rgba(255, 255, 255, .98);
  box-shadow: 0 30px 72px rgba(99, 45, 14, .36), 0 2px 0 rgba(255, 255, 255, .9) inset;
  transform: translateY(20px) scale(.93);
  opacity: 0;
  transition: transform .4s cubic-bezier(.16, 1.22, .36, 1), opacity .26s ease;
}

.overlay.show .result-card { transform: translateY(0) scale(1); opacity: 1; }

.result-card::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -54px;
  width: 268px;
  height: 160px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(255, 186, 105, .42), rgba(255, 186, 105, 0) 68%);
  pointer-events: none;
}

.result-top {
  position: relative;
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

.result-medal {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #FFF8EC;
  background: linear-gradient(150deg, #FFB05F, #FF7A32 55%, #F15A1F);
  border: 3px solid #FFF9EF;
  box-shadow: 0 12px 24px rgba(224, 104, 38, .36), inset 0 2px 0 rgba(255, 255, 255, .45);
  animation: badgePop .55s .08s cubic-bezier(.2, 1.5, .4, 1) both;
}

.result-medal .mp-icon { width: 31px; height: 31px; }

@keyframes badgePop {
  0% { transform: scale(.4) rotate(-16deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.result-kicker {
  margin: 0;
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: .32em;
  margin-left: .32em;
  color: #A87C5E;
}

.result-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  margin: 1px 0 0;
  font-variant-numeric: tabular-nums;
}

.result-score span {
  font-size: 72px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -.05em;
  color: var(--orange-deep);
  text-shadow: 0 3px 0 rgba(255, 255, 255, .9), 0 12px 26px rgba(226, 106, 36, .28);
}

.result-score small {
  font-size: 15px;
  font-weight: 900;
  color: #C98961;
  transform: translateY(-7px);
}

.result-sub {
  margin: 2px 0 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  color: #B08A6C;
}

.new-best {
  position: absolute;
  top: 15px;
  right: 13px;
  padding: 5px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #FFE7A6, #FFC24F);
  color: #8A4808;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  transform: rotate(7deg);
  box-shadow: 0 4px 10px rgba(205, 132, 38, .25);
}

.new-best[hidden] { display: none; }

.result-stats {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 12px;
  margin: 14px 0 15px;
  padding: 11px 12px;
  border-radius: 19px;
  background: rgba(255, 255, 255, .7);
  border: 1px solid rgba(255, 255, 255, .92);
  box-shadow: inset 0 1px 0 #fff, 0 5px 16px rgba(160, 90, 40, .07);
}

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

.stat-ico { display: grid; place-items: center; color: #D98A45; }
.stat-ico .mp-icon { width: 15px; height: 15px; }
.stat-label { font-size: 9.5px; font-weight: 700; letter-spacing: .08em; color: #A9856B; }
.stat b { font-size: 21px; line-height: 1.05; font-weight: 900; color: #56301A; font-variant-numeric: tabular-nums; }
.stat-divider { width: 1px; background: rgba(180, 130, 92, .2); }

.btn-primary {
  position: relative;
  width: 100%;
  height: 54px;
  border: 0;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: .04em;
  color: #FFF9EF;
  background: linear-gradient(180deg, #FFA65C 0%, #FF8636 42%, #F26622 100%);
  box-shadow: 0 11px 22px rgba(226, 100, 34, .36), inset 0 1px 0 rgba(255, 255, 255, .5), inset 0 -3px 0 rgba(190, 70, 18, .35);
  cursor: pointer;
  overflow: hidden;
  touch-action: manipulation;
  transition: transform .1s ease, filter .16s ease;
}

.btn-primary::after {
  content: "";
  position: absolute;
  top: 0;
  left: -40%;
  width: 40%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .38), transparent);
  transform: skewX(-18deg);
  animation: btnShine 3.4s 1s ease-in-out infinite;
}

@keyframes btnShine {
  0%, 62% { left: -50%; }
  85%, 100% { left: 120%; }
}

.btn-primary:active { transform: translateY(1px) scale(.985); filter: brightness(.96); }
.btn-primary .mp-icon { width: 20px; height: 20px; }

.result-tip {
  margin: 11px 0 0;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .02em;
  color: #AA8B76;
}

/* ---------------- small screens ---------------- */

@media (max-width: 360px) {
  .hud { padding-left: 11px; padding-right: 11px; }
  .player-chip { max-width: 124px; padding-right: 9px; }
  .player-name { font-size: 11.5px; }
  .player-tag { font-size: 8px; letter-spacing: .12em; }
  .score-value { font-size: 50px; }
  .round-btn { width: 38px; height: 38px; }
  .bottom-ui { padding-left: 13px; padding-right: 13px; }
  .hint-pill { font-size: 11.5px; padding: 6px 12px 6px 7px; }
  .power-card { padding: 9px 13px 8px; }
  .result-score span { font-size: 64px; }
}

@media (max-height: 690px) {
  .hud-top { min-height: 58px; }
  .score-value { font-size: 48px; }
  .best-line { margin-top: 1px; }
  .bottom-ui { gap: 8px; padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 11px); }
  .power-card { padding: 8px 13px 7px; }
  .power-foot { margin-top: 4px; }
  .result-card { padding-top: 24px; padding-bottom: 16px; }
  .result-score span { font-size: 60px; }
  .result-stats { margin: 11px 0 12px; padding: 9px 10px; }
  .btn-primary { height: 50px; }
}

@media (max-height: 610px) {
  .hint-pill { display: none; }
  .score-value { font-size: 42px; }
  .player-chip { transform: scale(.92); transform-origin: left top; }
  .result-score span { font-size: 52px; }
  .result-sub { display: none; }
  .result-tip { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .hint-pill, .result-medal, .power-card.full { animation: none; }
  .btn-primary::after { animation: none; display: none; }
  .score-value.bump { animation: none; }
}
