/* 乒乓球7 — 双人对打 · 卡通游戏界面 */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --orange: #FF8A3D;
  --orange-deep: #F26A10;
  --orange-dark: #B3440A;
  --gold: #FFD15C;
  --blue: #2D7BFF;
  --red: #FF4D5E;
  --ink: #2A120B;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #7C260B;
  font-family: var(--font);
  overscroll-behavior: none;
}

body { position: fixed; inset: 0; }

.hidden { display: none !important; }

.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  background: #A93A12;
}

.game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
  touch-action: none;
}

.canvas-vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(54, 16, 4, 0.30) 0%, transparent 17%, transparent 82%, rgba(44, 10, 2, 0.20) 100%),
    radial-gradient(ellipse at 50% 48%, transparent 40%, rgba(80, 25, 5, 0.13) 76%, rgba(48, 11, 2, 0.36) 100%);
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  z-index: 20;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 0;
  pointer-events: none;
}

.score-card {
  flex: 1 1 0;
  max-width: 140px;
  min-width: 0;
  height: 54px;
  border-radius: 17px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 9px;
  color: #fff;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.30);
  box-shadow: 0 8px 18px rgba(55, 10, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.score-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.28) 0%, transparent 38%, transparent 100%);
  pointer-events: none;
}

.score-card.blue {
  background: linear-gradient(145deg, #4B9AFF 0%, #2169EE 55%, #1650C8 100%);
}

.score-card.red {
  background: linear-gradient(145deg, #FF737B 0%, #EA344B 55%, #C51D34 100%);
}

.score-card .avatar {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.94);
  background: #fff;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.28);
}

.score-card .avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.score-card .score {
  flex: 1 1 auto;
  text-align: center;
  font-size: 29px;
  line-height: 1;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.22);
}

.score-card.red .score { text-align: center; }

.score-card.bump .score { animation: scorePop 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.4); }

.vs {
  flex: 0 0 auto;
  width: 40px;
  text-align: center;
  font-size: 23px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: -1px;
  color: var(--gold);
  text-shadow: 0 2px 0 #AE3B0D, 0 0 14px rgba(255, 190, 80, 0.45);
  transform: rotate(-4deg);
}

