:root {
  --ink-strong: #6d3924;
  --ink-primary: #8a4a2e;
  --ink-soft: #a5755b;
  --panel-bg: rgba(255, 250, 244, 0.78);
  --panel-border: rgba(167, 125, 94, 0.22);
  --shadow-soft: 0 22px 60px rgba(110, 74, 42, 0.14);
  --shadow-light: 0 12px 30px rgba(110, 74, 42, 0.08);
  --gold: #c68c44;
  --gold-soft: rgba(215, 172, 99, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--ink-strong);
}

body {
  min-height: 100vh;
  background:
    linear-gradient(rgba(255, 246, 239, 0.18), rgba(255, 246, 239, 0.45)),
    url("/assets/background.png") center top / cover no-repeat fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.36), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.22), transparent 18%);
  pointer-events: none;
}

.page-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.board {
  width: min(1200px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.board-header,
.table-panel,
.summary-grid {
  width: 100%;
}

.board-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0;
}

.title-image {
  width: min(100%, 980px);
  display: block;
  filter: drop-shadow(0 10px 16px rgba(73, 36, 18, 0.22));
}

.title-image-mobile,
.mobile-bottom-nav {
  display: none;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.summary-card {
  padding: 18px 20px;
  border-radius: 24px;
  text-align: center;
  background: linear-gradient(180deg, rgba(255, 253, 249, 0.88), rgba(255, 246, 236, 0.72));
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-light);
  backdrop-filter: blur(10px);
}

.summary-label {
  display: block;
  margin-bottom: 10px;
  color: var(--ink-soft);
  font-size: 14px;
}

.summary-value {
  display: block;
  width: 100%;
  font-size: clamp(28px, 4vw, 38px);
  color: var(--gold);
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
}

.table-panel {
  padding: 24px;
  border-radius: 32px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.toolbar-meta {
  font-size: 15px;
  color: var(--ink-soft);
}

.toolbar-formula {
  font-size: 15px;
  color: var(--ink-primary);
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.refresh-button {
  border: none;
  border-radius: 999px;
  padding: 11px 22px;
  background: linear-gradient(135deg, #b87443, #d2a162);
  color: #fffefc;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 12px 22px rgba(184, 116, 67, 0.22);
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.refresh-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 26px rgba(184, 116, 67, 0.26);
}

.refresh-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 24px;
}

.ranking-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
  overflow: hidden;
}

.ranking-table thead th {
  padding: 16px 12px;
  background: linear-gradient(180deg, rgba(205, 154, 90, 0.24), rgba(205, 154, 90, 0.1));
  color: var(--ink-primary);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.ranking-table tbody td {
  padding: 16px 12px;
  text-align: center;
  font-size: 15px;
  border-top: 1px solid rgba(180, 145, 114, 0.16);
  background: rgba(255, 255, 255, 0.32);
}

.ranking-table tbody tr:nth-child(even) td {
  background: rgba(255, 248, 240, 0.56);
}

.ranking-table tbody tr:hover td {
  background: rgba(255, 245, 232, 0.82);
}

.rank-pill {
  display: inline-flex;
  min-width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: 999px;
  font-weight: 700;
  color: var(--ink-primary);
  background: rgba(198, 140, 68, 0.12);
}

.rank-top-1,
.rank-top-2-4,
.rank-rest {
  color: #fff;
}

.rank-top-1 {
  background: linear-gradient(135deg, #d89f38, #f0c56d);
}

.rank-top-2-4 {
  background: linear-gradient(135deg, #8f9fb5, #b8c4d3);
}

.rank-rest {
  background: linear-gradient(135deg, #be875b, #d7ab83);
}

.unit-name,
.program-name {
  font-weight: 600;
}

.program-name {
  min-width: 220px;
}

.unit-name {
  min-width: 180px;
}

.votes-total {
  color: var(--gold);
  font-weight: 700;
}

.ranking-table tbody td:nth-child(4),
.ranking-table tbody td:nth-child(5),
.ranking-table tbody td:nth-child(6) {
  font-weight: 700;
  font-size: 19px;
}

.empty-row,
.error-row {
  padding: 32px 12px !important;
  color: var(--ink-soft);
}

@media (min-width: 561px) {
  .page-shell {
    align-items: flex-start;
    padding: 10px 18px 16px;
  }

  .board {
    width: min(1820px, 100%);
    gap: 10px;
  }

  .board-header {
    margin-bottom: 0;
  }

  .title-image-desktop {
    width: 90%;
  }

  .summary-grid {
    display: none;
  }

  .toolbar-formula {
    display: none;
  }

  .table-panel {
    padding: 14px 18px;
    border-radius: 24px;
  }

  .table-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
  }

  .toolbar-meta {
    font-size: 16px;
    text-align: left;
  }

  .refresh-button {
    padding: 10px 22px;
    font-size: 16px;
    font-weight: 700;
  }

  .toolbar-formula {
    font-size: 16px;
    justify-self: end;
  }

  .table-wrap {
    overflow-x: visible;
  }

  .ranking-table {
    min-width: 0;
    table-layout: fixed;
  }

  .ranking-table thead th {
    padding: 10px 8px;
    font-size: 16px;
  }

  .ranking-table tbody td {
    padding: 8px 8px;
    font-size: 18px;
    line-height: 1.35;
  }

  .ranking-table tbody td:nth-child(4),
  .ranking-table tbody td:nth-child(5),
  .ranking-table tbody td:nth-child(6) {
    font-size: 22px;
  }

  .ranking-table thead th:nth-child(1),
  .ranking-table tbody td:nth-child(1) {
    width: 10%;
  }

  .ranking-table thead th:nth-child(2),
  .ranking-table tbody td:nth-child(2) {
    width: 50%;
  }

  .ranking-table thead th:nth-child(3),
  .ranking-table tbody td:nth-child(3) {
    width: 40%;
  }

  .ranking-table thead th:nth-child(4),
  .ranking-table tbody td:nth-child(4),
  .ranking-table thead th:nth-child(5),
  .ranking-table tbody td:nth-child(5),
  .ranking-table thead th:nth-child(6),
  .ranking-table tbody td:nth-child(6) {
    display: none;
  }

  .program-name,
  .unit-name {
    min-width: 0;
    word-break: break-word;
    line-height: 1.3;
  }

  .rank-pill {
    min-width: 38px;
    height: 38px;
    padding: 0 8px;
    font-size: 20px;
  }
}

@media (max-width: 900px) {
  .page-shell {
    padding: 24px 12px;
  }

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

  .table-panel {
    padding: 18px;
    border-radius: 24px;
  }

  .table-toolbar {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "meta meta"
      "button formula";
    align-items: center;
    gap: 10px 12px;
  }

  .refresh-button {
    width: 100%;
  }

  .toolbar-meta {
    grid-area: meta;
    text-align: left;
  }

  .refresh-button {
    grid-area: button;
  }

  .toolbar-formula {
    grid-area: formula;
    text-align: right;
    white-space: normal;
    line-height: 1.35;
  }

  .ranking-table {
    min-width: 760px;
  }
}

@media (max-width: 560px) {
  body {
    background:
      linear-gradient(rgba(255, 246, 239, 0.08), rgba(255, 246, 239, 0.2)),
      url("/assets/mobile-title.jpg") center top / cover no-repeat fixed;
  }

  .board {
    gap: 18px;
  }

  .page-shell {
    align-items: flex-start;
    padding: 0 16px 98px;
  }

  .title-image {
    width: 100%;
  }

  .title-image-desktop {
    display: none;
  }

  .title-image-mobile {
    display: block;
    width: 100vw;
    max-width: none;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    border-radius: 0;
    filter: none;
  }

  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .summary-card {
    padding: 14px 8px;
    border-radius: 18px;
  }

  .summary-label {
    margin-bottom: 8px;
    font-size: 12px;
    line-height: 1.35;
  }

  .summary-value {
    font-size: 24px;
  }

  .table-panel {
    padding: 14px;
    border-radius: 20px;
  }

  .toolbar-meta {
    font-size: 13px;
  }

  .refresh-button {
    padding: 10px 18px;
    font-size: 14px;
    width: auto;
    min-width: 132px;
  }

  .table-toolbar {
    grid-template-columns: auto 1fr;
  }

  .toolbar-formula {
    font-size: 12px;
  }

  .table-wrap {
    overflow-x: visible;
  }

  .ranking-table,
  .ranking-table thead,
  .ranking-table tbody,
  .ranking-table tr,
  .ranking-table th,
  .ranking-table td {
    display: block;
    width: 100%;
  }

  .ranking-table {
    min-width: 0;
  }

  .ranking-table thead {
    display: none;
  }

  .ranking-table tbody {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .ranking-table tbody tr:not(.mobile-card-row) {
    padding: 14px;
    border-radius: 18px;
    background: rgba(255, 252, 247, 0.82);
    border: 1px solid rgba(180, 145, 114, 0.16);
    box-shadow: var(--shadow-light);
  }

  .ranking-table tbody td:not(.mobile-card-cell) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    text-align: left;
    font-size: 14px;
    border-top: none;
    background: transparent !important;
  }

  .ranking-table tbody td:not(.mobile-card-cell)::before {
    content: attr(data-label);
    flex: 0 0 78px;
    color: var(--ink-soft);
    font-size: 13px;
  }

  .ranking-table tbody td:not(.mobile-card-cell):first-child {
    padding-top: 0;
  }

  .ranking-table tbody td:not(.mobile-card-cell):last-child {
    padding-bottom: 0;
  }

  .ranking-table tbody td:not(.mobile-card-cell):first-child::before {
    content: "\6392\884c";
  }

  .program-name,
  .unit-name {
    min-width: 0;
  }

  .program-name,
  .unit-name,
  .votes-total {
    justify-content: flex-end;
    text-align: right;
  }

  .empty-row,
  .error-row {
    display: block !important;
    text-align: center !important;
    padding: 22px 10px !important;
  }

  .empty-row::before,
  .error-row::before {
    content: none !important;
  }

  .mobile-card-row {
    width: 100%;
  }

  .mobile-card-cell {
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
  }

  .mobile-rank-card {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 10px 12px;
    align-items: start;
    padding: 12px;
    border-radius: 18px;
    background: rgba(255, 252, 247, 0.9);
    border: 1px solid rgba(180, 145, 114, 0.16);
    box-shadow: var(--shadow-light);
  }

  .mobile-rank-badge {
    grid-row: 1 / span 2;
    width: 42px;
    min-width: 42px;
    height: 42px;
    padding: 0;
    font-size: 20px;
  }

  .mobile-card-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .mobile-info-row {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 10px;
  }

  .mobile-info-label {
    flex: 0 0 58px;
    color: var(--ink-soft);
    font-size: 13px;
    line-height: 1.35;
  }

  .mobile-info-value {
    flex: 1;
    text-align: left;
    font-size: 14px;
    line-height: 1.4;
    font-weight: 600;
    word-break: break-word;
  }

  .mobile-program-value,
  .mobile-unit-value {
    color: var(--ink-strong);
  }

  .mobile-votes-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding-top: 2px;
  }

  .mobile-vote-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 6px;
    border-radius: 14px;
    background: rgba(255, 247, 238, 0.9);
  }

  .mobile-vote-label {
    font-size: 12px;
    color: var(--ink-soft);
    line-height: 1.2;
  }

  .mobile-vote-value {
    font-size: 24px;
    line-height: 1;
    color: var(--ink-primary);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
  }

  .mobile-vote-total .mobile-vote-value {
    color: var(--gold);
  }

  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    align-items: center;
    padding: 10px 18px calc(10px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.96);
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    box-shadow: 0 -10px 30px rgba(94, 63, 34, 0.12);
    backdrop-filter: blur(12px);
    z-index: 20;
  }

  .mobile-nav-item {
    appearance: none;
    border: none;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: #b8afa4;
    padding: 4px 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
  }

  .mobile-nav-item.is-active {
    color: #d63122;
  }

  .mobile-nav-icon {
    width: 24px;
    height: 24px;
    display: block;
  }

  .mobile-nav-label {
    line-height: 1.2;
  }
}
