:root {
  color-scheme: dark;
  --bg: #101210;
  --bg-2: #171915;
  --panel: rgba(24, 26, 22, 0.74);
  --panel-strong: rgba(28, 30, 25, 0.9);
  --line: rgba(234, 226, 205, 0.16);
  --line-strong: rgba(234, 226, 205, 0.28);
  --text: #f3eee2;
  --muted: #a9a291;
  --faint: #746f63;
  --gold: #d4ad64;
  --gold-2: #f0d08b;
  --green: #73c78c;
  --danger: #e46f62;
  --shadow: 0 22px 80px rgba(0, 0, 0, 0.45);
  --radius: 8px;
  --side-width: clamp(238px, 18vw, 314px);
  --dock-height: clamp(104px, 15vh, 154px);
  --topbar-height: 86px;
  --font-ui: Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --font-display: "Songti SC", "Noto Serif SC", "STSong", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 22% 12%, rgba(212, 173, 100, 0.09), transparent 27%),
    linear-gradient(135deg, #0c0e0c 0%, #151712 48%, #0f1110 100%);
  color: var(--text);
  font-family: var(--font-ui);
  overflow-x: hidden;
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-rows: var(--topbar-height) minmax(0, 1fr) var(--dock-height);
  width: 100%;
  height: 100dvh;
  padding: 18px;
  gap: 14px;
  overflow: hidden;
}

.app-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
}

.topbar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: clamp(26px, 3vw, 42px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}

.brand-mark {
  width: 14px;
  height: 42px;
  border: 1px solid rgba(212, 173, 100, 0.56);
  background:
    linear-gradient(to bottom, transparent 0 16%, rgba(212, 173, 100, 0.72) 16% 18%, transparent 18% 82%, rgba(212, 173, 100, 0.72) 82% 84%, transparent 84%),
    rgba(212, 173, 100, 0.08);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  min-width: 0;
}

.total-votes {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.total-votes strong {
  color: var(--gold-2);
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
}

.select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(16, 18, 16, 0.66);
  color: var(--muted);
  white-space: nowrap;
}

.select-wrap span {
  font-size: 13px;
}

.select-wrap select {
  appearance: none;
  min-width: 118px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
}

.icon-button,
.dock-arrow,
.nav-arrow {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: rgba(19, 21, 18, 0.72);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.icon-button {
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
}

.gallery {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: var(--side-width) minmax(0, 1fr) var(--side-width);
  gap: 14px;
  min-height: 0;
}

.info-panel,
.rank-panel {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.info-panel {
  display: flex;
  flex-direction: column;
  padding: clamp(20px, 2vw, 28px);
}

.work-index {
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.04em;
}

.info-panel h1 {
  margin: clamp(24px, 4vh, 44px) 0 14px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(27px, 2.5vw, 37px);
  font-weight: 700;
  line-height: 1.16;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.artist-line {
  display: none;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
}

.meta-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px 14px;
  margin: 22px 0;
  padding: 20px 0;
  border-block: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.meta-grid strong {
  min-width: 0;
  color: var(--text);
  font-weight: 500;
  overflow-wrap: anywhere;
}

#artDescription {
  margin: 0;
  color: #c6bfad;
  font-size: 16px;
  line-height: 1.82;
}

.vote-area {
  display: grid;
  gap: 14px;
  margin-top: auto;
  padding-top: 24px;
}

.vote-button,
.ghost-button {
  min-height: 58px;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 650;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.vote-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1px solid rgba(240, 208, 139, 0.54);
  background: linear-gradient(135deg, #c79d50, #9c7130);
  color: #fff8e8;
  box-shadow: 0 14px 34px rgba(170, 125, 54, 0.24);
}

.vote-button svg {
  font-size: 23px;
  fill: currentColor;
  stroke-width: 1.6;
}

.vote-button.is-voted {
  border-color: rgba(115, 199, 140, 0.52);
  background: linear-gradient(135deg, #2a7b4c, #1b5335);
  box-shadow: 0 14px 34px rgba(67, 148, 94, 0.19);
}

.ghost-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
}

.ghost-button[hidden] {
  display: none;
}

.current-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding: 16px;
  border: 1px solid rgba(212, 173, 100, 0.22);
  border-radius: var(--radius);
  background: rgba(212, 173, 100, 0.06);
  color: var(--muted);
}

.current-score strong {
  color: var(--gold-2);
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1;
}

.stage-section {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
}

.art-stage {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(234, 226, 205, 0.22);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.018), transparent 18%, transparent 82%, rgba(255, 255, 255, 0.018)),
    #0b0c0b;
  box-shadow: var(--shadow);
}

