:root {
  --bg: #0f0f0f;
  --card: #1c1c1c;
  --line: #2a2a2a;
  --text: #f1f1f1;
  --sub: #a1a1a1;
  --primary: #ff6a00;
  --warn: #ffd166;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Barlow', 'Noto Sans SC', sans-serif;
  background: radial-gradient(circle at top, #212121 0%, #0a0a0a 45%, #050505 100%);
  color: var(--text);
}

.app-page {
  background: #0b0f14;
}
.login-page {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: stretch;
  background: #06080c;
  overflow: hidden;
}

.app-shell {
  max-width: 460px;
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  background: #0b0f14;
}

.app-page.home-plain .app-shell {
  background: #0b0f14;
}

.app-page.home-plain {
  background: #0b0f14;
}

.topbar {
  display: grid;
  grid-template-columns: 84px 1fr 72px;
  gap: 8px;
  padding: calc(6px + env(safe-area-inset-top)) 8px 6px;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.city-pill,
.search,
button,
input {
  font: inherit;
}

.city-pill {
  border: 1px solid #3a3a3a;
  background: #181818;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search {
  border: 1px solid #3a3a3a;
  background: #171717;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
}

.locate-btn {
  border: 1px solid #3a3a3a;
  background: #181818;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  white-space: nowrap;
}

main {
  padding: 10px;
  min-height: 0;
  overflow: hidden;
}

.view {
  display: none;
  animation: fade 220ms ease;
}

.view.active {
  display: block;
  height: 100%;
  overflow-y: auto;
}

#homeView.view.active {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 8px;
  overflow: hidden;
}

#homeView > .panel {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
}

#demandList {
  overflow-y: auto;
  min-height: 0;
}

@keyframes fade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.map-wrap {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  height: 56vh;
  min-height: 420px;
  border: 1px solid #333;
  background: #111;
}

.real-map {
  position: absolute;
  inset: 0;
}

.map-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.08) 1px, transparent 1px) 0 0 / 36px 36px,
    linear-gradient(rgba(255,255,255,0.08) 1px, transparent 1px) 0 0 / 36px 36px,
    linear-gradient(160deg, #131313 0%, #1b1b1b 55%, #101010 100%);
}

