@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;600;700&display=swap");
@import url("./tokens.css");

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--color-primary-text);
  background: #e8eaee;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font-family: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ---------- Stage / phone ---------- */

.stage {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.phone {
  width: var(--phone-w);
  height: var(--phone-h);
  background: var(--color-bg-page);
  border-radius: 36px;
  box-shadow: 0 20px 50px rgba(28, 28, 46, 0.18);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  border: 8px solid var(--phone-bezel);
}

.phone-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--color-bg-page);
}

/* Real device: drop desktop phone chrome, fill the viewport */
@media (max-width: 520px) {
  html {
    height: 100%;
  }

  body {
    background: var(--color-bg-page);
    min-height: 100%;
    min-height: 100dvh;
  }

  body.sb-has-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
  }

  .stage {
    min-height: 100%;
    min-height: 100dvh;
    height: 100%;
    height: 100dvh;
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
  }

  body.sb-has-shell .stage {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
  }

  .phone {
    width: 100%;
    max-width: none;
    height: 100%;
    min-height: 100%;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  body.sb-has-shell .phone {
    min-height: 0;
  }

  .status-bar {
    display: none;
  }

  /* No shell: notch/home indicator insets go on the in-app nav */
  body:not(.sb-has-shell) .top-nav {
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(var(--nav-h) + env(safe-area-inset-top, 0px));
  }

  .tabbar {
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .page-body {
    padding-bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom, 0px));
  }

  body.flow-screen .page-body,
  body.flow-screen .page-body.compact {
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
}

.status-bar {
  height: var(--status-h);
  padding: 0 24px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  color: var(--status-fg);
  background: var(--status-bg);
  font-size: 14px;
  font-weight: 600;
  padding-bottom: 6px;
}

.status-bar.light {
  color: var(--color-primary-text);
  background: var(--color-bg-page);
}

.status-icons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.top-nav {
  height: var(--nav-h);
  background: var(--nav-bg);
  color: var(--nav-fg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--page-padding);
  flex-shrink: 0;
  box-shadow: inset 0 -1px 0 var(--color-neutral-200);
}

[data-theme="ink"] .top-nav,
[data-theme="forest"] .top-nav,
[data-theme="night"] .top-nav,
[data-theme="dusk"] .top-nav {
  box-shadow: none;
}

.top-nav .nav-title {
  font-size: var(--type-nav);
  font-weight: var(--weight-semibold);
  line-height: 24px;
}

.nav-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  color: var(--nav-fg);
}

.nav-icon svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.page-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--page-padding);
  padding-bottom: calc(var(--tab-h) + 16px);
  min-height: 0;
}

/* 打线 / 比赛页：无滚动条，左右与底栏对齐 12px */
.page-body.compact {
  overflow: hidden;
  padding: 12px;
  padding-bottom: 88px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 比赛记录：球场 bar 全宽触顶，下方内容保留 12px */
.page-body.compact:has(> .defense-bar) {
  padding-top: 0;
  padding-left: 0;
  padding-right: 0;
}

.page-body.compact > .defense-bar {
  flex: 0 0 auto;
  margin: 0;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.page-body.compact > .defense-bar ~ * {
  margin-left: 12px;
  margin-right: 12px;
}

body.flow-screen .page-body {
  padding-bottom: 16px;
}

body.flow-screen .page-body.compact {
  padding-bottom: 16px;
}

.page-body.compact > .card {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 10px 12px;
}

.page-body.compact > .btn {
  flex: 0 0 auto;
}

/* ---------- Cards / type ---------- */

.card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.section {
  margin-bottom: var(--space-md);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.section-title {
  font-size: var(--type-m);
  font-weight: var(--weight-semibold);
  line-height: var(--lh-m);
  color: var(--color-neutral-900);
}

.section-hint {
  font-size: var(--type-sm);
  color: var(--color-neutral-500);
  line-height: var(--lh-sm);
}

/* ---------- Tags / buttons ---------- */

.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: var(--color-bg-tag);
  color: var(--color-primary-text);
  font-size: var(--type-sm);
  line-height: var(--lh-sm);
}

.tag.muted {
  color: var(--color-neutral-500);
}

.tag.live {
  background: var(--color-accent-red);
  color: var(--color-white);
  font-weight: var(--weight-medium);
  gap: 6px;
}

.tag.live::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--type-base);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-button), opacity var(--duration-fast) var(--ease-button);
}

