:root {
  --bg: #05080d;
  --panel: rgba(8, 18, 28, 0.72);
  --line: rgba(86, 255, 214, 0.28);
  --jade: #3dffc8;
  --jade-dim: #167a62;
  --gold: #f4cf6a;
  --gold-dim: #8a6b1d;
  --red: #ff6b6b;
  --ink: #d7efe8;
  --muted: #7f9b96;
  --shadow: 0 0 24px rgba(61, 255, 200, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
  min-height: 100dvh;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

#bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 15% 20%, rgba(61, 255, 200, 0.12), transparent 28%),
    radial-gradient(circle at 85% 80%, rgba(244, 207, 106, 0.1), transparent 24%),
    linear-gradient(180deg, #071018 0%, #05080d 100%);
}

#bg canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.scanlines,
.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.scanlines {
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.025),
    rgba(255, 255, 255, 0.025) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
}

.vignette {
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.72);
}

.app {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: calc(10px + env(safe-area-inset-top)) 14px calc(10px + env(safe-area-inset-bottom));
  gap: 10px;
}

.topbar,
.panel,
.nav button,
.card,
.member,
.award,
.speaker-card,
.winner-chip,
.prize-card {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(10px);
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 14px;
}

.seal {
  width: 42px;
  height: 42px;
  border: 1px solid var(--gold);
  color: var(--gold);
  display: grid;
  place-items: center;
  font-family: "Ma Shan Zheng", "STKaiti", serif;
  font-size: 22px;
  box-shadow: 0 0 16px rgba(244, 207, 106, 0.25);
}

.brand h1 {
  margin: 0;
  font-family: "ZCOOL XiaoWei", "STSong", serif;
  font-size: clamp(18px, 3.2vw, 28px);
  letter-spacing: 0.12em;
  color: #f7f3df;
}

