:root {
  color-scheme: dark;
  font-family: "Segoe UI", Roboto, sans-serif;
  --text-primary: #f6f6fb;
  --text-secondary: #b8b7cb;
  --accent-purple: #5c3bff;
  --accent-purple-hover: #7149ff;
  --accent-purple-active: #4b30e6;
  --accent-pink: #ff78d9;
  --overlay-bg: rgba(20, 20, 32, 0.82);
  --button-shadow: 0 18px 28px -14px rgba(92, 59, 255, 0.55);
  --button-shadow-active: 0 20px 32px -12px rgba(92, 59, 255, 0.65);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100dvh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(140% 140% at 15% -10%, rgba(124, 87, 255, 0.35) 0%, rgba(11, 11, 20, 0) 55%),
    radial-gradient(120% 120% at 85% -20%, rgba(255, 120, 217, 0.22) 0%, rgba(8, 8, 18, 0) 45%),
    #080812;
  color: var(--text-primary);
  overflow: hidden;
  transition: background 0.4s ease;
}

body[data-active-category="pokemon"] {
  background: linear-gradient(330deg, #000000 0%, #1a1303 45%, #b8960a 100%);
}

.app-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
  overflow: hidden;
}

.app-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(0.35rem, 1.5vw, 0.75rem);
  padding: clamp(1rem, 4vw, 2rem) clamp(2rem, 6vw, 3.5rem) 0;
  text-align: center;
}

.app-logo {
  width: clamp(132px, 20vw, 180px);
  height: auto;
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.35));
}

.app-tagline {
  margin: 0;
  font-size: clamp(0.95rem, 1.7vw, 1.15rem);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  letter-spacing: 0.02em;
}

.app-tagline__accent {
  color: var(--accent-pink);
  font-weight: 700;
}

.app-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(0.6rem, 2.8vh, 1.8rem);
  padding: clamp(0.75rem, 2.5vh, 1.5rem) clamp(1.5rem, 6vw, 3.5rem) clamp(0.85rem, 3vh, 1.75rem);
  width: 100%;
}

model-viewer {
  width: min(620px, 90vw);
  height: clamp(200px, 48dvh, 460px);
  border-radius: 22px;
  overflow: hidden;
  background: radial-gradient(circle at 20% 20%, rgba(69, 41, 172, 0.85), #151424);
  box-shadow: 0 40px 70px -35px rgba(0, 0, 0, 0.85);
  flex-shrink: 0;
  transition: background 0.3s ease;
}

body[data-active-category="pokemon"] model-viewer {
  background: linear-gradient(150deg, #000000 0%, #1a1303 45%, #b8960a 100%);
  box-shadow: 0 40px 70px -35px rgba(0, 0, 0, 0.85);
}

.ar-button {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 2rem;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--accent-purple), #8e4bff);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  gap: 0.5rem;
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease, box-shadow 150ms ease;
  box-shadow: 0 18px 30px -16px rgba(92, 59, 255, 0.65);
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0));
}

.ar-button:hover,
.ar-button:focus-visible {
  background: linear-gradient(135deg, var(--accent-purple-hover), #a45aff);
  transform: translateX(-50%) scale(1.03);
  box-shadow: 0 22px 36px -14px rgba(124, 87, 255, 0.7);
}

.ar-button:active {
  background: linear-gradient(135deg, var(--accent-purple-active), #7c40f2);
  transform: translateX(-50%) scale(0.98);
}

.model-switcher {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.6rem, 2vh, 1rem);
  width: min(520px, 90vw);
  flex-shrink: 0;
}

.model-switcher__label {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
  text-align: center;
}

.model-switcher__buttons {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: clamp(0.65rem, 4vw, 1rem);
  width: 100%;
  max-width: 520px;
  flex-wrap: nowrap;
  margin-top: clamp(0.75rem, 3vh, 1.6rem);
}

.category-switcher {
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(20, 20, 32, 0.4);
  border-radius: 999px;
  padding: 0.35rem;
  margin-bottom: 0.5rem;
  gap: 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.category-button {
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.category-button:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.category-button[data-category="nightlife"].is-active {
  background: linear-gradient(135deg, var(--accent-purple), #7d4dff);
  color: #fff;
  box-shadow: 0 4px 12px rgba(92, 59, 255, 0.4);
}

.category-button[data-category="pokemon"].is-active {
  background: #ffcc00;
  color: #111;
  box-shadow: 0 4px 12px rgba(255, 204, 0, 0.3);
}

.model-switcher__button {
  border: none;
  background: rgba(20, 20, 32, 0.6);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 0.6rem 1.8rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 150ms ease;
  flex: 1 1 30%;
  min-width: 0;
  max-width: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  text-align: center;
}

.model-switcher__button:hover,
.model-switcher__button:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transform: translateY(-2px);
}

.model-switcher__button:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.3);
  outline-offset: 3px;
}

body[data-active-category="nightlife"] .model-switcher__button.is-active,
body[data-active-category="nightlife"] .ar-overlay__button.is-active {
  background: linear-gradient(135deg, var(--accent-purple), #6d42ff);
  color: #fff;
  box-shadow: 0 4px 20px rgba(92, 59, 255, 0.6);
  transform: translateY(-2px);
}

body[data-active-category="pokemon"] .model-switcher__button.is-active,
body[data-active-category="pokemon"] .ar-overlay__button.is-active {
  background: #ffcc00;
  color: #111;
  box-shadow: 0 4px 20px rgba(255, 204, 0, 0.4);
  transform: translateY(-2px);
}

.ar-overlay {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-radius: 18px;
  background: var(--overlay-bg);
  color: var(--text-primary);
  max-width: min(92vw, 360px);
  text-align: center;
  box-shadow: 0 25px 50px -18px rgba(7, 7, 14, 0.85);
  margin-bottom: env(safe-area-inset-bottom, 0);
}

.ar-overlay__label {
  font-weight: 700;
  font-size: 1.05rem;
}

.ar-overlay__buttons {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 0.75rem 0.9rem;
  flex-wrap: nowrap;
  width: 100%;
  margin-top: clamp(0.65rem, 2.5vh, 1.25rem);
}

.ar-overlay__button {
  border: none;
  background: rgba(20, 20, 32, 0.6);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 0.5rem 1.6rem;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 150ms ease;
  flex: 1 1 30%;
  min-width: 0;
  max-width: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  text-align: center;
}

.ar-overlay__button:hover,
.ar-overlay__button:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transform: translateY(-2px);
}

.ar-overlay__button:focus-visible {
  outline: 3px solid rgba(255, 120, 217, 0.55);
  outline-offset: 3px;
}


.app-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(1rem, 3vw, 2rem);
  padding: clamp(0.85rem, 3vh, 1.6rem) clamp(1.5rem, 6vw, 3rem);
  flex-shrink: 0;
  width: 100%;
  color: rgba(243, 244, 255, 0.85);
  font-weight: 600;
}

