:root {
  color-scheme: light;
  --bg: #f3efe6;
  --panel: rgba(255, 252, 245, 0.92);
  --panel-strong: #fffaf0;
  --stroke: rgba(116, 92, 58, 0.15);
  --ink: #1f1d18;
  --muted: #6f675c;
  --accent: #c5481c;
  --accent-soft: rgba(197, 72, 28, 0.12);
  --accent-2: #0b6e4f;
  --danger: #8f2d22;
  --warn: #8a6200;
  --shadow: 0 20px 60px rgba(51, 35, 16, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "PingFang TC", "Noto Sans TC", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(197, 72, 28, 0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(11, 110, 79, 0.12), transparent 24%),
    linear-gradient(180deg, #f7f3eb 0%, #efe7d8 100%);
  color: var(--ink);
  min-height: 100vh;
}

body.view-projector,
body.view-bigscreen,
body.view-checkin {
  background:
    radial-gradient(circle at top left, rgba(197, 72, 28, 0.18), transparent 32%),
    linear-gradient(180deg, #f6efe2 0%, #ece3d3 100%);
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
.ghost-upload {
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 1.2rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

button:hover,
.ghost-upload:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.secondary-button,
.ghost-upload,
.mini-button {
  background: var(--accent-soft);
  color: var(--accent);
}

.danger-button {
  background: rgba(143, 45, 34, 0.12);
  color: var(--danger);
}

.mini-button {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.snapshot-banner {
  background: rgba(11, 110, 79, 0.1);
  color: var(--accent-2);
  padding: 0.9rem 1.2rem;
  text-align: center;
  border-bottom: 1px solid rgba(11, 110, 79, 0.15);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  gap: 1.5rem;
  padding: 1.5rem;
}

.control-panel,
.dashboard-panel {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.brand-block,
.panel-card,
.hero-board,
.board-card {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand-block,
.panel-card,
.board-card {
  padding: 1.25rem;
}

.brand-block {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at top right, rgba(197, 72, 28, 0.14), transparent 34%),
    linear-gradient(180deg, rgba(255, 251, 244, 0.96), rgba(251, 245, 234, 0.92));
}

.brand-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  align-items: center;
  gap: 1rem;
}

.brand-copy {
  position: relative;
  z-index: 1;
}

.brand-logo-card {
  position: relative;
  overflow: hidden;
  margin: 0;
  justify-self: end;
  width: 132px;
  padding: 0.35rem;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(247, 233, 205, 0.88), rgba(234, 219, 190, 0.72));
  border: 1px solid rgba(116, 92, 58, 0.14);
  box-shadow: 0 10px 24px rgba(51, 35, 16, 0.08);
  transform: rotate(-2deg);
}

.brand-logo-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 247, 234, 0.22), rgba(255, 250, 243, 0.4));
  pointer-events: none;
}

.brand-logo-image {
  display: block;
  width: 100%;
  aspect-ratio: 0.68;
  object-fit: cover;
  object-position: center;
  border-radius: 18px;
  opacity: 0.82;
  filter: saturate(0.8) contrast(0.94) brightness(1.03);
}

.hero-board {
  padding: 1.4rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.hero-copy {
  min-width: 0;
}

.hero-status-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
}

.hero-sync-strip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.55rem;
}

.hero-sync-detail {
  margin: 0;
  text-align: right;
  max-width: 30ch;
  color: var(--muted);
}

.hero-sync-controls {
  justify-content: flex-end;
}

.hero-actions,
.button-row,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.button-column {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-header h2,
.hero-board h2,
.brand-block h1 {
  margin: 0;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.74rem;
  color: var(--accent);
  margin: 0 0 0.45rem;
}

.lead,
.muted-note,
.match-meta,
.timeline-note,
.share-mode-label,
.player-subline {
  color: var(--muted);
}

.lead {
  max-width: 34ch;
}

.stack-form,
.stack-form label {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.stack-form {
  gap: 0.8rem;
}

.grid-two,
.grid-three,
.content-grid {
  display: grid;
  gap: 0.85rem;
}

.grid-two,
.content-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(116, 92, 58, 0.18);
  border-radius: 16px;
  padding: 0.8rem 0.9rem;
  background: rgba(255, 255, 255, 0.8);
}

textarea {
  resize: vertical;
}

.mini-input {
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: rgba(11, 110, 79, 0.1);
  color: var(--accent-2);
  font-size: 0.84rem;
  white-space: nowrap;
}

.pill.warn {
  background: rgba(138, 98, 0, 0.1);
  color: var(--warn);
}

.pill.danger {
  background: rgba(143, 45, 34, 0.12);
  color: var(--danger);
}

.list-board,
.table-board,
.timeline-board {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.empty-state {
  min-height: 120px;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: var(--muted);
  border: 1px dashed rgba(116, 92, 58, 0.22);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
}

.seeding-item,
.standings-row,
.timeline-item,
.player-row,
.round-card {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.95rem 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(116, 92, 58, 0.1);
}

.seed-index {
  display: inline-block;
  min-width: 2.2rem;
  color: var(--accent);
  font-weight: 700;
}

.player-row {
  align-items: flex-start;
}

.player-main {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.player-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.player-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
}

.matches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

.match-card {
  padding: 1rem;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(250, 242, 228, 0.95));
  border: 1px solid rgba(116, 92, 58, 0.12);
  box-shadow: 0 16px 40px rgba(41, 29, 13, 0.08);
}

.match-topline,
.score-row,
.match-admin-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.match-admin-row {
  margin-top: 0.8rem;
}

.match-admin-row label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.match-body {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.8rem;
  align-items: center;
  margin: 1rem 0 0.7rem;
}

.score-column {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  align-items: center;
}

.player-button {
  border-radius: 18px;
  padding: 1rem;
  min-height: 82px;
  background: rgba(197, 72, 28, 0.08);
  color: var(--ink);
}

.player-button.active-winner {
  background: rgba(11, 110, 79, 0.14);
  color: var(--accent-2);
}

.player-button.locked {
  opacity: 0.7;
}

.score-input {
  width: 4rem;
  text-align: center;
}

.full-width-card {
  width: 100%;
}

.share-board {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  align-items: center;
}

.qr-image {
  width: min(100%, 260px);
  aspect-ratio: 1;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(116, 92, 58, 0.12);
}

.share-link {
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}

.standings-table {
  display: grid;
  gap: 0.6rem;
}

.standings-row {
  grid-template-columns: 48px 1.5fr repeat(6, minmax(42px, 78px));
}

.timeline-item,
.round-card {
  flex-direction: column;
  align-items: stretch;
}

.timeline-item strong,
.round-card strong {
  color: var(--ink);
}

.round-card-header {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
}

.round-card-matches {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.round-card-matches span {
  color: var(--muted);
}

body.view-projector #control-panel,
body.view-bigscreen #control-panel,
body.view-checkin #control-panel {
  display: none;
}

body.view-projector .app-shell,
body.view-bigscreen .app-shell,
body.view-checkin .app-shell {
  grid-template-columns: 1fr;
}

body.view-projector .lower-grid .board-card:last-child,
body.view-projector .top-grid .board-card:first-child,
body.view-checkin .mid-grid,
body.view-checkin #matches-board,
body.view-checkin #bracket-board,
body.view-checkin #standings-board,
body.view-checkin #history-board,
body.view-checkin .full-width-card,
body.view-checkin .lower-grid .board-card:first-child {
  display: none;
}

body.view-checkin .top-grid,
body.view-projector .mid-grid,
body.view-bigscreen .mid-grid {
  grid-template-columns: 1fr;
}

body.view-bigscreen {
  font-size: 1.08rem;
}

body.view-bigscreen .match-card,
body.view-projector .match-card {
  padding: 1.25rem;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .content-grid,
  .grid-three {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 0.9rem;
  }

  .hero-board,
  .match-body {
    grid-template-columns: 1fr;
  }

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

  .hero-status-panel,
  .hero-sync-strip {
    align-items: flex-start;
  }

  .hero-sync-detail {
    text-align: left;
    max-width: none;
  }

  .grid-two,
  .grid-three,
  .standings-row {
    grid-template-columns: 1fr;
  }

  .brand-intro {
    grid-template-columns: 1fr;
  }

  .brand-logo-card {
    justify-self: start;
    width: 116px;
    transform: rotate(-2deg);
  }
}
