*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  color: #e8eaef;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

input,
textarea {
  -webkit-user-select: text;
  user-select: text;
}

body {
  background: #000;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.app-stage {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  background: transparent;
}

#game-container {
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  flex-grow: 0;
  box-sizing: border-box;
  transform-origin: 0 0;
  background: transparent;
}

#game-container canvas {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

#rotate-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  background: radial-gradient(120% 90% at 50% 18%, #2c1149 0%, #1d0b2e 52%, #12061f 100%);
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  text-align: center;
  touch-action: manipulation;
}

#rotate-overlay[hidden] {
  display: none !important;
}

.rotate-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 340px;
  padding: 24px;
}

.rotate-phone {
  width: 64px;
  height: 104px;
  margin-bottom: 10px;
  filter: drop-shadow(0 10px 24px rgba(255, 47, 146, 0.35));
  transform-origin: 50% 50%;
  animation: rotate-phone 3.2s ease-in-out infinite;
}

.rotate-phone svg {
  display: block;
  width: 100%;
  height: 100%;
}

@keyframes rotate-phone {
  0%, 22%   { transform: rotate(0deg);   opacity: 1; }
  48%, 82%  { transform: rotate(-90deg); opacity: 1; }
  92%       { transform: rotate(-90deg); opacity: 0; }
  93%       { transform: rotate(0deg);   opacity: 0; }
  100%      { transform: rotate(0deg);   opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .rotate-phone {
    animation: none;
    transform: rotate(-90deg);
  }
}

.rotate-title {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.rotate-sub {
  font-size: 15px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.72);
}

.rotate-fullscreen {
  margin-top: 12px;
  min-height: 48px;
  min-width: 200px;
  padding: 0 28px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff4fae 0%, #e6007e 100%);
  color: #fff;
  font: 600 16px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  box-shadow: 0 6px 18px rgba(230, 0, 126, 0.38);
  cursor: pointer;
  touch-action: manipulation;
}

.rotate-fullscreen:active {
  transform: translateY(1px);
  filter: brightness(0.94);
}

.rotate-continue {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 0 16px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 15px;
  text-decoration: underline;
  text-underline-offset: 3px;
  touch-action: manipulation;
}

.rotate-continue:active {
  color: #ff4fae;
}

.mobile-chip {
  position: fixed;
  z-index: 900;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  background: rgba(20, 6, 34, 0.55);
  color: #fff;
  font: 700 13px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  opacity: 0.85;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.mobile-chip::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
}

.mobile-chip[hidden] {
  display: none !important;
}

.mobile-chip.is-overlapping {
  opacity: 0.38;
}

.mobile-chip:active {
  opacity: 1;
  background: rgba(230, 0, 126, 0.7);
}

.mobile-chip svg {
  width: 20px;
  height: 20px;
  display: block;
}

#fullscreen-chip .icon-exit {
  display: none;
}

#fullscreen-chip.is-fullscreen .icon-enter {
  display: none;
}

#fullscreen-chip.is-fullscreen .icon-exit {
  display: block;
}

#zoom-reset {
  left: calc(env(safe-area-inset-left, 0px) + 8px);
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  background: rgba(230, 0, 126, 0.75);
}

html.is-standalone .install-offer {
  display: none !important;
}

#install-guide {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  background: rgba(8, 2, 16, 0.72);
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  touch-action: manipulation;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

#install-guide[hidden] {
  display: none !important;
}

.install-sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 0%, #2c1149 0%, #1d0b2e 55%, #12061f 100%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

@media (min-width: 700px) and (min-height: 560px) {
  .install-sheet {
    width: min(980px, calc(100% - 48px));
    height: auto;
    max-height: min(760px, calc(100% - 48px));
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 22px;
  }
}

.install-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 64px 12px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.install-icon {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  filter: drop-shadow(0 6px 14px rgba(255, 47, 146, 0.35));
}

.install-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.install-lead {
  margin-top: 2px;
  font-size: 14px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.74);
}

.install-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
}

.install-close svg {
  width: 20px;
  height: 20px;
}

.install-close:active {
  background: rgba(230, 0, 126, 0.7);
}

.install-close:focus-visible,
.install-tab:focus-visible,
.install-chip:focus-visible,
.install-button:focus-visible,
.install-invite-go:focus-visible,
.install-invite-later:focus-visible,
.rotate-install:focus-visible {
  outline: 2px solid #ff4fae;
  outline-offset: 2px;
}

.install-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 12px 18px 22px;
}

.install-perks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  list-style: none;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.86);
}

.install-perks li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.install-perks li::before {
  content: "";
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ff2f92 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.3l2.6 2.5L12 5.4' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px no-repeat;
}

.install-banner {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  background: rgba(255, 196, 0, 0.14);
  border: 1px solid rgba(255, 196, 0, 0.45);
  color: #ffe9a8;
}

.install-banner[hidden] {
  display: none !important;
}

.install-banner.is-good {
  background: rgba(44, 214, 150, 0.14);
  border-color: rgba(44, 214, 150, 0.5);
  color: #bff5df;
}

