:root {
  color-scheme: light;
  --ink: #17251f;
  --muted: #627169;
  --cream: #f7f5ed;
  --glass: rgba(248, 250, 246, 0.76);
  --glass-strong: rgba(252, 253, 250, 0.92);
  --line: rgba(255, 255, 255, 0.72);
  --shadow: 0 24px 70px rgba(24, 48, 36, 0.2), 0 3px 12px rgba(24, 48, 36, 0.1);
  font-family: Inter, ui-rounded, "SF Pro Rounded", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #c7dccd;
  color: var(--ink);
}

button,
a {
  font: inherit;
}

button {
  color: inherit;
}

.village-shell,
.village-stage,
.game-host {
  width: 100vw;
  height: 100dvh;
}

.village-stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: linear-gradient(160deg, #adcdb7, #d8e5d5);
}

.game-host canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  outline: none;
}

.glass {
  border: 1px solid var(--line);
  background: var(--glass);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(24px) saturate(1.18);
  -webkit-backdrop-filter: blur(24px) saturate(1.18);
}

.village-brand {
  position: absolute;
  z-index: 20;
  top: max(20px, env(safe-area-inset-top));
  left: max(22px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 13px 10px 10px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 18px;
  background: rgba(250, 250, 245, 0.72);
  box-shadow: 0 10px 34px rgba(35, 65, 49, 0.13);
  backdrop-filter: blur(18px);
  transition: left 260ms ease, right 260ms ease;
}

.village-stage.sidebar-left .village-brand {
  right: max(22px, env(safe-area-inset-right));
  left: auto;
}

.brand-orb {
  position: relative;
  width: 38px;
  height: 38px;
  overflow: hidden;
  border-radius: 13px;
  background: linear-gradient(145deg, #264c3c, #6f9f75);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.brand-orb i {
  position: absolute;
  bottom: -5px;
  width: 23px;
  height: 23px;
  border-radius: 50% 50% 45% 45%;
  background: #d5e7cc;
}

.brand-orb i:nth-child(1) { left: -6px; }
.brand-orb i:nth-child(2) { left: 9px; bottom: -1px; background: #9fc197; }
.brand-orb i:nth-child(3) { right: -8px; background: #c8d9aa; }

.village-brand strong,
.village-brand small {
  display: block;
}

.village-brand strong {
  font-size: 14px;
  letter-spacing: -0.01em;
}

.village-brand small {
  margin-top: 1px;
  color: #68766f;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.promise {
  position: absolute;
  z-index: 18;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: max(24px, env(safe-area-inset-left));
  max-width: min(520px, calc(100vw - 450px));
  pointer-events: none;
  text-shadow: 0 1px 14px rgba(246, 251, 246, 0.85);
  transition: left 260ms ease, right 260ms ease;
}

.village-stage.sidebar-left .promise {
  right: max(24px, env(safe-area-inset-right));
  left: auto;
}

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

.promise span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(247, 248, 242, 0.72);
  box-shadow: 0 4px 18px rgba(31, 58, 43, 0.1);
  color: #526159;
  font-size: 12px;
  font-weight: 620;
}

kbd {
  padding: 2px 6px;
  border: 1px solid rgba(40, 63, 51, 0.16);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.72);
  color: #25382f;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.04em;
}

.nearby-panel {
  position: absolute;
  z-index: 25;
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  width: min(410px, calc(100vw - 36px));
  max-height: calc(100dvh - 36px);
  overflow: auto;
  padding: 18px;
  border-radius: 28px;
  background: rgba(248, 250, 246, 0.56);
  backdrop-filter: blur(14px) saturate(1.06);
  -webkit-backdrop-filter: blur(14px) saturate(1.06);
  scrollbar-width: none;
  transition: transform 320ms cubic-bezier(.2, .8, .2, 1);
}

.nearby-panel.is-left {
  transform: translateX(calc(-100vw + 446px));
}

.nearby-panel::-webkit-scrollbar {
  display: none;
}

.nearby-heading,
.nearby-heading > div {
  display: flex;
  align-items: center;
}

.nearby-heading {
  justify-content: space-between;
  gap: 16px;
  color: #617068;
  font-size: 11px;
  font-weight: 650;
}

.nearby-heading > div {
  gap: 7px;
}

.nearby-heading p {
  margin: 0;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nearby-heading > span {
  white-space: nowrap;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3ca46b;
  box-shadow: 0 0 0 4px rgba(60, 164, 107, 0.13);
  animation: live-pulse 2.4s ease-in-out infinite;
}

.ghost-dot {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid rgba(90, 111, 143, 0.18);
  border-radius: 50%;
  background: rgba(217, 228, 247, 0.7);
  color: #667ca2;
  font-size: 15px;
  box-shadow: 0 0 0 4px rgba(123, 147, 187, 0.07);
}

.nearby-heading p b {
  color: #41566f;
}

@keyframes live-pulse {
  50% { box-shadow: 0 0 0 7px rgba(60, 164, 107, 0.03); }
}

.nearby-panel h1 {
  margin: 9px 0 11px;
  font-size: 21px;
  letter-spacing: -0.035em;
}

.nearby-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 14px;
}

.app-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  min-width: 0;
  min-height: 78px;
  padding: 7px 4px 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 19px;
  background: rgba(255, 255, 255, 0.48);
  text-align: center;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.app-card::after {
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  border-radius: inherit;
  content: "";
  pointer-events: none;
  transition: border-color 180ms ease;
}

.app-card:hover,
.app-card:focus-visible,
.app-card.is-nearest,
.app-card.is-store-focused {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.95);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 25px rgba(35, 61, 48, 0.12);
  outline: none;
}

.app-card.is-nearest::after,
.app-card.is-store-focused::after {
  border-color: var(--app-color);
}

.app-icon,
.detail-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: linear-gradient(145deg, var(--app-accent), var(--app-color));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), 0 7px 15px color-mix(in srgb, var(--app-color) 28%, transparent);
  color: #fff;
  font-size: 24px;
  font-weight: 720;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.16);
}