.brand p {
  margin: 2px 0 0;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.28em;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav button {
  appearance: none;
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: left;
  letter-spacing: 0.16em;
  transition: 0.2s ease;
}

.nav button.active,
.nav button:hover {
  color: #06110e;
  background: linear-gradient(90deg, var(--jade), #9cff87);
  box-shadow: var(--shadow);
}

.stage {
  min-height: 0;
  border-radius: 16px;
  padding: 10px;
  overflow: hidden;
}

.view {
  display: none;
  height: 100%;
  min-height: 0;
}

.view.active {
  display: grid;
}

#view-lottery {
  grid-template-columns: 210px 1fr 220px;
  gap: 10px;
}

.prize-list,
.winner-list,
.side-block,
.roll-board,
.form-grid,
.vote-grid,
.award-grid,
.roster-layout {
  min-height: 0;
}

.prize-card,
.card {
  border-radius: 12px;
  padding: 10px;
}

.prize-card {
  width: 100%;
  text-align: left;
  color: inherit;
  margin-bottom: 6px;
}

.prize-card small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.prize-card b {
  color: var(--gold);
}

.roll-board {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
}

.roll-window {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(244, 207, 106, 0.45);
  background:
    linear-gradient(180deg, rgba(244, 207, 106, 0.08), transparent 18%),
    linear-gradient(180deg, #07141a, #0a1c1a);
  box-shadow: inset 0 0 40px rgba(61, 255, 200, 0.08), 0 0 24px rgba(244, 207, 106, 0.12);
}

.roll-window::before,
.roll-window::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  height: 1px;
  background: rgba(244, 207, 106, 0.5);
  z-index: 2;
}

.roll-window::before { top: 33%; }
.roll-window::after { top: 67%; }

.roll-track {
  display: flex;
  flex-direction: column;
  will-change: transform;
}

.roll-item {
  height: 72px;
  display: grid;
  place-items: center;
  font-family: "ZCOOL XiaoWei", "STSong", serif;
  font-size: clamp(28px, 5vw, 48px);
  letter-spacing: 0.18em;
}

.roll-item.can-win,
.roll-item.blocked {
  color: #7dffa8 !important;
  text-shadow: 0 0 16px rgba(125, 255, 168, 0.55);
}

.roll-item.winner {
  color: var(--gold) !important;
  opacity: 1;
  text-shadow: 0 0 18px rgba(244, 207, 106, 0.65);
}

.roll-meta,
.hint {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(61, 255, 200, 0.08);
  color: var(--jade);
  border-radius: 999px;
  padding: 10px 16px;
  letter-spacing: 0.16em;
}

.btn.gold {
  color: #1b1405;
  background: linear-gradient(90deg, #f8de8a, #d7a73a);
  border-color: #f4cf6a;
}

.btn.danger {
  color: var(--red);
  border-color: rgba(255, 107, 107, 0.4);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.winner-chip,
.speaker-chip,
.member {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  margin-bottom: 6px;
}

.member.can-share strong {
  color: var(--jade);
}

.member.no-share strong {
  color: #5c6570;
  opacity: 0.55;
}

.scroll {
  overflow: auto;
  height: 100%;
  padding-right: 4px;
}

#view-speakers {
  grid-template-columns: 280px 1fr;
  gap: 10px;
}

.form-grid input,
.form-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(4, 10, 14, 0.7);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}

.speaker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.speaker-card {
  border-radius: 14px;
  padding: 12px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.speaker-card.sharing {
  border-color: var(--gold);
  box-shadow: 0 0 18px rgba(244, 207, 106, 0.22);
}

.speaker-card h3 {
  margin: 6px 0 0;
  font-size: 22px;
  letter-spacing: 0.12em;
  color: #8fa3a8;
}

.speaker-card.sharing h3 {
  color: var(--gold);
  text-shadow: 0 0 16px rgba(244, 207, 106, 0.45);
}

.card-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-actions .btn {
  width: 100%;
  text-align: center;
}

#view-share {
  grid-template-columns: 1fr;
}

.share-stage {
  height: 100%;
  min-height: 280px;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 16px;
  padding: 20px;
  border-radius: 18px;
  border: 1px solid rgba(244, 207, 106, 0.35);
  background:
    radial-gradient(circle at 50% 30%, rgba(244, 207, 106, 0.12), transparent 42%),
    linear-gradient(180deg, #07141a, #0a1c1a);
}

.share-topic {
  color: var(--gold);
  letter-spacing: 0.28em;
  font-size: clamp(16px, 2.4vw, 28px);
}

.share-name {
  font-family: "ZCOOL XiaoWei", "STSong", serif;
  font-size: clamp(48px, 9vw, 108px);
  letter-spacing: 0.22em;
  color: #f7f3df;
  text-shadow: 0 0 28px rgba(244, 207, 106, 0.45);
}

.share-name.idle {
  color: #6f8890;
  text-shadow: none;
}

.share-sub {
  color: var(--jade);
  letter-spacing: 0.24em;
}

.tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--gold);
  border: 1px solid rgba(244, 207, 106, 0.35);
}

.tag.blocked {
  color: var(--red);
  border-color: rgba(255, 107, 107, 0.4);
}

#view-vote {
  grid-template-rows: auto 1fr;
  gap: 8px;
}

.vote-top {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: stretch;
}

.qr-panel {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 280px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.qr-panel b {
  color: var(--gold);
  letter-spacing: 0.16em;
}

#vote-qr {
  width: 132px;
  height: 132px;
  padding: 6px;
  background: #f4fff9;
  border-radius: 10px;
  flex: 0 0 auto;
}

#vote-qr svg,
#vote-qr img {
  width: 100%;
  height: 100%;
  display: block;
}

#vote-url {
  display: block;
  margin-top: 6px;
  color: var(--jade);
  font-size: 12px;
  word-break: break-all;
}

.vote-page,
.vote-page body {
  overflow: auto;
}

.vote-app {
  height: auto;
  min-height: 100dvh;
}

.vote-mobile {
  overflow: auto;
}

.vote-mobile .vote-grid {
  grid-template-columns: 1fr;
}

.vote-mobile .prize-legend {
  grid-template-columns: 1fr 1fr;
}

body.vote-page,
body.stage-page {
  overflow: auto;
  height: auto;
}