.install-tabs,
.install-chips {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  overflow-x: auto;
  scrollbar-width: none;
  touch-action: pan-x pan-y;
}

.install-tabs::-webkit-scrollbar,
.install-chips::-webkit-scrollbar {
  display: none;
}

.install-tab,
.install-chip {
  flex: none;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.86);
  font: 600 14px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}

.install-tab[aria-selected="true"] {
  border-color: transparent;
  background: linear-gradient(180deg, #ff4fae 0%, #e6007e 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(230, 0, 126, 0.35);
}

.install-chips {
  margin-top: 10px;
}

.install-chips[hidden] {
  display: none !important;
}

.install-chip {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
}

.install-chip[aria-selected="true"] {
  border-color: #ff4fae;
  background: rgba(255, 79, 174, 0.16);
  color: #fff;
}

.install-now {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 14px;
  line-height: 1.4;
}

.install-now[hidden] {
  display: none !important;
}

.install-button {
  min-height: 48px;
  min-width: 160px;
  padding: 0 28px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff4fae 0%, #e6007e 100%);
  color: #fff;
  font: 700 16px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  box-shadow: 0 6px 18px rgba(230, 0, 126, 0.38);
  cursor: pointer;
  touch-action: manipulation;
}

.install-button:active {
  transform: translateY(1px);
  filter: brightness(0.94);
}

.install-steps {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  margin-top: 14px;
  list-style: none;
  counter-reset: install-step;
}

.install-step {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.install-step-text {
  display: flex;
  gap: 10px;
  font-size: 15px;
  line-height: 1.4;
}

.install-step-text::before {
  counter-increment: install-step;
  content: counter(install-step);
  flex: none;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #ff2f92;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.install-step-text b {
  color: #ffd1ea;
  font-weight: 700;
}

.install-pic {
  display: block;
  width: 100%;
  margin-top: auto;
  border-radius: 12px;
  overflow: hidden;
}

.install-pic svg {
  display: block;
  width: 100%;
  height: auto;
}

.install-note {
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.66);
}

.install-note + .install-note {
  margin-top: 6px;
}

.install-pic .tap-ring {
  transform-box: fill-box;
  transform-origin: center;
  animation: install-tap 1.6s ease-out infinite;
}

@keyframes install-tap {
  0%   { transform: scale(0.7); opacity: 0.95; }
  70%  { transform: scale(1.25); opacity: 0; }
  100% { transform: scale(1.25); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .install-pic .tap-ring {
    animation: none;
    opacity: 0.9;
  }
}

@media (max-height: 480px) {
  .install-head {
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .install-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
  }
  .install-title {
    font-size: 18px;
  }
  .install-lead {
    font-size: 13px;
  }
  .install-close {
    top: 6px;
  }
  .install-body {
    padding-top: 8px;
  }
  .install-perks {
    font-size: 12px;
    gap: 4px 14px;
  }
  .install-tabs {
    margin-top: 10px;
  }
  .install-tab {
    min-height: 34px;
    font-size: 13px;
  }
  .install-chips {
    margin-top: 8px;
  }
  .install-chip {
    min-height: 30px;
    font-size: 12px;
  }
  .install-steps {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    margin-top: 10px;
    gap: 10px;
  }
  .install-step-text {
    font-size: 14px;
  }
}

#install-invite,
#push-invite {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
  z-index: 950;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(580px, calc(100% - 24px));
  padding: 8px 10px 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  background: rgba(24, 8, 40, 0.92);
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  transform: translateX(-50%);
  touch-action: manipulation;
  animation: install-invite-in 0.35s ease-out;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

#install-invite[hidden],
#push-invite[hidden] {
  display: none !important;
}

@keyframes install-invite-in {
  from { transform: translate(-50%, 24px); opacity: 0; }
  to   { transform: translate(-50%, 0); opacity: 1; }
}

.install-invite-icon {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 10px;
}

.install-invite-text {
  flex: 1;
  min-width: 0;
}

.install-invite-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
}

.install-invite-sub {
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.74);
}

.install-invite-go {
  flex: none;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff4fae 0%, #e6007e 100%);
  color: #fff;
  font: 700 14px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}

.install-invite-later {
  flex: none;
  min-height: 40px;
  padding: 0 8px;
  border: 0;
  background: none;
  color: rgba(255, 255, 255, 0.7);
  font: 500 13px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  touch-action: manipulation;
}

@media (max-height: 480px) {
  #install-invite,
  #push-invite {
    gap: 10px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 6px);
  }
  .install-invite-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
  }
  .install-invite-title {
    font-size: 13px;
  }
  .install-invite-sub {
    font-size: 11px;
  }
  .install-invite-go {
    min-height: 36px;
    padding: 0 14px;
    font-size: 13px;
  }
}

.rotate-install {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font: 600 15px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}

.rotate-install img {
  width: 22px;
  height: 22px;
  border-radius: 5px;
}