.pause-btn {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #FFF6EC;
  background: rgba(30, 12, 6, 0.44);
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 5px 14px rgba(40, 10, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
  pointer-events: auto;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s, background 0.12s;
}

.pause-btn .mp-icon { width: 21px; height: 21px; }
.pause-btn:active { transform: scale(0.92); background: rgba(30, 12, 6, 0.62); }

/* ---------- 场内提示 ---------- */
.hint {
  position: absolute;
  z-index: 15;
  left: 50%;
  transform: translateX(-50%);
  padding: 7px 13px;
  border-radius: 999px;
  color: rgba(255, 244, 232, 0.92);
  background: rgba(30, 12, 6, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 14px rgba(30, 8, 0, 0.2);
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
  font-size: 11px;
  letter-spacing: 0.4px;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.hint b { font-weight: 800; margin-right: 3px; }
.hint-top { top: calc(env(safe-area-inset-top, 0px) + 78px); }
.hint-top b { color: #FF9AA4; }
.hint-bottom { bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); }
.hint-bottom b { color: #8FBBFF; }
.hint.fade { opacity: 0; transform: translate(-50%, 6px); }

.toast {
  position: absolute;
  z-index: 18;
  top: 21%;
  left: 50%;
  transform: translate(-50%, 0);
  padding: 8px 17px;
  border-radius: 999px;
  color: #FFF6E6;
  background: rgba(28, 11, 5, 0.58);
  border: 1px solid rgba(255, 200, 150, 0.34);
  box-shadow: 0 8px 22px rgba(30, 8, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.2px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show { opacity: 1; transform: translate(-50%, -4px); }

/* ---------- 首页 ---------- */
.splash {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 100%, #B84215 0%, #7A2309 55%, #56170A 100%);
  touch-action: pan-y;
  opacity: 1;
  transition: opacity 0.36s ease, transform 0.36s ease;
}

.splash.leaving {
  opacity: 0;
  transform: scale(1.035);
  pointer-events: none;
}

.hero {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  aspect-ratio: 3 / 2;
  max-height: 40vh;
  min-height: 185px;
  overflow: hidden;
  background: #1E0E08;
}

.hero-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 47%;
  display: block;
  transform: scale(1.01);
  transform-origin: 50% 45%;
  animation: heroZoom 17s ease-in-out infinite alternate;
}

.hero-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(28, 9, 3, 0.36) 0%, transparent 17%, transparent 60%, rgba(150, 45, 10, 0.42) 83%, #C7501B 100%),
    linear-gradient(90deg, rgba(50, 15, 4, 0.28) 0%, transparent 18%, transparent 82%, rgba(50, 15, 4, 0.28) 100%);
}

.hero-tag {
  position: absolute;
  z-index: 2;
  left: 16px;
  bottom: 30px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  color: #FFF3E3;
  background: rgba(30, 10, 5, 0.44);
  border: 1px solid rgba(255, 255, 255, 0.24);
  box-shadow: 0 5px 16px rgba(20, 5, 0, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
}

.tag-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 9px currentColor;
}

.tag-dot.blue { color: #4D9BFF; }
.tag-dot.red { color: #FF5B67; }

.lobby {
  position: relative;
  z-index: 3;
  flex: 1 1 auto;
  min-height: 0;
  margin-top: -26px;
  border-radius: 28px 28px 0 0;
  padding: 22px 22px calc(env(safe-area-inset-bottom, 0px) + 18px);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 172, 94, 0.36) 0%, transparent 58%),
    linear-gradient(180deg, #C7501B 0%, #A53B12 46%, #7C260B 100%);
  box-shadow: 0 -14px 34px rgba(70, 18, 4, 0.35), inset 0 1px 0 rgba(255, 210, 170, 0.36);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.lobby::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.022) 0 2px, transparent 2px 10px);
  opacity: 0.65;
}

.lobby > * { position: relative; z-index: 1; }

.lobby-title { text-align: center; }

.eyebrow {
  margin: 0 0 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 3.2px;
  color: rgba(255, 218, 180, 0.70);
}

.game-logo {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-size: clamp(36px, 10.5vw, 46px);
  line-height: 1.02;
  font-weight: 900;
  letter-spacing: 2px;
  color: #FFFDF7;
  text-shadow: 0 2px 0 #8E2A0B, 0 4px 0 #6B1C06, 0 11px 24px rgba(0, 0, 0, 0.42);
}

.logo-seven {
  display: inline-block;
  margin-left: 2px;
  color: #FFD15C;
  font-size: 1.12em;
  transform: rotate(-7deg) translateY(-1px);
  text-shadow: 0 2px 0 #C75A0C, 0 4px 0 #8E2A0B, 0 9px 18px rgba(0, 0, 0, 0.32);
}

.lobby-sub {
  margin: 9px 0 0;
  font-size: 12.5px;
  letter-spacing: 0.6px;
  color: rgba(255, 232, 210, 0.80);
}

.matchup {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 2px 0;
}

.player {
  flex: 1 1 0;
  min-width: 0;
  max-width: 154px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 18px;
  background: rgba(30, 10, 5, 0.30);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.player.blue {
  border-color: rgba(100, 160, 255, 0.36);
  background: linear-gradient(135deg, rgba(42, 102, 220, 0.42), rgba(18, 38, 88, 0.30));
}

.player.red {
  border-color: rgba(255, 112, 124, 0.36);
  background: linear-gradient(135deg, rgba(220, 52, 72, 0.38), rgba(90, 20, 30, 0.28));
}

.player img {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.92);
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.26);
}

.p-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.1;
}

.p-meta b {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: #FFFFFF;
  white-space: nowrap;
}

.p-meta span {
  font-size: 10px;
  color: rgba(255, 240, 225, 0.62);
  white-space: nowrap;
}

.player.red .p-meta {
  margin-left: auto;
  text-align: right;
}

.vs-badge {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #7A2605;
  background: linear-gradient(160deg, #FFE08A 0%, #FFB32C 55%, #F08A12 100%);
  border: 2px solid rgba(255, 255, 255, 0.66);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.30), inset 0 2px 0 rgba(255, 255, 255, 0.52);
  font-size: 13px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: -0.5px;
  transform: rotate(-5deg);
  animation: vsPulse 3.2s ease-in-out infinite;
}

.start-btn {
  position: relative;
  width: 100%;
  max-width: 320px;
  height: 58px;
  margin: 4px auto 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  overflow: hidden;
  font-family: inherit;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 3px;
  color: #FFFFFF;
  text-shadow: 0 2px 0 rgba(120, 40, 0, 0.38);
  background: linear-gradient(180deg, #FFC25C 0%, #FF9A37 34%, #FF7518 100%);
  box-shadow: 0 7px 0 #AF3F08, 0 15px 28px rgba(40, 8, 0, 0.42), inset 0 3px 0 rgba(255, 255, 255, 0.50);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.start-btn::before {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: inherit;
  box-shadow: 0 0 26px rgba(255, 155, 55, 0.55);
  animation: startBreathe 2.8s ease-in-out infinite;
  pointer-events: none;
}

.start-btn::after {
  content: "";
  position: absolute;
  top: -60%;
  left: -40%;
  width: 26%;
  height: 220%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.50), transparent);
  transform: rotate(20deg);
  animation: btnShine 4.6s ease-in-out infinite;
  pointer-events: none;
}

