:root {
  --orange: #FF8A3D;
  --orange-deep: #E7651B;
  --gold: #FFD24A;
  --gold-deep: #E89B18;
  --ink: #0B1B2B;
  --navy: #122B44;
  --purple: #A84CFF;
  --blue: #36B7FF;
  --mint: #7FE3C4;
  --paper: #F4F8FC;
  --muted: #9DB3C6;
  --line: rgba(255, 255, 255, 0.14);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
  background: #07131F;
}

body {
  margin: 0;
  min-height: 100%;
  color: #fff;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font-family: inherit;
}

button,
a {
  -webkit-user-select: none;
  user-select: none;
}

.mp-icon {
  font-size: 20px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------------- home */

.home-body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #07131F;
  touch-action: none;
  overscroll-behavior: none;
}

.home-bg {
  position: absolute;
  inset: -52px;
  background: url("images/home/home_bg.jpg") center 38% / cover no-repeat;
  filter: blur(17px) saturate(1.22) brightness(0.92);
  transform: scale(1.16);
  transform-origin: center;
  will-change: transform;
}

.home-tint {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 44% at 50% 4%, rgba(143, 219, 255, 0.34), transparent 62%),
    radial-gradient(80% 38% at 50% 100%, rgba(1, 8, 13, 0.94), transparent 76%),
    linear-gradient(180deg, rgba(6, 27, 45, 0.5) 0%, rgba(6, 22, 35, 0.18) 42%, rgba(3, 12, 19, 0.83) 100%);
}

.home-rays {
  position: absolute;
  inset: -20%;
  opacity: 0.26;
  background: conic-gradient(from 190deg at 50% 12%, transparent 0deg, rgba(255, 236, 186, 0.55) 13deg, transparent 27deg, transparent 48deg, rgba(255, 236, 186, 0.3) 58deg, transparent 70deg, transparent 100deg, rgba(255, 255, 255, 0.22) 112deg, transparent 126deg, transparent 360deg);
  filter: blur(14px);
  mix-blend-mode: screen;
  animation: raysDrift 20s ease-in-out infinite alternate;
  pointer-events: none;
}

.motes {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}

.mote {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: rgba(255, 226, 158, 0.9);
  color: rgba(255, 204, 116, 0.8);
  box-shadow: 0 0 10px 2px currentColor;
  opacity: 0;
  animation: moteFloat var(--d) linear infinite;
  animation-delay: var(--delay);
}

.home-shell {
  position: relative;
  z-index: 4;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px calc(10px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.hud {
  display: flex;
  align-items: center;
  gap: 9px;
  justify-content: space-between;
  flex: 0 0 auto;
  animation: fadeDown 0.55s ease both;
}

.player-card {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  max-width: 226px;
  flex: 1 1 auto;
  padding: 5px 12px 5px 5px;
  border: 1px solid rgba(255, 214, 122, 0.46);
  border-radius: 17px;
  background: linear-gradient(135deg, rgba(11, 36, 58, 0.9), rgba(7, 21, 36, 0.69));
  box-shadow: 0 9px 22px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.13);
  color: #fff;
  text-align: left;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform 0.12s ease, border-color 0.2s ease;
}

.player-card:active {
  transform: scale(0.97);
  border-color: rgba(255, 214, 122, 0.8);
}

.avatar {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  overflow: hidden;
  border: 2px solid rgba(255, 213, 108, 0.9);
  background: #17344A;
  box-shadow: 0 0 0 2px rgba(7, 20, 33, 0.55), 0 4px 12px rgba(0, 0, 0, 0.4);
}

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

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

.p-name {
  max-width: 136px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
}

.p-level {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: #C8D9E8;
  line-height: 1;
}

.p-level b {
  color: var(--gold);
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.xp {
  display: block;
  width: 100%;
  min-width: 66px;
  height: 5px;
  margin-top: 2px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.35);
}

.xp span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #FFB13D, #FFD95A);
  box-shadow: 0 0 8px rgba(255, 190, 67, 0.75);
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}

.best-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 37px;
  padding: 0 11px;
  border-radius: 13px;
  border: 1px solid rgba(255, 216, 130, 0.38);
  background: linear-gradient(180deg, rgba(20, 48, 71, 0.88), rgba(9, 25, 41, 0.82));
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.best-pill .mp-icon {
  font-size: 17px;
  color: var(--gold);
  filter: drop-shadow(0 0 5px rgba(255, 198, 65, 0.5));
}