.btn:active {
  transform: scale(0.96);
  opacity: 0.8;
}

.btn-primary {
  background: var(--color-brand);
  color: var(--color-white);
}

.btn-primary:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.btn-secondary {
  background: var(--color-white);
  color: var(--color-primary-text);
  box-shadow: var(--shadow-sm);
}

.btn-ghost {
  background: transparent;
  color: var(--color-primary-text);
  height: 32px;
  padding: 8px 16px;
}

.btn-block {
  width: 100%;
}

.btn-danger {
  background: var(--color-accent-red);
  color: var(--color-white);
}

.btn-outline {
  background: var(--color-white);
  color: var(--color-primary-text);
  box-shadow: inset 0 0 0 1px var(--color-neutral-200);
}

.link {
  font-size: var(--type-sm);
  color: var(--color-neutral-500);
}

/* ---------- Inputs ---------- */

.field {
  width: 100%;
  height: 40px;
  background: var(--color-white);
  border: 1px solid var(--color-neutral-300);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: var(--type-base);
  color: var(--color-primary-text);
  outline: none;
}

.field::placeholder {
  color: var(--color-neutral-400);
}

.field:focus {
  border-color: var(--color-brand);
}

.field-label {
  display: block;
  font-size: var(--type-sm);
  color: var(--color-neutral-500);
  margin-bottom: var(--space-sm);
}

/* ---------- Bottom tabs ---------- */

.tabbar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  height: 64px;
  background: var(--color-white);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
  padding: 0 8px;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--color-neutral-400);
  font-size: 11px;
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
}

.tab-item svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab-item.active {
  color: var(--color-brand-dark);
}

.tab-item.active .tab-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-brand);
  color: var(--color-white);
  display: grid;
  place-items: center;
  margin-top: -2px;
}

.tab-item.active .tab-icon svg {
  stroke: #fff;
}

/* ---------- Choice chips ---------- */

.choice-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.choice {
  height: 48px;
  border: 1px solid var(--color-neutral-200);
  background: var(--color-white);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: var(--type-base);
  font-weight: var(--weight-medium);
  color: var(--color-primary-text);
  cursor: pointer;
  position: relative;
}

.choice.active {
  border-color: var(--selected-border);
  background: var(--selected-bg);
}

.choice.active::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 10px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-accent-red);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M4 8.2l2.4 2.4L12 5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}

.seg {
  display: flex;
  background: transparent;
  border-radius: var(--radius-md);
  padding: 0;
  gap: 8px;
}

.seg button {
  flex: 1;
  height: 40px;
  border: none;
  background: var(--color-white);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--color-primary-text);
  cursor: pointer;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.seg button.active {
  background: var(--color-brand);
  color: var(--color-white);
}

/* ---------- Gallery ---------- */

.gallery {
  min-height: 100vh;
  padding: 40px 24px 64px;
}

.gallery-head {
  max-width: 1320px;
  margin: 0 auto 32px;
}

.gallery-head h1 {
  font-size: 28px;
  line-height: 36px;
  margin-bottom: 8px;
}

.gallery-head p {
  color: var(--color-neutral-500);
  font-size: 14px;
}

.gallery-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 40px;
}

.gallery-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.gallery-item h2 {
  font-size: 16px;
  font-weight: 600;
}

.gallery-item a.open {
  font-size: 13px;
  color: var(--color-brand-dark);
}

.phone.preview {
  transform: scale(0.86);
  transform-origin: top center;
  margin-bottom: -80px;
}

body.embed {
  background: transparent;
}

body.embed .stage {
  min-height: 0;
  padding: 0;
}

.gallery-frame {
  width: 406px;
  height: 860px;
  border: 0;
  background: transparent;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-neutral-500);
  font-size: var(--type-sm);
}

.meta-row svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}