.start-btn > * { position: relative; z-index: 1; }

.start-btn:active {
  transform: translateY(4px) scale(0.988);
  box-shadow: 0 3px 0 #AF3F08, 0 7px 16px rgba(40, 8, 0, 0.36), inset 0 3px 0 rgba(255, 255, 255, 0.42);
}

.play-tri {
  width: 0;
  height: 0;
  border-left: 16px solid #FFFFFF;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  margin-left: 3px;
  filter: drop-shadow(0 1px 0 rgba(120, 40, 0, 0.28));
}

.play-tri.small {
  border-left-width: 11px;
  border-top-width: 7px;
  border-bottom-width: 7px;
  margin-left: 1px;
}

.lobby-tip {
  margin: 2px 0 0;
  text-align: center;
  font-size: 10.5px;
  letter-spacing: 0.5px;
  color: rgba(255, 232, 212, 0.58);
}

/* ---------- 弹层 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: radial-gradient(circle at 50% 44%, rgba(35, 12, 5, 0.35) 0%, rgba(20, 6, 2, 0.76) 100%);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
}

.overlay:not(.hidden) .modal-card { animation: cardIn 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.14); }

.modal-card {
  position: relative;
  width: 100%;
  max-width: 340px;
  overflow: hidden;
  border-radius: 26px;
  padding: 22px 20px 18px;
  text-align: center;
  color: #fff;
  background: linear-gradient(165deg, rgba(74, 33, 16, 0.98) 0%, rgba(45, 19, 9, 0.99) 58%, rgba(30, 12, 5, 0.99) 100%);
  border: 1px solid rgba(255, 190, 130, 0.22);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.modal-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% -10%, rgba(255, 170, 90, 0.24), transparent 56%);
  pointer-events: none;
}

.modal-card > * { position: relative; z-index: 1; }

.modal-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 3px;
  color: rgba(255, 205, 160, 0.62);
}

.modal-title {
  margin: 7px 0 0;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #FFF7EE;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}

.modal-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin: 12px 0 0;
  font-size: 42px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.modal-score span { min-width: 42px; text-align: center; }
.ms-blue { color: #7FB3FF; text-shadow: 0 0 18px rgba(60, 130, 255, 0.50); }
.ms-red { color: #FF8A94; text-shadow: 0 0 18px rgba(255, 70, 90, 0.45); }
.modal-score em {
  font-style: normal;
  font-size: 25px;
  color: rgba(255, 220, 190, 0.46);
  transform: translateY(-4px);
}

.modal-sub {
  margin: 9px 0 18px;
  font-size: 11px;
  letter-spacing: 0.6px;
  color: rgba(255, 225, 205, 0.55);
}

.btn {
  width: 100%;
  height: 50px;
  border: 0;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn .mp-icon { width: 18px; height: 18px; }

.btn.primary {
  margin-bottom: 8px;
  color: #FFFFFF;
  text-shadow: 0 1px 0 rgba(120, 40, 0, 0.30);
  background: linear-gradient(180deg, #FFAE4A 0%, #FF7E1D 100%);
  box-shadow: 0 7px 18px rgba(255, 110, 20, 0.32), inset 0 2px 0 rgba(255, 255, 255, 0.35);
}

.btn.ghost {
  color: rgba(255, 238, 225, 0.80);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn:active { transform: scale(0.972); filter: brightness(0.96); }

.winner-wrap {
  position: relative;
  width: 92px;
  height: 92px;
  margin: 0 auto 10px;
}

.winner-avatar {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  border: 4px solid rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.38);
}

.trophy {
  position: absolute;
  right: -7px;
  bottom: -5px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #8A3A05;
  background: linear-gradient(160deg, #FFE08A, #FFB32C);
  border: 2px solid #FFF3D0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.30);
}

.trophy .mp-icon { width: 19px; height: 19px; }

/* ---------- 动画 ---------- */
@keyframes heroZoom {
  from { transform: scale(1.01); }
  to { transform: scale(1.055); }
}