.best-pill b {
  font-size: 12.5px;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #FFEBAA;
  font-variant-numeric: tabular-nums;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 37px;
  height: 37px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 13px;
  color: #E9F4FC;
  background: linear-gradient(180deg, rgba(27, 58, 83, 0.88), rgba(9, 25, 41, 0.84));
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.11);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  transition: transform 0.12s ease;
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn .mp-icon {
  font-size: 19px;
}

.sound-btn .icon-off {
  display: none;
}

.sound-btn.off .icon-on {
  display: none;
}

.sound-btn.off .icon-off {
  display: inline-block;
}

/* brand ---------------------------------------------------------------- */

.brand {
  display: flex;
  justify-content: center;
  flex: 0 0 auto;
  margin-top: clamp(4px, 1.4vh, 12px);
  pointer-events: none;
  animation: logoIn 0.7s cubic-bezier(0.18, 0.9, 0.25, 1.2) both;
}

.logo {
  display: block;
  width: min(82vw, 340px);
  height: auto;
  transform: rotate(-2deg);
  filter: drop-shadow(0 9px 14px rgba(2, 12, 21, 0.62)) drop-shadow(0 0 22px rgba(255, 128, 48, 0.24));
  animation: logoFloat 4.8s ease-in-out infinite;
}

.tagline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 0;
  color: #FFE4B1;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
  flex: 0 0 auto;
  opacity: 0.95;
  animation: fadeUp 0.7s 0.1s ease both;
}

.tagline span {
  width: 22px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 211, 116, 0.85));
}

.tagline span:last-child {
  background: linear-gradient(90deg, rgba(255, 211, 116, 0.85), transparent);
}

/* modes ---------------------------------------------------------------- */

.modes {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: clamp(7px, 1.25vh, 12px);
  margin-top: clamp(8px, 1.8vh, 16px);
  flex: 0 0 auto;
  animation: fadeUp 0.6s 0.08s ease both;
}

.mode-btn {
  position: relative;
  display: block;
  width: 100%;
  border-radius: 24px;
  overflow: hidden;
  isolation: isolate;
  text-decoration: none;
  cursor: pointer;
  transform: translateZ(0);
  transition: transform 0.13s ease, filter 0.13s ease;
  -webkit-user-drag: none;
}

.mode-btn img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  -webkit-user-drag: none;
  transform: scale(1.012);
}

.mode-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(112deg, transparent 30%, rgba(255, 255, 255, 0.3) 46%, rgba(255, 255, 255, 0.04) 54%, transparent 64%);
  transform: translateX(-135%);
  animation: sheen 7s 1.6s ease-in-out infinite;
  pointer-events: none;
  z-index: 2;
}

.mode-btn:active {
  transform: translateY(1px) scale(0.977);
  filter: brightness(1.08) saturate(1.08);
}

.mode-btn:focus-visible {
  outline: 3px solid #FFE08A;
  outline-offset: 2px;
}

.mode-campaign {
  box-shadow: 0 12px 26px rgba(168, 62, 5, 0.42), 0 0 0 1px rgba(255, 204, 105, 0.45);
}

.mode-premium {
  box-shadow: 0 12px 26px rgba(86, 24, 157, 0.42), 0 0 0 1px rgba(222, 165, 255, 0.4);
}

.mode-endless {
  box-shadow: 0 12px 26px rgba(8, 75, 130, 0.44), 0 0 0 1px rgba(139, 226, 255, 0.4);
}

.mode-premium::after {
  animation-delay: 3.1s;
}

.mode-endless::after {
  animation-delay: 4.6s;
}

.mode-badge {
  position: absolute;
  left: 23px;
  bottom: 9px;
  z-index: 3;
  padding: 2px 9px 3px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(5, 17, 28, 0.56);
  color: rgba(255, 255, 255, 0.95);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.35;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
}

/* hero + tip ----------------------------------------------------------- */