.image-frame {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: clamp(8px, 1.7vmin, 20px);
}

#artImage {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  object-fit: contain;
  border-radius: 2px;
  background: #ece6d8;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.22),
    0 18px 48px rgba(0, 0, 0, 0.48);
}

.is-portrait #artImage,
.is-square #artImage {
  max-height: 100%;
}

.is-landscape #artImage {
  max-width: 100%;
}

#imageCaption {
  display: none;
}

.nav-arrow {
  position: absolute;
  top: 50%;
  z-index: 5;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  color: var(--text);
  background: rgba(27, 28, 25, 0.72);
  transform: translateY(-50%);
  backdrop-filter: blur(12px);
}

.nav-prev {
  left: 14px;
}

.nav-next {
  right: 14px;
}

.rank-panel {
  display: flex;
  flex-direction: column;
  padding: 22px;
  overflow: hidden;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--text);
  font-size: 18px;
  font-weight: 650;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--faint);
  font-size: 13px;
}

.rank-list {
  display: grid;
  gap: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  list-style: none;
  scrollbar-width: thin;
}

.rank-item {
  display: grid;
  grid-template-columns: 34px 62px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.rank-item button {
  display: contents;
  color: inherit;
}

.rank-number {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 21px;
  text-align: center;
}

.rank-item:nth-child(-n + 3) .rank-number {
  color: var(--gold-2);
}

.rank-thumb {
  width: 62px;
  height: 48px;
  object-fit: cover;
  border: 1px solid rgba(234, 226, 205, 0.18);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.04);
}

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

.rank-title {
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-votes {
  margin-top: 4px;
  color: var(--gold-2);
  font-size: 15px;
}

.rank-votes span {
  color: var(--faint);
  font-size: 12px;
}

.thumb-dock {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 8px;
  min-height: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(17, 19, 17, 0.8);
  box-shadow: 0 16px 54px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(16px);
}

.dock-arrow {
  width: 38px;
  height: 100%;
  min-height: 76px;
  border: 0;
  background: transparent;
  color: var(--text);
}

.thumb-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: clamp(82px, 8.2vw, 128px);
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-behavior: smooth;
  scrollbar-width: none;
  padding: 12px 0;
}

.thumb-track:focus-visible {
  outline: 1px solid rgba(240, 208, 139, 0.48);
  outline-offset: -3px;
}

.thumb-track::-webkit-scrollbar {
  display: none;
}

.thumb-button {
  position: relative;
  display: block;
  width: 100%;
  height: clamp(74px, 11vh, 118px);
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(234, 226, 205, 0.14);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.045);
}

.thumb-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-button.is-active {
  border-color: var(--gold-2);
  box-shadow: 0 0 0 2px rgba(240, 208, 139, 0.16);
}

