:root {
  --sky: #D5F3ED;
  --ink: #171717;
  --cream: #fff7d8;
  --orange: #ff9f1c;
  --orange-dark: #d96c00;
  --mint: #5ee6b9;
  --blue: #73c8ff;
  --pink: #ff7ab8;
  --shadow: 0 8px 0 #171717;
}

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

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--sky);
  color: var(--ink);
  font-family: "Trebuchet MS", "Microsoft YaHei", "PingFang SC", sans-serif;
}

body {
  image-rendering: pixelated;
  touch-action: none;
}

button,
input,
select {
  font: inherit;
}

#app {
  position: fixed;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(213, 243, 237, 0) 0 56%, rgba(213, 243, 237, .16) 72%, rgba(213, 243, 237, .52) 100%),
    url("/assets/ui/home-bottom-pixel-landscape.png?v=20260710-bottom-bg") bottom center / 100% auto no-repeat,
    radial-gradient(circle at 50% 45%, rgba(255,255,255,.72) 0 16%, rgba(255,255,255,0) 42%),
    radial-gradient(circle at 52% 54%, rgba(71, 219, 255, .22) 0 18%, rgba(71,219,255,0) 47%),
    linear-gradient(rgba(255,255,255,.22) 2px, transparent 2px),
    linear-gradient(90deg, rgba(255,255,255,.22) 2px, transparent 2px),
    radial-gradient(circle at 18% 20%, rgba(255,255,255,.75), transparent 18%),
    radial-gradient(circle at 82% 12%, rgba(255,218,99,.38), transparent 16%),
    linear-gradient(180deg, #bff7f2 0%, #effde8 100%);
  background-size: 100% 100%, 100% auto, 100% 100%, 100% 100%, 28px 28px, 28px 28px, 100% 100%, 100% 100%, 100% 100%;
}

@media (max-width: 720px) {
  #app {
    background:
      radial-gradient(circle at 50% 44%, rgba(217, 255, 240, .28) 0 20%, rgba(174, 233, 221, .12) 38%, rgba(174, 233, 221, 0) 56%),
      linear-gradient(180deg, rgba(213, 243, 237, .1) 0%, rgba(213, 243, 237, 0) 48%, rgba(213, 243, 237, .12) 100%),
      url("/assets/ui/mobile-travel-atlas-bg.png?v=20260710-travel-atlas") center center / cover no-repeat;
  }

  .bottom-dock {
    left: 12px;
    right: 12px;
    bottom: max(14px, env(safe-area-inset-bottom));
    height: clamp(77px, 22vw, 101px);
  }

  .primary-button {
    width: clamp(70px, 20vw, 90px);
    height: clamp(70px, 20vw, 90px);
    bottom: 0;
    font-size: clamp(10px, 3vw, 12px);
    box-shadow: 0 6px 0 var(--ink), inset 0 5px 0 rgba(255,255,255,.36), 0 11px 21px rgba(255, 159, 28, .28);
  }

  .primary-button img {
    width: 68%;
    height: 68%;
  }

  .side-pill {
    bottom: clamp(19px, 5.6vw, 26px);
    width: calc((100vw - clamp(70px, 20vw, 90px) - 44px) / 2);
    max-width: 107px;
    min-width: 70px;
    height: clamp(38px, 11vw, 48px);
    gap: clamp(4px, 1.3vw, 7px);
    padding: 4px 6px;
    font-size: clamp(9px, 2.6vw, 11px);
  }

  .side-pill.left {
    left: 0;
  }

  .side-pill.right {
    right: 0;
  }

  .side-pill img {
    width: clamp(21px, 6.4vw, 27px);
    height: clamp(21px, 6.4vw, 27px);
  }
}

#earthCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

#earthCanvas:active {
  cursor: grabbing;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
}

.top-ribbon {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(88vw, 420px);
  height: 58px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #fffbe6 0%, var(--cream) 100%);
  border: 2px solid var(--ink);
  box-shadow: 0 6px 0 var(--ink), 0 14px 28px rgba(0, 112, 128, .16);
  clip-path: polygon(0 0, 100% 0, 94% 50%, 100% 100%, 0 100%, 6% 50%);
}

.top-ribbon::before {
  content: "";
  position: absolute;
  inset: 7px 38px;
  border: 2px dashed rgba(23,23,23,.35);
  pointer-events: none;
}

