:root {
  --ink: #39224c;
  --muted: rgba(57,34,76,.66);
  --panel: rgba(255,255,255,.72);
  --panel-strong: rgba(255,255,255,.92);
  --pink: #ff6ea8;
  --violet: #8d77ff;
  --cyan: #44d7ff;
  --yellow: #ffd85c;
  --green: #73df8a;
  --shadow: 0 16px 42px rgba(95,54,126,.22);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 18%, rgba(255,216,92,.58), transparent 28%),
    radial-gradient(circle at 82% 14%, rgba(68,215,255,.42), transparent 30%),
    linear-gradient(135deg, #fff7d7, #ffe6f2 48%, #e6f7ff);
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}
.s2-shell { position: fixed; inset: 0; overflow: hidden; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.s2-hud {
  position: absolute;
  z-index: 10;
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  top: calc(env(safe-area-inset-top) + 12px);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
.icon-btn, .scorebox, .timer, .leaderboard, .room-chip, .center-tip {
  background: var(--panel);
  border: 2px solid rgba(255,255,255,.74);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}
.icon-btn {
  pointer-events: auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 22px;
  font-weight: 950;
}
.icon-btn.back { font-size: 40px; padding-bottom: 4px; }
.scorebox {
  min-width: 142px;
  min-height: 50px;
  border-radius: 20px;
  padding: 7px 13px;
  display: grid;
  grid-template-columns: auto auto;
  gap: 0 9px;
  align-items: center;
  background: rgba(255,255,255,.38);
  border-color: rgba(255,255,255,.48);
  box-shadow: 0 10px 26px rgba(95,54,126,.12);
}
.scorebox span { color: rgba(231,78,142,.86); font-weight: 950; font-size: 14px; }
.scorebox strong { font-size: 24px; line-height: 1; color: #251034; }
.scorebox small { grid-column: 1 / 3; color: rgba(57,34,76,.56); font-size: 11px; font-weight: 850; }
.timer {
  margin-left: auto;
  min-width: 78px;
  height: 46px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 950;
  color: #251034;
}
.leaderboard {
  position: absolute;
  z-index: 9;
  top: calc(env(safe-area-inset-top) + 72px);
  right: max(14px, env(safe-area-inset-right));
  width: min(168px, 39vw);
  padding: 2px 0;
  display: grid;
  gap: 5px;
  background: transparent;
  border: 0;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.rank-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  font-size: 10px;
  font-weight: 950;
  color: rgba(57,34,76,.62);
  text-shadow: 0 2px 8px rgba(255,255,255,.95), 0 0 2px rgba(255,255,255,.9);
}
.rank-row.me { color: #251034; }
.rank-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.9);
  box-shadow: 0 3px 10px rgba(57,34,76,.18);
  display: inline-block;
  vertical-align: -3px;
}
.rank-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rank-meta { text-align: right; font-variant-numeric: tabular-nums; }
.room-chip {
  position: absolute;
  z-index: 9;
  left: max(14px, env(safe-area-inset-left));
  bottom: calc(env(safe-area-inset-bottom) + 15px);
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
  transition: opacity .2s ease;
}
.center-tip {
  position: absolute;
  z-index: 11;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 13px 19px;
  border-radius: 999px;
  color: #251034;
  font-weight: 950;
  opacity: 0;
  transition: opacity .18s ease;
  text-align: center;
}
.center-tip.show { opacity: 1; }
.boost {
  position: absolute;
  z-index: 11;
  right: max(14px, env(safe-area-inset-right));
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  width: 62px;
  height: 62px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, #fff, #fff3b8);
  color: #ff9c1f;
  font-size: 27px;
  font-weight: 950;
  box-shadow: 0 12px 30px rgba(95,54,126,.16);
  opacity: .9;
}
.boost:active, .icon-btn:active, button:active { transform: scale(.95); }
.touch-zone {
  position: absolute;
  z-index: 4;
  bottom: calc(env(safe-area-inset-bottom) + 34px);
  color: rgba(57,34,76,.28);
  font-weight: 950;
  font-size: 13px;
  pointer-events: none;
  transition: opacity .2s ease;
}
.touch-zone.left { left: calc(env(safe-area-inset-left) + 22px); }
.touch-zone.right { right: calc(env(safe-area-inset-right) + 88px); }
.s2-shell.active-play .touch-zone { opacity: 0; }
.s2-shell.active-play .room-chip { opacity: .46; }
.menu {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top) + 18px) 18px calc(env(safe-area-inset-bottom) + 18px);
  background:
    radial-gradient(circle at 24% 18%, rgba(255,216,92,.46), transparent 32%),
    radial-gradient(circle at 78% 28%, rgba(68,215,255,.36), transparent 34%),
    rgba(255,244,251,.68);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.menu[hidden] { display: none; }
.menu-card {
  width: min(560px, 100%);
  max-height: min(760px, 92vh);
  overflow: auto;
  border-radius: 30px;
  background: var(--panel-strong);
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 24px;
  border: 2px solid rgba(255,255,255,.8);
}
.kicker { color: #e74e8e; font-size: 13px; font-weight: 950; }
.menu-card h1 {
  margin: 6px 0 9px;
  font-size: clamp(36px, 8vw, 58px);
  line-height: 1;
  color: #251034;
  letter-spacing: 0;
}
.menu-card p { margin: 0 0 18px; color: var(--muted); font-weight: 850; line-height: 1.55; }
.online-option {
  min-height: 46px;
  margin: 0 0 14px;
  padding: 10px 11px 10px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255,255,255,.88), rgba(245,238,251,.72));
  border: 2px solid rgba(255,255,255,.82);
  color: rgba(57,34,76,.76);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 950;
  box-shadow: 0 10px 24px rgba(95,54,126,.11);
  cursor: pointer;
}
.online-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.option-copy {
  display: grid;
  gap: 1px;
  line-height: 1.12;
}
.option-copy strong {
  font-size: 15px;
  color: #251034;
}
.option-copy small {
  font-size: 11px;
  color: rgba(57,34,76,.48);
  font-weight: 900;
}
.switch-ui {
  position: relative;
  flex: 0 0 auto;
  width: 58px;
  height: 32px;
  border-radius: 999px;
  background: rgba(201,188,214,.72);
  box-shadow: inset 0 2px 8px rgba(57,34,76,.16);
  transition: background .18s ease, box-shadow .18s ease;
}
.switch-ui::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 5px 12px rgba(57,34,76,.22);
  transition: transform .18s ease;
}
.online-option input:checked ~ .switch-ui {
  background: linear-gradient(135deg, var(--pink), var(--violet));
  box-shadow: inset 0 1px 5px rgba(255,255,255,.34), 0 7px 18px rgba(255,110,168,.22);
}
.online-option input:checked ~ .switch-ui::after {
  transform: translateX(26px);
}
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.actions button, .room-row button {
  border: 0;
  border-radius: 18px;
  min-height: 52px;
  padding: 12px;
  background: #f5eefb;
  color: var(--ink);
  font-size: 16px;
  font-weight: 950;
}
.actions .primary, .room-row button {
  background: linear-gradient(135deg, var(--pink), var(--violet));
  color: #fff;
}
.room-list { display: grid; gap: 10px; margin-top: 13px; }
.room-row {
  background: #fff;
  border-radius: 18px;
  padding: 12px;
  display: grid;
  gap: 8px;
  box-shadow: 0 8px 20px rgba(95,54,126,.1);
}
.room-top { display: flex; justify-content: space-between; gap: 8px; font-weight: 950; }
.room-meta { color: var(--muted); font-size: 12px; font-weight: 850; }
.empty { text-align: center; color: var(--muted); font-weight: 900; padding: 18px; }
@media (max-width: 760px) {
  .s2-hud { top: calc(env(safe-area-inset-top) + 8px); gap: 8px; }
  .icon-btn { width: 40px; height: 40px; }
  .scorebox { min-width: 112px; min-height: 44px; padding: 5px 10px; }
  .scorebox strong { font-size: 20px; }
  .timer { min-width: 66px; height: 40px; }
  .leaderboard { top: calc(env(safe-area-inset-top) + 60px); }
  .boost { width: 58px; height: 58px; bottom: calc(env(safe-area-inset-bottom) + 13px); }
}
@media (max-width: 480px) {
  .s2-hud { gap: 6px; }
  .scorebox { min-width: 104px; }
  .timer { min-width: 58px; font-size: 14px; }
  .leaderboard { right: max(8px, env(safe-area-inset-right)); width: min(142px, 36vw); }
  .rank-row { grid-template-columns: 19px 1fr auto; font-size: 9px; gap: 4px; }
  .rank-dot { width: 10px; height: 10px; }
}
@media (max-width: 520px) {
  .actions { grid-template-columns: 1fr; }
  .menu-card { padding: 20px; }
}