.thumb-button.is-voted::after {
  content: "";
  position: absolute;
  right: 7px;
  top: 7px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 2px rgba(16, 18, 16, 0.85);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 32px));
  padding: 13px 18px;
  border: 1px solid rgba(234, 226, 205, 0.22);
  border-radius: var(--radius);
  background: rgba(20, 22, 19, 0.92);
  color: var(--text);
  box-shadow: var(--shadow);
  transform: translate(-50%, 24px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

button:hover,
button:focus-visible,
select:focus-visible {
  border-color: rgba(240, 208, 139, 0.6);
  outline: none;
}

.vote-button:hover,
.ghost-button:hover,
.icon-button:hover,
.nav-arrow:hover {
  transform: translateY(-1px);
}

.nav-arrow:hover {
  transform: translateY(-50%) scale(1.04);
}

@media (max-width: 1180px) {
  :root {
    --side-width: 244px;
  }

  .app-shell {
    --topbar-height: auto;
    grid-template-rows: auto minmax(0, 1fr) var(--dock-height);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-height: 760px) and (min-width: 1081px) {
  :root {
    --topbar-height: 68px;
    --dock-height: 92px;
  }

  .app-shell {
    padding: 14px 18px;
    gap: 10px;
  }

  .brand {
    font-size: 34px;
  }

  .brand-mark {
    height: 34px;
  }

  .topbar-actions {
    gap: 10px;
  }

  .select-wrap {
    height: 42px;
  }

  .icon-button {
    width: 42px;
    height: 42px;
  }

  .info-panel,
  .rank-panel {
    padding: 18px;
  }

  .info-panel h1 {
    margin: 16px 0 8px;
    font-size: 30px;
  }

  .artist-line,
  #artDescription {
    font-size: 15px;
  }

  #artDescription {
    display: -webkit-box;
    overflow: hidden;
    line-height: 1.58;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }

  .meta-grid {
    gap: 7px 12px;
    margin: 13px 0;
    padding: 13px 0;
  }

  .vote-area {
    gap: 8px;
    padding-top: 12px;
  }

  .vote-button,
  .ghost-button {
    min-height: 48px;
    font-size: 15px;
  }

  .current-score {
    margin-top: 8px;
    padding: 10px 12px;
  }

  .current-score strong {
    font-size: 28px;
  }

  .thumb-track {
    padding: 8px 0;
  }

  .thumb-button {
    height: 76px;
  }
}

@media (max-width: 1080px) {
  .app-shell {
    height: auto;
    min-height: 100svh;
    overflow: visible;
  }

  .gallery {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(52vh, 1fr) auto auto;
  }

  .stage-section {
    order: 1;
  }

  .info-panel {
    order: 2;
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
    gap: 12px 24px;
  }

  .info-panel h1,
  .artist-line,
  .work-index,
  #artDescription,
  .meta-grid {
    grid-column: 1;
  }

  .vote-area,
  .current-score {
    grid-column: 2;
  }

  .vote-area {
    align-self: end;
    padding-top: 0;
  }

  .rank-panel {
    order: 3;
    max-height: 280px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    min-height: 100svh;
    padding: 12px;
    gap: 10px;
  }

  .brand {
    font-size: 28px;
  }

  .brand-mark {
    display: none;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 44px;
    gap: 8px;
  }

  .total-votes {
    grid-column: 1 / -1;
  }

  .select-wrap {
    width: 100%;
    height: 42px;
    justify-content: space-between;
    padding: 0 10px;
  }

  .select-wrap select {
    min-width: 0;
    max-width: 110px;
    font-size: 14px;
  }

  .icon-button {
    width: 44px;
    height: 42px;
  }

  .gallery {
    grid-template-rows: minmax(46vh, 58vh) auto auto;
    gap: 10px;
  }

  .image-frame {
    padding: 6px;
  }

  #imageCaption {
    display: none;
  }

  .nav-arrow {
    width: 42px;
    height: 42px;
  }

  .nav-prev {
    left: 8px;
  }

  .nav-next {
    right: 8px;
  }

  .info-panel {
    display: flex;
    padding: 16px;
  }

  .info-panel h1 {
    margin: 12px 0 8px;
    font-size: 25px;
  }

  .artist-line,
  #artDescription {
    font-size: 14px;
  }

  .meta-grid {
    margin: 12px 0;
    padding: 12px 0;
  }

  .vote-area {
    padding-top: 12px;
  }

  .vote-button,
  .ghost-button {
    min-height: 50px;
    font-size: 15px;
  }

  .rank-panel {
    padding: 16px;
  }

  .rank-list {
    max-height: 220px;
  }

  .thumb-dock {
    grid-template-columns: 30px minmax(0, 1fr) 30px;
  }

  .dock-arrow {
    width: 30px;
    min-height: 66px;
  }

  .thumb-track {
    grid-auto-columns: 76px;
    gap: 8px;
    padding: 8px 0;
  }

  .thumb-button {
    height: 64px;
  }
}

@media (max-width: 430px) {
  .topbar-actions {
    grid-template-columns: 1fr 44px;
  }

  .select-wrap:nth-of-type(2) {
    grid-column: 1 / -1;
  }

  .brand {
    white-space: normal;
    line-height: 1.1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