.hero {
  position: absolute;
  left: 50%;
  bottom: max(-14px, calc(env(safe-area-inset-bottom, 0px) - 14px));
  z-index: 2;
  width: min(92vw, 390px);
  transform: translateX(-50%);
  pointer-events: none;
  filter: drop-shadow(0 16px 28px rgba(0, 0, 0, 0.5));
  -webkit-mask-image: radial-gradient(ellipse 82% 84% at 50% 54%, #000 62%, rgba(0, 0, 0, 0.72) 82%, transparent 100%);
  mask-image: radial-gradient(ellipse 82% 84% at 50% 54%, #000 62%, rgba(0, 0, 0, 0.72) 82%, transparent 100%);
  animation: heroRise 0.9s 0.12s cubic-bezier(0.16, 0.8, 0.24, 1) both;
}

.hero img {
  display: block;
  width: 100%;
  height: auto;
}

.home-tip {
  position: relative;
  z-index: 6;
  display: flex;
  align-items: center;
  align-self: center;
  gap: 6px;
  margin-top: auto;
  margin-bottom: 2px;
  padding: 7px 14px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(4, 16, 27, 0.58);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: #D7E8F4;
  font-size: 11px;
  line-height: 1.3;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex: 0 0 auto;
  animation: fadeUp 0.7s 0.2s ease both;
}

.home-tip .mp-icon {
  font-size: 14px;
  color: #FFD15E;
}

/* nickname sheet ------------------------------------------------------- */

.sheet-mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(2, 9, 16, 0.66);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: maskIn 0.2s ease both;
}

.sheet-mask[hidden] {
  display: none;
}

.sheet {
  width: 100%;
  max-width: 480px;
  padding: 10px 20px calc(18px + env(safe-area-inset-bottom, 0px));
  border-radius: 24px 24px 0 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom: 0;
  background: linear-gradient(180deg, #193A56 0%, #0B2033 100%);
  box-shadow: 0 -24px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.13);
  animation: sheetUp 0.3s cubic-bezier(0.16, 0.86, 0.26, 1) both;
}

.sheet-handle {
  display: block;
  width: 38px;
  height: 4px;
  margin: 0 auto 16px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.25);
}

.sheet h2 {
  margin: 0 0 6px;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.01em;
}

.sheet p {
  margin: 0 0 16px;
  color: #A9C0D3;
  font-size: 12.5px;
  line-height: 1.5;
}

.sheet input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1.5px solid rgba(255, 255, 255, 0.17);
  outline: none;
  background: rgba(3, 13, 22, 0.45);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sheet input::placeholder {
  color: #7894A9;
  font-weight: 500;
}

.sheet input:focus {
  border-color: rgba(255, 174, 88, 0.85);
  box-shadow: 0 0 0 4px rgba(255, 138, 61, 0.16);
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.sheet-actions button {
  height: 46px;
  border-radius: 14px;
  border: 0;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.sheet-actions button:active {
  transform: scale(0.97);
  filter: brightness(1.06);
}

.btn-ghost {
  flex: 0 0 38%;
  color: #D7E5F1;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
}

.btn-primary {
  flex: 1;
  color: #352008;
  background: linear-gradient(180deg, #FFDF79 0%, #FFA53D 52%, #F47A22 100%);
  box-shadow: 0 8px 20px rgba(244, 122, 34, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* animations ----------------------------------------------------------- */

@keyframes logoFloat {
  0%, 100% { transform: rotate(-2deg) translateY(0); }
  50% { transform: rotate(-1.2deg) translateY(-5px); }
}

@keyframes logoIn {
  from { opacity: 0; transform: scale(0.82) translateY(-12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes heroRise {
  from { opacity: 0; transform: translateX(-50%) translateY(28px) scale(0.97); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes maskIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes sheen {
  0%, 62% { transform: translateX(-135%); }
  76%, 100% { transform: translateX(135%); }
}

@keyframes moteFloat {
  0% { opacity: 0; transform: translate3d(0, 18px, 0) scale(0.7); }
  18% { opacity: 0.9; }
  75% { opacity: 0.5; }
  100% { opacity: 0; transform: translate3d(18px, -110px, 0) scale(1.1); }
}

@keyframes raysDrift {
  from { transform: translateX(-3%) rotate(-1.5deg); }
  to { transform: translateX(3%) rotate(1.5deg); }
}

/* responsive ----------------------------------------------------------- */

@media (max-width: 360px) {
  .p-name { max-width: 104px; font-size: 12.5px; }
  .best-pill { padding: 0 8px; }
  .home-shell { padding-left: 13px; padding-right: 13px; }
  .mode-badge { left: 18px; font-size: 9px; }
}

@media (max-height: 700px) {
  .tagline { display: none; }
  .logo { width: min(68vw, 250px); }
  .modes { margin-top: 6px; gap: 7px; }
  .home-tip { font-size: 10px; padding: 6px 11px; }
  .hero { width: min(82vw, 320px); bottom: -22px; }
}

@media (max-height: 610px) {
  .hud { transform: scale(0.94); transform-origin: top center; }
  .logo { width: min(58vw, 210px); }
  .mode-btn { border-radius: 18px; }
  .mode-badge { display: none; }
  .home-tip { display: none; }
  .hero { width: min(72vw, 270px); }
}

@media (min-height: 900px) {
  .logo { width: min(84vw, 366px); }
  .modes { gap: 13px; margin-top: 20px; }
  .hero { width: min(96vw, 430px); }
}

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