.fullscreen-share {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  border: 0;
  border-radius: 0;
}

.vote-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.vote-card {
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.vote-card .count {
  font-family: "Share Tech Mono", monospace;
  font-size: 28px;
  color: var(--jade);
}

.vote-card .count small {
  margin-left: 4px;
  font-size: 12px;
  letter-spacing: 0.12em;
}

.vote-card.display-only {
  pointer-events: none;
}

#view-vote .vote-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.prize-legend {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

.prize-legend .card {
  padding: 8px 10px;
}

.prize-legend b {
  color: var(--gold);
  letter-spacing: 0.12em;
}

.prize-legend span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

input[type="file"] {
  color: var(--muted);
  max-width: 220px;
}

#view-awards {
  grid-template-columns: 1fr;
}

.award {
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 8px;
}

.award h3 {
  margin: 0 0 6px;
  color: var(--gold);
}

#view-roster {
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.roster-layout textarea {
  min-height: 140px;
  resize: none;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9;
  padding: 10px 14px;
  border-radius: 10px;
  background: #10241f;
  border: 1px solid var(--jade);
  color: var(--jade);
  opacity: 0;
  transform: translateY(8px);
  transition: 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.empty {
  color: var(--muted);
  letter-spacing: 0.12em;
  padding: 20px 0;
}

@media (min-width: 960px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .app {
    height: 100dvh;
    min-height: 0;
    max-width: 1680px;
    margin: 0 auto;
    padding: 16px 22px;
  }

  .workspace {
    grid-template-columns: 110px 1fr;
  }

  .nav button {
    padding: 14px 12px;
  }

  .roll-item {
    height: 88px;
    font-size: clamp(36px, 4.4vw, 64px);
  }
}

@media (max-width: 959px) {
  .vote-top {
    grid-template-columns: 1fr;
  }

  #view-vote .vote-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app {
    height: auto;
    overflow: visible;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .nav {
    flex-direction: row;
    overflow-x: auto;
  }

  .nav button {
    flex: 1 0 auto;
    text-align: center;
    padding: 12px 14px;
    min-height: 44px;
    white-space: nowrap;
  }

  .topbar {
    grid-template-columns: auto 1fr;
    gap: 8px;
  }

  #view-lottery,
  #view-speakers,
  #view-awards,
  #view-roster {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  #view-lottery {
    grid-template-rows: auto minmax(220px, 42vh) auto;
  }

  #prize-list,
  #winner-list {
    display: flex;
    gap: 8px;
    height: auto;
    overflow: auto;
  }

  #prize-list .prize-card,
  #winner-list .winner-chip {
    min-width: 168px;
    margin-bottom: 0;
  }

  .prize-legend {
    grid-template-columns: 1fr 1fr;
  }

  .roster-layout textarea {
    min-height: 180px;
  }

  .scroll {
    height: auto;
    max-height: none;
  }

  #view-vote .vote-grid,
  #view-speakers .speaker-grid,
  #award-vote,
  #member-list {
    max-height: 70vh;
    overflow: auto;
  }
}

@media (max-width: 959px) and (orientation: landscape) {
  .app {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  .brand p {
    display: none;
  }

  .topbar {
    grid-template-columns: auto 1fr;
  }

  #view-lottery {
    grid-template-columns: 180px 1fr 180px;
    grid-template-rows: 1fr;
  }

  #prize-list,
  #winner-list {
    display: block;
    height: 100%;
  }

  #prize-list .prize-card,
  #winner-list .winner-chip {
    min-width: 0;
    margin-bottom: 6px;
  }

  .roll-item {
    height: 52px;
    font-size: 26px;
  }

  .scroll {
    height: 100%;
  }
}

@media (min-width: 960px) and (max-width: 1180px) {
  #view-lottery {
    grid-template-columns: 200px 1fr 200px;
  }

  #view-speakers {
    grid-template-columns: 240px 1fr;
  }
}

@media (max-height: 420px) {
  .roll-item {
    height: 52px;
    font-size: 26px;
  }

  .topbar,
  .stage {
    padding: 6px 8px;
  }
}