.ribbon-text {
  position: relative;
  z-index: 1;
  font-size: clamp(15px, 4vw, 20px);
  font-weight: 900;
  text-shadow: 2px 2px 0 #ffd666;
  white-space: nowrap;
}

.bottom-dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(18px, env(safe-area-inset-bottom));
  height: 126px;
  pointer-events: none;
}

.primary-button {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 118px;
  height: 118px;
  transform: translateX(-50%);
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: linear-gradient(180deg, #ffbf42 0%, var(--orange) 64%, var(--orange-dark) 100%);
  box-shadow: 0 9px 0 var(--ink), inset 0 7px 0 rgba(255,255,255,.36), 0 18px 34px rgba(255, 159, 28, .32);
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.05;
  pointer-events: auto;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 10px;
  user-select: none;
}

.primary-button img {
  position: absolute;
  width: 82px;
  height: 82px;
  object-fit: contain;
  opacity: .35;
}

.primary-button span {
  position: relative;
  z-index: 1;
  text-shadow: 2px 2px 0 #fff0a8;
}

.primary-button:active {
  transform: translateX(-50%) translateY(6px);
  box-shadow: 0 3px 0 var(--ink), inset 0 7px 0 rgba(255,255,255,.32);
}

.side-pill {
  position: absolute;
  bottom: 28px;
  width: min(32vw, 142px);
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: #ffffff;
  box-shadow: 0 3px 0 var(--ink);
  font-size: clamp(12px, 3.1vw, 15px);
  font-weight: 900;
  pointer-events: auto;
  user-select: none;
}

.side-pill.left {
  left: 16px;
  background: linear-gradient(180deg, #d9ffe5 0%, #aaf3c2 100%);
}

.side-pill.right {
  right: 16px;
  background: linear-gradient(180deg, #ffe2f1 0%, #ffbadb 100%);
}

.side-pill img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex: 0 0 auto;
}

.side-pill:active,
.pixel-action:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

.corner-chip {
  position: absolute;
  display: none !important;
  top: max(90px, calc(env(safe-area-inset-top) + 82px));
  left: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 144px;
  min-height: 46px;
  padding: 8px 10px;
  border: 2px solid var(--ink);
  background: rgba(255,255,255,.9);
  box-shadow: 5px 5px 0 var(--ink), 0 14px 22px rgba(0, 126, 137, .12);
  font-size: 12px;
  font-weight: 900;
}

.corner-chip img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.skin-chip {
  position: absolute;
  top: max(108px, calc(env(safe-area-inset-top) + 100px));
  left: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 7px 9px;
  border: 2px solid var(--ink);
  background: rgba(255, 251, 230, .94);
  box-shadow: 5px 5px 0 var(--ink), 0 14px 22px rgba(0, 126, 137, .12);
  font-size: 12px;
  font-weight: 900;
  pointer-events: auto;
}

.skin-chip span {
  line-height: 1;
  white-space: nowrap;
}

.skin-chip select {
  width: 108px;
  min-height: 32px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  padding: 2px 6px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .08);
}

.zoom-pad {
  position: absolute;
  top: max(108px, calc(env(safe-area-inset-top) + 100px));
  right: 16px;
  display: grid;
  gap: 10px;
  pointer-events: auto;
}

.zoom-pad button {
  display: none;
  width: 46px;
  height: 46px;
  border: 2px solid var(--ink);
  background: linear-gradient(180deg, #ffffff 0%, #e5fbff 100%);
  box-shadow: 4px 4px 0 var(--ink), 0 10px 20px rgba(0, 126, 137, .12);
  font-size: 28px;
  line-height: 1;
  font-weight: 900;
}

.zoom-pad .landmark-toggle {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 54px;
  border: 2px solid var(--ink);
  background: linear-gradient(180deg, #fff7d8 0%, #ffd86b 100%);
  box-shadow: 4px 4px 0 var(--ink), 0 10px 20px rgba(0, 126, 137, .12);
  color: #171717;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
  cursor: pointer;
  user-select: none;
}

.zoom-pad .landmark-toggle input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.zoom-pad .landmark-toggle span {
  pointer-events: none;
}

.zoom-pad .landmark-toggle::before {
  content: "✓";
  position: absolute;
  right: -7px;
  bottom: -7px;
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border: 2px solid var(--ink);
  background: #5ee6b9;
  color: var(--ink);
  font-size: 14px;
  box-shadow: 2px 2px 0 var(--ink);
}

.zoom-pad .landmark-toggle:not(.active) {
  background: linear-gradient(180deg, #eeeeee 0%, #b8c1c5 100%);
  color: #6d7478;
}

.zoom-pad .landmark-toggle:not(.active)::before {
  content: "";
  background: #ff5b4a;
}

.zoom-pad button:active {
  transform: translateY(3px);
  box-shadow: 1px 1px 0 var(--ink);
}

.search-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 47vh;
  padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  background: #fff7d8;
  border-top: 2px solid var(--ink);
  box-shadow: 0 -8px 0 var(--ink);
  transform: translateY(115%);
  transition: transform .28s steps(5, end);
  pointer-events: auto;
  z-index: 8;
}

.search-sheet.open {
  transform: translateY(0);
}

.sheet-handle {
  width: 64px;
  height: 10px;
  margin: 0 auto 18px;
  border: 2px solid var(--ink);
  background: #ffc857;
}

.sheet-title {
  margin: 0 0 14px;
  font-size: 22px;
  font-weight: 900;
  text-align: center;
  text-shadow: 2px 2px 0 #8df0ff;
}

.cascade-selects {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.select-field {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.select-field span {
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  background: #5ee6b9;
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.pixel-input {
  width: 100%;
  height: 48px;
  border: 2px solid var(--ink);
  border-radius: 0;
  padding: 0 14px;
  background: #fff;
  box-shadow: inset 4px 4px 0 rgba(23,23,23,.12);
  font-size: 17px;
  font-weight: 900;
  outline: none;
}

.pixel-select {
  appearance: none;
  cursor: pointer;
  padding-right: 44px;
  background:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%) right 22px center / 8px 8px no-repeat,
    linear-gradient(135deg, var(--ink) 50%, transparent 50%) right 14px center / 8px 8px no-repeat,
    #ffffff;
}

.pixel-select:disabled {
  cursor: not-allowed;
  color: rgba(23, 23, 23, .58);
  background:
    linear-gradient(45deg, transparent 50%, rgba(23, 23, 23, .45) 50%) right 22px center / 8px 8px no-repeat,
    linear-gradient(135deg, rgba(23, 23, 23, .45) 50%, transparent 50%) right 14px center / 8px 8px no-repeat,
    #f2f2f2;
}

.city-results {
  max-height: 28vh;
  overflow-y: auto;
  padding-right: 5px;
}

.city-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  border: 2px solid var(--ink);
  background: #bdf9d2;
  box-shadow: 5px 5px 0 var(--ink);
  text-align: left;
}

.city-card.selected {
  background: #ffef96;
}

.city-card img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  flex: 0 0 auto;
}

.city-card strong {
  display: block;
  font-size: 18px;
  line-height: 1.2;
}

.city-card span {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  font-weight: 900;
  opacity: .75;
}

.empty-card {
  margin-top: 16px;
  padding: 14px;
  border: 2px solid var(--ink);
  background: #ffffff;
  box-shadow: 5px 5px 0 var(--ink);
  font-size: 15px;
  font-weight: 900;
  text-align: center;
}

.confirm-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.pixel-action {
  min-height: 48px;
  border: 2px solid var(--ink);
  background: #fff;
  box-shadow: 0 5px 0 var(--ink);
  font-size: 15px;
  font-weight: 900;
}

.pixel-action.primary {
  background: #ff9f1c;
}

.pixel-action.compact {
  min-height: 40px;
  padding: 0 12px;
  box-shadow: 0 4px 0 var(--ink);
}

.toast {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(78vw, 340px);
  padding: 16px 18px;
  transform: translate(-50%, -50%) scale(.85);
  border: 2px solid var(--ink);
  background: #fff;
  box-shadow: 8px 8px 0 var(--ink);
  text-align: center;
  font-size: 18px;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s steps(3, end), transform .2s steps(3, end);
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.overlay-page {
  position: absolute;
  inset: 0;
  z-index: 7;
  padding: max(16px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom));
  background: rgba(213, 243, 237, .92);
  overflow-y: auto;
  pointer-events: auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.page-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  text-shadow: 2px 2px 0 #ffd666;
}

.page-header img {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.profile-grid {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 14px;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat-chip {
  min-height: 72px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  background: #ffffff;
  box-shadow: 5px 5px 0 var(--ink);
  text-align: center;
  font-weight: 900;
}

.stat-chip strong {
  font-size: 24px;
  line-height: 1;
  color: #d96c00;
}

.stat-chip span {
  font-size: 12px;
}

.game-panel {
  border: 2px solid var(--ink);
  background: #fff7d8;
  box-shadow: 6px 6px 0 var(--ink);
  padding: 14px;
}

.game-panel h2 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 900;
}

.timeline-list {
  display: grid;
  gap: 10px;
}

.timeline-item {
  display: flex;
  gap: 10px;
  align-items: center;
  border-left: 6px solid #5ee6b9;
  padding: 10px;
  background: white;
  border-top: 2px solid var(--ink);
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  font-weight: 900;
}

.timeline-item img {
  width: 46px;
  height: 46px;
  object-fit: contain;
  flex: 0 0 auto;
}

.timeline-item span,
.timeline-item em {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  font-style: normal;
  opacity: .78;
}

.badge-wall {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.badge {
  display: grid;
  place-items: center;
  min-height: 92px;
  background: white;
  border: 2px solid var(--ink);
  padding: 8px 6px;
  text-align: center;
  font-weight: 900;
}

.badge img {
  max-width: 54px;
  max-height: 54px;
  object-fit: contain;
}

.badge strong {
  margin-top: 4px;
  font-size: 12px;
}

.badge span {
  font-size: 11px;
}

.badge.unlocked {
  background: #fff1a8;
  box-shadow: inset 0 0 0 4px rgba(255, 198, 51, .35);
}

.badge.locked {
  filter: grayscale(1);
  opacity: .58;
}

.toy-shelf {
  margin-top: 16px;
}

.toy-shelf-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
  gap: 12px;
}

.toy-card {
  min-height: 158px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  background: #ffffff;
  box-shadow: 5px 5px 0 var(--ink);
  padding: 10px;
  text-align: center;
  font-weight: 900;
}

.toy-card img {
  width: 112px;
  height: 88px;
  object-fit: contain;
}

.toy-card span {
  font-size: 12px;
  opacity: .72;
}

.poster-canvas {
  display: block;
  width: min(78vw, 360px);
  aspect-ratio: 9 / 16;
  margin: 0 auto 16px;
  border: 2px solid var(--ink);
  background: white;
  box-shadow: 8px 8px 0 var(--ink);
}

.poster-save {
  display: block;
  width: min(78vw, 360px);
  margin: 0 auto 22px;
  background: #ff9f1c;
}

@media (max-width: 640px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }

  .profile-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 720px) {
  .primary-button {
    width: 128px;
    height: 128px;
    font-size: 17px;
  }

  .bottom-dock {
    height: 150px;
  }

  .side-pill.left {
    left: calc(50% - 310px);
  }

  .side-pill.right {
    right: calc(50% - 310px);
  }

  .search-sheet {
    left: 50%;
    right: auto;
    width: 480px;
    transform: translate(-50%, 115%);
    border-left: 2px solid var(--ink);
    border-right: 2px solid var(--ink);
  }

  .search-sheet.open {
    transform: translate(-50%, 0);
  }

  .overlay-page {
    padding-left: max(32px, calc((100vw - 920px) / 2));
    padding-right: max(32px, calc((100vw - 920px) / 2));
  }
}

.auth-view {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(213, 243, 237, .92);
  pointer-events: auto;
}

.auth-view.active {
  display: grid;
}

.auth-panel {
  width: min(92vw, 380px);
  display: grid;
  gap: 13px;
  padding: 22px;
  border: 2px solid var(--ink);
  background: #fff7d8;
  box-shadow: 8px 8px 0 var(--ink);
}

.auth-panel > img {
  width: 72px;
  height: 72px;
  justify-self: center;
}

.auth-panel h1,
.auth-panel p {
  margin: 0;
  text-align: center;
}

.auth-panel h1 {
  font-size: 24px;
  font-weight: 900;
  text-shadow: 2px 2px 0 #ffd666;
}

.auth-panel p {
  font-size: 13px;
  font-weight: 900;
}

.auth-panel label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 900;
}

.auth-link {
  min-height: 38px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 900;
  text-decoration: underline;
}
