.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: calc(var(--space-3) + env(safe-area-inset-top)) var(--space-4) var(--space-3);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-size: 18px;
  font-weight: 600;
}

.view-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow-x: clip;
}

.view {
  flex: 1;
  padding: var(--space-4);
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.view-forward {
  animation: view-in-forward 0.32s cubic-bezier(0.22, 0.9, 0.3, 1) both;
}

.view-backward {
  animation: view-in-backward 0.32s cubic-bezier(0.22, 0.9, 0.3, 1) both;
}

.view-fade {
  animation: view-in-fade 0.26s ease both;
}

@keyframes view-in-forward {
  from {
    opacity: 0;
    transform: translate3d(28px, 0, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes view-in-backward {
  from {
    opacity: 0;
    transform: translate3d(-28px, 0, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes view-in-fade {
  from {
    opacity: 0;
    transform: translate3d(0, 8px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@supports not (overflow: clip) {
  .view-forward,
  .view-backward {
    animation-name: view-in-fade;
  }
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}

.tab-indicator {
  position: absolute;
  top: 0;
  left: 0;
  width: 25%;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--primary);
  pointer-events: none;
  transition: transform 0.32s cubic-bezier(0.34, 1.15, 0.64, 1);
}

.tabbar a {
  flex: 1;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  line-height: 1.2;
  color: var(--muted);
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s ease;
}

.tabbar a .tab-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 26px;
  border-radius: 999px;
  transition: background-color 0.25s ease;
}

.tab-icon-svg {
  display: block;
  width: 22px;
  height: 22px;
  transition: transform 0.2s ease;
}

.tabbar a:active .tab-icon-svg {
  transform: scale(0.86);
}

.tabbar a.active {
  color: var(--primary);
  font-weight: 600;
}

.tabbar a.active .tab-icon {
  background: var(--primary-weak);
  animation: tab-icon-pop 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.tabbar a.active .tab-label {
  animation: tab-label-in 0.3s ease both;
}

@keyframes tab-icon-pop {
  0% {
    transform: scale(0.72);
  }
  55% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes tab-label-in {
  from {
    opacity: 0.4;
    transform: translate3d(0, 3px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

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

.small {
  font-size: 12px;
}

.strong {
  font-weight: 600;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.chip-primary {
  background: var(--primary-weak);
  color: var(--primary);
}

.chip-win {
  background: var(--primary-weak);
  color: var(--win);
}

.chip-lost {
  color: var(--lost);
}

.chip-warn {
  color: var(--warn);
}

.summary-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.summary-item .summary-label {
  font-size: 12px;
  color: var(--muted);
}

.summary-item .summary-value {
  font-size: 18px;
  font-weight: 600;
}

.summary-note {
  font-size: 12px;
  color: var(--muted);
}

.rec-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.rec-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  text-align: left;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
}

.rec-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.rec-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.rec-teams {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.rec-teams .vs {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

.pick-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.pick-row {
  display: grid;
  grid-template-columns: 64px 1fr 1fr;
  align-items: baseline;
  gap: var(--space-2);
  padding: 8px 10px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.pick-row:last-child {
  border-bottom: none;
}

.pick-row:nth-child(even) {
  background: var(--chip);
}

.pick-row-fallback {
  grid-template-columns: 1fr;
  color: var(--muted);
}

.pick-goals {
  font-weight: 600;
}

.pick-metric {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: var(--space-1);
  min-width: 0;
}

.pick-metric-label {
  color: var(--muted);
  font-size: 12px;
}

.pick-metric-value {
  font-size: 14px;
}

.rec-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.rec-result {
  font-size: 14px;
  font-weight: 600;
}

.form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.field label {
  font-size: 14px;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--primary);
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
}

.button {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 16px;
}

.button-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 600;
}

.button-ghost {
  background: transparent;
}

.button-danger {
  color: var(--lost);
  border-color: var(--lost);
}

.button-primary.button-danger {
  background: var(--lost);
  border-color: var(--lost);
  color: #ffffff;
}

.form-error {
  color: var(--lost);
  font-size: 14px;
  min-height: 20px;
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.auth-links {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  font-size: 14px;
  color: var(--muted);
}

.auth-links a {
  color: var(--primary);
}

.filters {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.filter-row {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.filter-row .field {
  flex: 1;
  min-width: 130px;
}

.segmented {
  display: flex;
  gap: var(--space-2);
}

.segmented button {
  flex: 1;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
}

.segmented button.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-weak);
}

.empty {
  padding: var(--space-5) var(--space-4);
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.load-more {
  display: flex;
  justify-content: center;
  padding: var(--space-2) 0;
}

.invite-code {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  text-align: center;
}

.stat-grid .stat-value {
  font-size: 18px;
  font-weight: 600;
}

.stat-grid .stat-label {
  font-size: 12px;
  color: var(--muted);
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.list-item:last-child {
  border-bottom: none;
}

.toast-root {
  position: fixed;
  left: 50%;
  bottom: calc(80px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--text);
  color: var(--surface);
  font-size: 14px;
}

.toast-error {
  background: var(--lost);
  color: #ffffff;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(17, 24, 39, 0.45);
  display: flex;
  align-items: flex-end;
}

.sheet {
  width: 100%;
  max-height: 86vh;
  overflow: auto;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: var(--space-4);
  padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.sheet-title {
  font-size: 16px;
  font-weight: 600;
}

.share-guide-steps {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: 14px;
  line-height: 1.6;
}

.copy-helper {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: none;
  padding: 0;
  pointer-events: none;
}

.detail-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: 14px;
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--border);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-key {
  color: var(--muted);
  font-size: 12px;
}

.detail-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.dialog {
  margin: auto;
  width: calc(100% - 48px);
  max-width: 360px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.dialog-actions {
  display: flex;
  gap: var(--space-2);
}

.dialog-actions .button {
  flex: 1;
}

.page-note {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: var(--space-2) 0;
}

.pill-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.pill-toggle button {
  border: none;
  background: transparent;
  min-height: 36px;
  padding: 0 14px;
  font-size: 14px;
}

.pill-toggle button.active {
  background: var(--primary-weak);
  color: var(--primary);
}

@media (prefers-reduced-motion: reduce) {
  .view-forward,
  .view-backward,
  .view-fade,
  .tabbar a.active .tab-icon,
  .tabbar a.active .tab-label {
    animation: none;
  }

  .tab-indicator,
  .tabbar a .tab-icon,
  .tab-icon-svg {
    transition: none;
  }
}