.ball-marker {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(12, 12, 12, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 10px rgba(255, 146, 45, 0.6);
}

.court-card,
.detail-card,
.panel,
.game-row {
  margin-top: 8px;
  border: 1px solid #323232;
  border-radius: 16px;
  background: var(--card);
  padding: 10px;
}

.hidden {
  display: none;
}

.cta,
.btn-primary,
.btn-secondary,
.chip,
.tab {
  border: 0;
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
  cursor: pointer;
}

.cta,
.btn-primary {
  background: linear-gradient(100deg, var(--primary), #ff8740);
  color: #111;
  font-weight: 800;
}

.btn-secondary {
  background: #272727;
  border: 1px solid #3a3a3a;
}

.map-pick-btn {
  background: linear-gradient(100deg, #1a9cff, #49b5ff);
  border-color: #6ec5ff;
  color: #061421;
  font-weight: 800;
}

.cta {
  width: 100%;
  margin-top: 12px;
}

.section-title {
  margin: 0 0 8px;
}
.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.city-picker-card {
  max-height: 78vh;
  overflow-y: auto;
}

.city-list {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.city-option {
  border: 1px solid #3a3a3a;
  background: #202020;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  font-size: 13px;
  cursor: pointer;
}

.city-option.active {
  border-color: #ffb870;
  background: #3a2a1d;
  color: #ffd7aa;
}

.row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.chip {
  background: #2d2d2d;
  border: 1px solid #3b3b3b;
}

.chip.active {
  background: #ff6a0020;
  border-color: var(--primary);
}

.input {
  width: 100%;
  margin-top: 10px;
  border: 1px solid #3a3a3a;
  background: #121212;
  border-radius: 10px;
  color: var(--text);
  padding: 10px;
}
.field-help {
  margin: 2px 0 0;
  color: var(--sub);
  font-size: 13px;
}

select.input {
  appearance: none;
}

.demand-item {
  border: 1px solid #353535;
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 6px;
  background: #171717;
}

.demand-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.demand-time {
  display: inline-block;
  min-width: 52px;
  text-align: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(25, 186, 255, 0.16);
  border: 1px solid rgba(25, 186, 255, 0.45);
  color: #63d2ff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.demand-court {
  color: #ffd166;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.demand-item .meta {
  margin-top: 4px;
}
.favorite-item {
  border: 1px solid #353535;
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 6px;
  background: #171717;
}
.busy-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  margin-left: 6px;
  border: 1px solid #3f3f3f;
}

.pos-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid #3b3b3b;
  border-radius: 10px;
  padding: 7px 10px;
  background: #252525;
}

.pos-check input {
  accent-color: var(--primary);
}

.panel.muted {
  color: var(--sub);
}

.form label {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.form input {
  border: 1px solid #3a3a3a;
  background: #121212;
  color: var(--text);
  border-radius: 10px;
  padding: 8px;
}

.form select {
  border: 1px solid #3a3a3a;
  background: #121212;
  color: var(--text);
  border-radius: 10px;
  padding: 8px;
  width: 100%;
}

.with-unit {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}

.unit-tag {
  min-width: 34px;
  text-align: center;
  font-size: 12px;
  color: #cfcfcf;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  padding: 6px 8px;
  background: #171717;
}

.full {
  width: 100%;
  margin-bottom: 8px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 8px 10px 10px;
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  position: sticky;
  bottom: 0;
  z-index: 20;
}

.tab {
  background: #1e1e1e;
  border: 1px solid #313131;
  color: #bbb;
  padding: 10px 2px;
  font-size: 12px;
}

.tab.active {
  color: #111;
  background: var(--warn);
  font-weight: 700;
}

.meta {
  color: var(--sub);
  font-size: 13px;
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
}
.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
.modal-card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 420px);
  max-height: 84vh;
  overflow: auto;
  border: 1px solid #353535;
  border-radius: 16px;
  padding: 14px;
  background: #171717;
}
.modal-card label {
  display: block;
  margin-bottom: 10px;
}
.login-card {
  width: min(92vw, 430px);
  min-height: 100dvh;
  height: 100dvh;
  margin: 0 auto;
  padding: 0;
  overflow: hidden;
  background: #06080c;
  position: relative;
  display: flex;
  flex-direction: column;
}

.login-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: #06080c;
  background-image:
    linear-gradient(rgba(6, 8, 12, 0.34), rgba(6, 8, 12, 0.58)),
    url('./background.png');
  background-position: center 38%, center 38%;
  background-size: cover, cover;
  background-repeat: no-repeat, no-repeat;
  z-index: 0;
}
.standalone-login-card {
  position: static;
  transform: none;
}