.app-icon {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  font-size: 20px;
}

.app-card-copy {
  display: block;
  width: 100%;
  min-width: 0;
}

.app-card-title,
.app-card-subline,
.app-card-meta {
  display: flex;
  align-items: center;
}

.app-card-title {
  display: block;
}

.app-card-title strong {
  display: block;
  overflow: hidden;
  font-size: 10px;
  letter-spacing: -0.015em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.discovery-label {
  display: none;
}

.app-card-copy > p {
  display: none;
}

.app-card-subline {
  display: none;
}

.app-card-subline span + span::before {
  margin-right: 8px;
  color: #a1aca6;
  content: "·";
}

.app-card-meta {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 19px;
  padding: 2px 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.86);
  color: #53635b;
  font-size: 8px;
  text-align: center;
}

.visitor-mark {
  display: none;
}

.visitor-mark::before,
.visitor-mark::after {
  position: absolute;
  bottom: 0;
  width: 7px;
  height: 7px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: var(--app-color);
  content: "";
}

.visitor-mark::before { left: 1px; }
.visitor-mark::after { right: 1px; opacity: 0.7; }

.app-card-meta b {
  font-size: 8px;
}

.sidebar-detail {
  padding-top: 14px;
  border-top: 1px solid rgba(42, 64, 53, 0.1);
}

.sidebar-app-hero {
  display: flex;
  align-items: center;
  gap: 13px;
}

.sidebar-app-hero .detail-icon {
  width: 64px;
  height: 64px;
  border-radius: 19px;
  font-size: 30px;
}

.sidebar-app-hero > div:last-child {
  min-width: 0;
}

.sidebar-app-hero h2 {
  margin: 0;
  overflow: hidden;
  font-size: 25px;
  letter-spacing: -0.045em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-app-hero p:last-child {
  margin: 3px 0 0;
  overflow: hidden;
  color: #6b7871;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-footnote {
  margin: 11px 0 0;
  color: #7b8881;
  font-size: 10px;
  text-align: center;
}

.curiosity-toast {
  position: absolute;
  z-index: 24;
  top: 22px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 340px;
  padding: 12px 16px 12px 12px;
  border-radius: 19px;
  transform: translate(-50%, -18px);
  opacity: 0;
  transition: transform 420ms cubic-bezier(.2,.8,.2,1), opacity 300ms ease;
}

.curiosity-toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.toast-spark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: #355f4e;
  color: #d9f2ca;
}

.curiosity-toast strong,
.curiosity-toast small {
  display: block;
}

.curiosity-toast strong { font-size: 12px; }
.curiosity-toast small { margin-top: 2px; color: #66746d; font-size: 10px; }

.game-error {
  position: absolute;
  z-index: 50;
  inset: 50% auto auto 50%;
  width: min(420px, calc(100vw - 40px));
  padding: 26px;
  border-radius: 24px;
  transform: translate(-50%, -50%);
  text-align: center;
}

.game-error strong { font-size: 20px; }
.game-error p { margin-bottom: 0; color: var(--muted); }

.app-dialog {
  width: min(700px, calc(100vw - 32px));
  max-height: min(790px, calc(100dvh - 32px));
  margin: auto;
  padding: 26px;
  overflow: auto;
  border-radius: 32px;
  color: var(--ink);
}

.app-dialog::backdrop {
  background: rgba(29, 49, 40, 0.28);
  backdrop-filter: blur(8px);
}

.dialog-close {
  position: absolute;
  top: 18px;
  right: 18px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(42, 64, 53, 0.1);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.66);
  color: #526159;
  font-size: 22px;
  cursor: pointer;
}

.detail-hero {
  display: flex;
  align-items: center;
  gap: 17px;
  padding-right: 44px;
}

.detail-icon {
  width: 76px;
  height: 76px;
  border-radius: 22px;
  font-size: 35px;
}

.detail-label {
  margin: 0 0 5px;
  color: var(--app-color);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.detail-hero h2 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -0.045em;
}

.detail-hero p:last-child {
  margin: 4px 0 0;
  color: #6b7871;
  font-size: 13px;
}

.detail-description {
  margin: 22px 0;
  color: #4e5f56;
  font-size: 16px;
  line-height: 1.5;
}