@keyframes vsPulse {
  0%, 100% { transform: rotate(-5deg) scale(1); }
  50% { transform: rotate(-5deg) scale(1.06); }
}

@keyframes startBreathe {
  0%, 100% { box-shadow: 0 0 20px rgba(255, 155, 55, 0.42); }
  50% { box-shadow: 0 0 38px rgba(255, 175, 80, 0.72); }
}

@keyframes btnShine {
  0%, 52% { left: -40%; }
  78%, 100% { left: 135%; }
}

@keyframes scorePop {
  0% { transform: scale(1); }
  42% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px) scale(0.955); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- 适配 ---------- */
@media (max-width: 352px) {
  .score-card { height: 50px; border-radius: 15px; padding: 0 7px; gap: 6px; }
  .score-card .avatar { width: 33px; height: 33px; }
  .score-card .score { font-size: 25px; }
  .vs { width: 32px; font-size: 20px; }
  .pause-btn { width: 34px; height: 34px; }
  .pause-btn .mp-icon { width: 18px; height: 18px; }
  .hud { gap: 5px; padding-left: 9px; padding-right: 9px; }
  .player { height: 52px; padding: 6px 8px; border-radius: 16px; }
  .player img { width: 35px; height: 35px; }
  .p-meta b { font-size: 11px; }
  .p-meta span { font-size: 9px; }
  .vs-badge { width: 33px; height: 33px; font-size: 12px; }
  .matchup { gap: 7px; }
}

@media (max-height: 700px) {
  .hero { max-height: 37vh; min-height: 165px; }
  .lobby { gap: 10px; padding-top: 18px; }
  .game-logo { font-size: clamp(32px, 9.5vw, 40px); }
  .lobby-sub { margin-top: 6px; }
  .player { height: 50px; }
  .player img { width: 35px; height: 35px; }
  .start-btn { height: 52px; font-size: 17px; }
  .eyebrow { margin-bottom: 4px; }
}

@media (max-height: 600px) {
  .hero { min-height: 150px; max-height: 34vh; }
  .lobby { justify-content: flex-start; }
  .matchup { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
