:root {
  color-scheme: light;
  --bg: #f3f6f9;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --text: #0f1720;
  --muted: #55606d;
  --accent: #0b7285;
  --danger: #b42318;
  --border: #d0dae5;
  --input-bg: #fcfdff;
  --secondary-bg: #eaf4f6;
  --secondary-text: #0b7285;
  --danger-border: #edc4be;
  --danger-bg: #fff5f3;
  --tag-bg: #e7f0fa;
  --tag-text: #0b3e69;
  --bg-gradient-start: #e4ecf7;
  --bg-gradient-mid: #f8fafc;
  --bg-gradient-end: #eef8f9;
  --sticky-bg: rgba(243, 246, 249, 0.96);
  --shadow: 0 8px 24px rgba(15, 23, 32, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0b1118;
    --surface: #121a24;
    --surface-soft: #162130;
    --text: #edf3fb;
    --muted: #9fb0c2;
    --accent: #63d2e9;
    --danger: #ffb0a3;
    --border: #2a3746;
    --input-bg: #0f1722;
    --secondary-bg: #173241;
    --secondary-text: #8de7f8;
    --danger-border: #5d2f2a;
    --danger-bg: #321a17;
    --tag-bg: #1e3145;
    --tag-text: #b7ddff;
    --bg-gradient-start: #090e14;
    --bg-gradient-mid: #111a25;
    --bg-gradient-end: #0d1a20;
    --sticky-bg: rgba(11, 17, 24, 0.93);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: linear-gradient(
    165deg,
    var(--bg-gradient-start) 0%,
    var(--bg-gradient-mid) 45%,
    var(--bg-gradient-end) 100%
  );
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  min-height: 100%;
}

a {
  color: var(--accent);
}

.app-shell {
  max-width: 720px;
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) 1rem 2rem;
}

.app-shell-wide {
  max-width: 980px;
}

.app-header h1 {
  margin: 0.1rem 0 0.4rem;
  font-size: clamp(1.4rem, 4vw, 2rem);
}

.subtitle {
  margin: 0;
  color: var(--muted);
}

.card-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.9rem;
}

.app-card {
  display: block;
  text-decoration: none;
  padding: 1rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.app-card:active,
.app-card:hover {
  transform: translateY(-2px);
}

.back-link {
  text-decoration: none;
  font-size: 0.95rem;
  color: var(--muted);
}

.composer,
.list-item,
.auth-panel {
  margin-top: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.85rem;
  box-shadow: var(--shadow);
}

input,
textarea,
button {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  font: inherit;
}

input,
textarea {
  background: var(--input-bg);
  color: var(--text);
  padding: 0.72rem;
  margin-bottom: 0.55rem;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

textarea {
  min-height: 110px;
  resize: vertical;
}

button {
  min-height: 48px;
  padding: 0.72rem 1rem;
  cursor: pointer;
}

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

.secondary-button {
  background: var(--secondary-bg);
  color: var(--secondary-text);
}

.danger-button {
  max-width: 92px;
  border: 1px solid var(--danger-border);
  color: var(--danger);
  background: var(--danger-bg);
}

.list {
  list-style: none;
  padding: 0;
  margin: 0.8rem 0 0;
  display: grid;
  gap: 0.6rem;
}

.list-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
}

.game-item {
  align-items: stretch;
}

.game-content {
  width: 100%;
}

.box-score-button {
  max-width: 170px;
}

.box-score-wrap {
  margin-top: 0.65rem;
  min-height: 180px;
}

.box-score-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem;
  background: var(--surface-soft);
}

.shimmer-card {
  position: relative;
  overflow: hidden;
}

.shimmer-card::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  animation: shimmer 1.1s infinite;
}

.shimmer-line {
  height: 0.72rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 72%, var(--surface-soft) 28%);
  margin-bottom: 0.55rem;
}

.shimmer-line-title {
  width: 38%;
  height: 0.85rem;
}

.shimmer-line-full {
  width: 100%;
}

.shimmer-line-short {
  width: 62%;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

.box-score-card h3 {
  margin: 0 0 0.45rem;
  font-size: 0.98rem;
}

.table-scroll {
  overflow-x: auto;
}

.box-score-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 440px;
}

.box-score-table th,
.box-score-table td {
  border: 1px solid var(--border);
  padding: 0.35rem;
  text-align: center;
}

.box-score-table th[scope="row"] {
  text-align: left;
}

.item-content p {
  margin: 0;
  word-break: break-word;
}

.item-content small {
  color: var(--muted);
}

.scoreboard-summary {
  margin-top: 0.45rem;
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-soft) 86%, var(--surface) 14%);
}

.scoreboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.scoreboard-status {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--muted);
}

.scoreboard-stat-labels,
.scoreboard-stats {
  display: grid;
  grid-template-columns: repeat(3, 1.4rem);
  gap: 0.45rem;
  justify-items: center;
  align-items: center;
}

.scoreboard-stat-labels {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
}

.scoreboard-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.15rem 0;
}

.scoreboard-stats {
  font-size: 1.02rem;
  color: var(--muted);
}

.scoreboard-stats strong {
  font-size: 1.32rem;
  color: var(--text);
  font-weight: 800;
}

.team-link-button {
  width: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  vertical-align: baseline;
  text-align: left;
}

.team-link-button strong {
  color: var(--text);
}

.team-link-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.list-empty {
  text-align: center;
  color: var(--muted);
  padding: 1rem;
}

.tag {
  display: inline-block;
  margin-top: 0.3rem;
  margin-right: 0.35rem;
  font-size: 0.8rem;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
}

.status-message {
  min-height: 1.3rem;
  color: var(--muted);
  margin: 0.7rem 0 0;
}

.pagination {
  margin-top: 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.pager-button {
  width: auto;
  min-width: 120px;
  flex: 0 0 auto;
}

.page-info {
  color: var(--muted);
  font-size: 0.92rem;
}

.sticky-top {
  position: sticky;
  top: 0;
  background: var(--sticky-bg);
  backdrop-filter: blur(4px);
  z-index: 10;
  padding-top: 0.4rem;
}

.sticky-action {
  position: sticky;
  bottom: max(0.5rem, env(safe-area-inset-bottom));
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 430px) {
  .app-shell {
    padding: max(0.8rem, env(safe-area-inset-top)) 0.8rem 1.5rem;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .list-item {
    flex-direction: column;
  }

  .danger-button {
    max-width: none;
  }

  .box-score-button {
    max-width: none;
  }

  .pagination {
    flex-direction: column;
    align-items: stretch;
  }

  .pager-button {
    width: 100%;
    min-width: 0;
  }
}