.detail-screens {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.screen-preview {
  position: relative;
  min-height: 180px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 21px;
  background: linear-gradient(155deg, color-mix(in srgb, var(--app-accent) 82%, white), color-mix(in srgb, var(--app-color) 48%, white));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.screen-preview::before,
.screen-preview::after {
  position: absolute;
  left: 15%;
  right: 15%;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: 0 10px 25px rgba(52, 69, 60, 0.08);
  content: "";
}

.screen-preview::before { top: 17%; height: 29%; }
.screen-preview::after { top: 54%; height: 28%; }
.screen-preview:nth-child(2)::before { height: 54%; }
.screen-preview:nth-child(2)::after { top: 76%; height: 8%; }
.screen-preview:nth-child(3)::before { top: 23%; border-radius: 50%; aspect-ratio: 1; height: auto; }
.screen-preview:nth-child(3)::after { top: 70%; height: 10%; }

.detail-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 18px;
  padding: 14px 0;
  border-top: 1px solid rgba(40, 63, 51, 0.1);
  border-bottom: 1px solid rgba(40, 63, 51, 0.1);
}

.detail-meta span {
  text-align: center;
}

.detail-meta span + span {
  border-left: 1px solid rgba(40, 63, 51, 0.1);
}

.detail-meta strong,
.detail-meta small {
  display: block;
}

.detail-meta strong { font-size: 16px; }
.detail-meta small { margin-top: 3px; color: #7c8982; font-size: 9px; text-transform: uppercase; }

.detail-reason {
  margin: 17px 0;
  padding: 12px 14px;
  border-radius: 15px;
  background: color-mix(in srgb, var(--app-color) 9%, white);
  color: #53625a;
  font-size: 12px;
}

.detail-reason::before {
  margin-right: 7px;
  color: var(--app-color);
  content: "✦";
}

.store-button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 10px 15px;
  border-radius: 18px;
  background: #17251f;
  box-shadow: 0 13px 28px rgba(20, 38, 29, 0.2);
  color: #fff;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.store-button:hover,
.store-button:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 17px 34px rgba(20, 38, 29, 0.25);
  outline: none;
}

.store-button span,
.store-button strong {
  display: block;
}

.store-button span { font-size: 9px; opacity: 0.7; }
.store-button strong { font-size: 16px; }
.store-button b { margin-left: auto; font-size: 21px; }

.sidebar-detail .detail-label {
  margin-bottom: 3px;
  font-size: 9px;
}

.sidebar-detail .detail-description {
  display: -webkit-box;
  margin: 12px 0;
  overflow: hidden;
  color: #4e5f56;
  font-size: 12px;
  line-height: 1.42;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.sidebar-detail .detail-screens {
  gap: 7px;
}

.sidebar-detail .screen-preview {
  min-height: 106px;
  border-radius: 15px;
}

.sidebar-detail .detail-meta {
  margin-top: 11px;
  padding: 9px 0;
}

.sidebar-detail .detail-meta strong {
  font-size: 13px;
}

.sidebar-detail .detail-meta small {
  font-size: 8px;
}

.sidebar-detail .detail-reason {
  margin: 10px 0;
  padding: 9px 11px;
  font-size: 10px;
  line-height: 1.35;
}

.sidebar-detail .store-button {
  min-height: 52px;
  border-radius: 16px;
}

.mobile-nudge {
  display: none;
}

@media (max-width: 860px) {
  .nearby-panel {
    top: auto;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 12px;
    right: 12px;
    width: auto;
    max-height: 62dvh;
    padding: 15px;
    border-radius: 23px;
  }

  .nearby-panel.is-left {
    transform: none;
  }

  .village-stage.sidebar-left .village-brand {
    right: auto;
    left: max(22px, env(safe-area-inset-left));
  }

  .nearby-panel h1 {
    margin: 7px 0 11px;
    font-size: 19px;
  }

  .nearby-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .app-card {
    min-height: 68px;
    padding: 6px 3px;
    border-radius: 16px;
  }

  .app-icon { width: 42px; height: 42px; border-radius: 13px; font-size: 20px; }
  .app-card-meta,
  .app-card-copy > p,
  .panel-footnote { display: none; }
  .app-card-title strong { font-size: 9px; }
  .app-card-subline { font-size: 9px; }
  .discovery-label { display: none; }

  .promise {
    display: none;
  }

  .curiosity-toast {
    top: 86px;
    width: calc(100vw - 28px);
  }
}

@media (max-width: 560px) {
  .village-brand { top: 12px; left: 12px; }
  .brand-orb { width: 33px; height: 33px; }
  .promise { top: 72px; left: 15px; }
  .promise span { display: none; }
  .nearby-list { gap: 7px; }
  .nearby-heading > span { display: none; }
  .detail-screens { grid-template-columns: repeat(3, 150px); overflow-x: auto; }
  .app-dialog { padding: 21px; border-radius: 25px; }
  .detail-icon { width: 64px; height: 64px; border-radius: 19px; }
  .detail-hero h2 { font-size: 25px; }
  .detail-description { font-size: 14px; }
}

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