/* 选城、玩法设置和出发按钮共用一套流式布局。 */
#city {
  left: 0; right: 0; margin-inline: auto; transform: none;
  display: grid; grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 84px minmax(0, 1fr) auto auto;
  padding: env(safe-area-inset-top, 0px) 0 calc(env(safe-area-inset-bottom, 0px) + min(7vw, 33.6px));
  background: linear-gradient(var(--sky) 50%, #33BA6D 50%);
}
.city-bg { position: absolute; left: 0; right: 0; bottom: env(safe-area-inset-bottom); aspect-ratio: 941 / 1672; pointer-events: none; }
.city-bg img { width: 100%; height: 100%; }

.city-head { position: absolute; left: 0; right: 0; top: env(safe-area-inset-top); height: 84px; }
#city > .city-head, #city > .city-grid, #city > .setrow, #city > .depart { min-width: 0; }
#city > .city-head { position: relative; top: auto; }
#chip-back { position: absolute; left: 8px; top: 10px; }
.city-title {
  position: absolute; left: 0; right: 0; top: 37px; transform: translateY(-50%); text-align: center; pointer-events: none;
  font: 30px/1 var(--ui-font); color: #fff; letter-spacing: .06em; text-indent: .06em;
  text-shadow:
    0 3px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 2px 0 var(--ink), 0 -2px 0 var(--ink),
    1.5px 1.5px 0 var(--ink), -1.5px 1.5px 0 var(--ink), 1.5px -1.5px 0 var(--ink), -1.5px -1.5px 0 var(--ink);
}

/* 三列城市，最后一行两个居中。空间不足时只滚动列表。 */
.city-grid {
  position: relative; width: calc(100% - 12px); min-height: 0; margin: 0 6px 2px;
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); grid-auto-rows: minmax(110px, 1fr);
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
  container-type: size;
}
.city-cell {
  grid-column: span 2; min-width: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 2px 0 4px;
}
.city-cell:nth-child(7) { grid-column: 2 / span 2; }
.city-cell .art {
  --art: 56px;
  --art: clamp(56px, min(calc(100cqw / 3 - 14px), calc(100cqh / 3 - 56px)), 150px);
  position: relative; flex: none; width: var(--art); height: var(--art);
  transition: transform .22s cubic-bezier(.3, 1.6, .5, 1);
}
.city-cell .art img { position: relative; width: 100%; height: 100%; }
.city-cell .art::before {   /* 选中时背后的一圈黄光 */
  content: ""; position: absolute; inset: -16%; border-radius: 50%; opacity: 0; transform: scale(.6);
  background: radial-gradient(closest-side, rgba(255, 248, 180, .98), rgba(255, 214, 72, .6) 62%, rgba(255, 214, 72, 0));
  transition: opacity .2s, transform .25s;
}
.city-cell .badge { position: absolute; right: -2%; top: -1%; width: 30%; max-width: 34px; min-width: 24px; opacity: 0; transform: scale(.3); transition: opacity .15s, transform .25s cubic-bezier(.3, 1.8, .5, 1); }
.city-cell .nm {
  margin-top: 2px; font: 21px/1.1 var(--ui-font); color: var(--ink); letter-spacing: .04em;
  text-shadow: 2px 0 0 #fff, -2px 0 0 #fff, 0 2px 0 #fff, 0 -2px 0 #fff, 1.5px 1.5px 0 #fff, -1.5px 1.5px 0 #fff, 1.5px -1.5px 0 #fff, -1.5px -1.5px 0 #fff;
}
.city-cell .ft { font-size: 14px; line-height: 1.35; font-weight: 600; color: #6A3B2C; white-space: nowrap; }
.city-cell[aria-checked="true"] .art { transform: scale(1.08); }
.city-cell[aria-checked="true"] .art::before { opacity: 1; transform: none; }
.city-cell[aria-checked="true"] .badge { opacity: 1; transform: none; }
.city-cell[aria-checked="true"] .nm { color: var(--red); }
.city-cell:active .art { transform: scale(.95); }

/* 玩法栏和出发按钮固定留在列表下面。 */
.setrow {
  position: relative; justify-self: center; max-width: 100%;
  min-height: 44px; padding: 0 12px; display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 600; color: var(--ink);
}
.setrow b { color: var(--red); font-weight: 700; flex: none; white-space: nowrap; }

.depart {
  position: relative; justify-self: center; width: 72%; z-index: 2;
  margin-top: 11.56cqw; margin-top: min(11.56cqw, 6dvh);
}

/* 进场 */
#city .city-bg img, #city .city-head, #city .city-cell, #city .setrow, #city .depart { opacity: 0; }
#city.ready .city-bg img, #city.ready .city-head, #city.ready .setrow { opacity: 1; transition: opacity .25s; }
#city.ready .city-cell { opacity: 1; animation: pop .35s calc(var(--i) * 35ms + .05s) cubic-bezier(.3, 1.5, .5, 1) backwards; }
#city.ready .depart { opacity: 1; animation: pop .4s .3s cubic-bezier(.3, 1.6, .5, 1) backwards, breathe 2s 1.2s ease-in-out infinite; }
#city.ready .depart:active { animation: none; }
@media (prefers-reduced-motion: reduce) {
  #city.ready .city-cell, #city.ready .depart { animation: none; }
}

/* 开局设置面板：从底部升起，盖住按钮那一块 */
.sheet { position: absolute; inset: 0; z-index: 10; }
.sheet-mask { position: absolute; inset: 0; background: rgba(42, 10, 30, .45); animation: fade .2s; }
.sheet-card {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 16px calc(env(safe-area-inset-bottom) + 16px);
  background: #FFF7EC; border-radius: 22px 22px 0 0; box-shadow: 0 -6px 24px rgba(42, 10, 30, .18);
  animation: rise .25s cubic-bezier(.2, .9, .3, 1);
}
.sheet-card h3 { font-size: 20px; text-align: center; margin-bottom: 10px; }
.seg-l { font-size: 15px; font-weight: 600; color: #6A3B2C; margin: 12px 2px 6px; }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; height: 50px; border-radius: 14px; background: #fff; border: 1.5px solid rgba(42, 10, 30, .14); font-size: 17px; font-weight: 700; }
.seg button[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: #fff; }
.seg-hint { font-size: 15px; line-height: 1.4; color: #6A3B2C; margin: 6px 2px 0; }
.sheet-ok { display: block; width: 100%; height: 52px; margin-top: 18px; border-radius: 16px; background: var(--ink); color: #fff; font-size: 18px; font-weight: 700; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(100%); } }