.footer-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.4rem;
  color: rgba(243, 244, 255, 0.85);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition: color 150ms ease, transform 150ms ease;
  position: relative;
}

.footer-button::after {
  content: "•";
  margin-left: clamp(0.9rem, 2vw, 1.2rem);
  color: rgba(243, 244, 255, 0.4);
}

.footer-button:focus-visible {
  outline: none;
}

.footer-button:active {
  transform: translateY(0);
}

.footer-button:hover,
.footer-button:focus-visible {
  color: var(--accent-pink);
  transform: translateY(-1px);
}

.footer-button:last-child::after {
  content: "";
  margin: 0;
}

@media (max-width: 760px) {
  .app-header {
    padding: clamp(0.85rem, 6vw, 1.5rem) clamp(1.5rem, 7vw, 2.5rem) 0;
  }

  .app-logo {
    width: clamp(126px, 36vw, 170px);
  }

  .app-main {
    gap: clamp(0.55rem, 3.5vw, 1.25rem);
    padding: clamp(0.6rem, 4vw, 1.1rem) clamp(1.25rem, 7vw, 2.5rem) clamp(0.75rem, 5vw, 1.5rem);
  }

  model-viewer {
    height: clamp(190px, 44dvh, 420px);
    border-radius: 18px;
  }

  .model-switcher__buttons {
    gap: clamp(0.55rem, 3.5vw, 0.8rem) clamp(0.55rem, 4vw, 0.85rem);
  }
}

@media (max-height: 740px) {
  .app-main {
    justify-content: flex-start;
    padding-top: clamp(0.6rem, 5vh, 1.25rem);
    padding-bottom: clamp(0.6rem, 4vh, 1.25rem);
  }

  model-viewer {
    height: clamp(180px, 42dvh, 400px);
  }

  .model-switcher {
    gap: clamp(0.5rem, 2.5vh, 0.8rem);
  }
}

@media (max-height: 620px) {
  .app-main {
    gap: clamp(0.4rem, 2.2vh, 0.9rem);
  }

  model-viewer {
    height: clamp(170px, 38dvh, 360px);
  }

  .ar-button {
    padding: 0.65rem 1.8rem;
    font-size: 0.95rem;
  }
}

@media (max-width: 540px) {
  .ar-button {
    padding: 0.65rem 1.75rem;
    font-size: 0.95rem;
  }

  .ar-overlay {
    max-width: min(94vw, 320px);
    padding: 0.85rem 1.1rem;
  }

  .model-switcher__buttons,
  .ar-overlay__buttons {
    flex-wrap: nowrap;
    gap: clamp(0.35rem, 2vw, 0.75rem);
    width: 100%;
  }

  .model-switcher__button,
  .ar-overlay__button {
    flex: 1 1 30%;
    min-width: 0;
    max-width: none;
    padding: 0.5rem 0.2rem;
    font-size: 0.8rem;
  }

  .category-button {
    font-size: 0.75rem;
    padding: 0.5rem 0.75rem;
    gap: 0.35rem;
  }
}

@media (max-width: 400px) {
  body {
    font-size: 0.95rem;
  }

  .app-header {
    padding: 0.75rem 1rem 0;
  }

  .app-main {
    padding: 0.85rem 0.9rem 1.25rem;
    gap: 0.65rem;
  }

  model-viewer {
    width: 92vw;
    height: clamp(180px, 52dvh, 340px);
  }

  .model-switcher__label {
    font-size: 0.95rem;
  }

  .ar-support {
    font-size: 0.9rem;
  }

  .app-footer {
    padding: 0.65rem 1rem 1rem;
  }
}