body.app-native {
  background: radial-gradient(circle at 18% 0%, #11345a 0%, #09111d 34%, #05070d 100%);
}

.app-native .app-shell {
  max-width: 100%;
  background: transparent;
}

.app-native .topbar {
  grid-template-columns: 84px 1fr 82px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: rgba(6, 10, 18, 0.86);
  border-bottom: 1px solid #263240;
}

.app-native .city-pill,
.app-native .search,
.app-native .locate-btn {
  background: #111927;
  border-color: #2f3e52;
}

.app-native .panel,
.app-native .demand-item,
.app-native .favorite-item {
  background: rgba(13, 18, 28, 0.94);
  border-color: #2c3a4a;
}

.app-native .tabs {
  background: rgba(8, 12, 21, 0.95);
  border-top: 1px solid #243243;
}

.app-native .tab {
  border-radius: 16px;
  background: #141d2b;
  border-color: #2b3a4d;
}

.app-native .tab.active {
  background: linear-gradient(100deg, #ff7a1a, #ff9e48);
  color: #141414;
}

.app-native .login-card::before {
  background-image:
    linear-gradient(rgba(5, 8, 14, 0.52), rgba(5, 8, 14, 0.78)),
    url('./background.png');
}
.login-hero {
  min-height: 0;
  padding: max(14px, env(safe-area-inset-top)) 18px 4px;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  position: relative;
  z-index: 1;
}
.brand-main {
  line-height: 1;
}
.brand-logo {
  width: clamp(220px, 58vw, 360px);
  height: auto;
  display: block;
  filter: drop-shadow(0 8px 22px rgba(0, 0, 0, 0.42));
}
.brand-sub {
  margin-top: 8px;
  color: #d0d0d0;
  font-size: clamp(16px, 2.3vw, 22px);
  font-weight: 700;
}
.login-panel {
  padding: 8px 12px 12px;
  display: grid;
  align-content: end;
  gap: 6px;
  position: relative;
  z-index: 1;
  margin-top: auto;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  max-height: 64dvh;
  overflow-y: auto;
}
.login-panel .panel {
  background: rgba(23, 23, 23, 0.78);
  backdrop-filter: blur(4px);
  margin-top: 0;
}
.auth-inline {
  color: #b5bac7;
  font-size: 13px;
  text-align: left;
  padding: 0 4px 2px;
}
.agree-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 8px 0 12px;
  color: var(--sub);
  font-size: 13px;
}
.link-btn {
  border: 0;
  background: transparent;
  color: #ffd166;
  padding: 0;
  cursor: pointer;
  font: inherit;
}
.link-btn:hover {
  text-decoration: underline;
}
.agree-row a {
  color: #ffd166;
  text-decoration: none;
}
.agree-row a:hover {
  text-decoration: underline;
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.login-btn-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 2px;
}
.login-btn-row .btn-primary,
.login-btn-row .btn-secondary {
  width: 100%;
  min-height: 46px;
}
.agree-under-buttons {
  margin-top: 12px;
}
.register-entry-toggle {
  border: 0;
  background: transparent;
  color: #d8dde8;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 2px 0;
  cursor: pointer;
}
.register-entry-toggle:hover {
  color: #ffffff;
}
.entry-link-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.policy-content {
  max-height: 58vh;
  overflow: auto;
  border: 1px solid #3a3a3a;
  border-radius: 12px;
  padding: 12px;
  background: #101010;
  line-height: 1.6;
  color: #ddd;
  white-space: pre-wrap;
}
.register-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}
.register-row .input {
  margin-top: 0;
}
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0 12px;
}
.photo-cell {
  border: 1px dashed #4a4a4a;
  border-radius: 10px;
  background: #121212;
  color: var(--sub);
  font-size: 12px;
  min-height: 66px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 6px;
}
.form input:disabled {
  opacity: 0.75;
}
.profile-plain {
  color: var(--text);
  font-weight: 700;
  line-height: 1.9;
  font-size: 18px;
}
.demand-item .actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.demand-item .actions button {
  flex: 1;
  padding: 9px 8px;
  font-size: 13px;
}

.amap-logo,
.amap-copyright {
  z-index: 1 !important;
}

.app-footer {
  text-align: center;
  padding: 6px 12px calc(8px + env(safe-area-inset-bottom));
  background: #0b0f14;
  border-top: 1px solid #1f252d;
}

.app-footer a {
  color: #8b95a1;
  font-size: 12px;
  text-decoration: none;
}

.app-footer a:hover {
  color: #bcc7d3;
}

@media (max-width: 480px) {
  .app-shell {
    max-width: 100%;
  }
  .login-card {
    width: 100vw;
    max-width: 100vw;
    min-height: 100dvh;
    height: 100dvh;
    margin: 0;
    border-radius: 0;
  }
  .login-card::before {
    background-position: center 24%, center 24%;
  }
  .login-hero {
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: 2px;
  }
  .brand-logo {
    width: clamp(180px, 52vw, 260px);
  }
  .brand-sub {
    margin-top: 4px;
    font-size: 14px;
  }
  .login-panel {
    gap: 5px;
    padding-top: 4px;
    max-height: 68dvh;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }
  .map-wrap {
    height: 58vh;
    min-height: 440px;
  }
}

@media (max-height: 760px) {
  .login-card::before {
    background-position: center 18%, center 18%;
  }
  .login-panel {
    max-height: 72dvh;
  }
}

@media (max-height: 680px) {
  .login-hero {
    padding-top: max(6px, env(safe-area-inset-top));
  }
  .brand-logo {
    width: clamp(160px, 48vw, 220px);
  }
  .brand-sub {
    font-size: 13px;
    margin-top: 2px;
  }
  .login-panel {
    max-height: 76dvh;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .login-card::before {
    background-position: center 40%, center 40%;
  }
  .login-hero {
    padding-top: max(4px, env(safe-area-inset-top));
    padding-bottom: 0;
  }
  .brand-logo {
    width: clamp(140px, 28vw, 190px);
  }
  .brand-sub {
    display: none;
  }
  .login-panel {
    max-height: 82dvh;
  }
}
