:root {
  color-scheme: dark;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --bg: #08090d;
  --panel: rgba(18, 21, 27, 0.82);
  --panel-strong: rgba(27, 30, 38, 0.94);
  --text: #f5efe7;
  --muted: rgba(245, 239, 231, 0.66);
  --gold: #d8b45b;
  --red: #c94a45;
  --blue: #5898d8;
  --green: #5bbd9b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% 12%, rgba(90, 170, 255, 0.36), transparent 30%),
    linear-gradient(135deg, #071443 0%, #120b35 52%, #070814 100%);
  color: var(--text);
}

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

button {
  border: 0;
}

.hidden {
  display: none !important;
}

.start-screen {
  align-items: center;
  display: grid;
  min-height: 100vh;
  overflow: hidden;
  place-items: center;
  position: relative;
  text-align: center;
  padding: 18px;
}

.start-content {
  position: relative;
  z-index: 2;
  width: min(100%, 1440px);
}

.poster-loading-panel {
  align-items: center;
  aspect-ratio: 16 / 9;
  background:
    linear-gradient(135deg, rgba(10, 26, 82, 0.72), rgba(16, 9, 48, 0.9)),
    radial-gradient(circle at 50% 22%, rgba(255, 221, 112, 0.16), transparent 26%);
  border: 1px solid rgba(255, 230, 168, 0.14);
  border-radius: 8px;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.62);
  color: rgba(245, 239, 231, 0.72);
  display: grid;
  font-size: 16px;
  font-weight: 800;
  inset: 0;
  justify-items: center;
  max-height: calc(100vh - 36px);
  opacity: 1;
  place-items: center;
  position: absolute;
  transition: opacity 220ms ease;
  width: 100%;
  z-index: 2;
}

.opening-poster {
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.62);
  display: block;
  height: auto;
  max-height: calc(100vh - 36px);
  object-fit: contain;
  opacity: 1;
  transition: opacity 220ms ease;
  width: 100%;
}

.start-content.poster-loading .opening-poster,
.start-content.poster-loading .poster-controls {
  opacity: 0;
}

.start-content.poster-loaded .poster-loading-panel {
  opacity: 0;
  pointer-events: none;
}

.start-content.poster-loaded .poster-controls {
  opacity: 1;
}

.poster-controls {
  bottom: clamp(18px, 4.4vw, 52px);
  display: grid;
  gap: 10px;
  justify-items: center;
  left: 50%;
  pointer-events: none;
  position: absolute;
  transform: translateX(-50%);
  transition: opacity 220ms ease;
  width: min(78%, 520px);
}

.name-field {
  display: grid;
  gap: 6px;
  margin: 0 auto;
  max-width: 300px;
  text-align: left;
  width: min(100%, 300px);
}

.name-field span {
  color: rgba(245, 239, 231, 0.74);
  font-size: 13px;
  font-weight: 900;
}

.name-field input {
  background: rgba(8, 9, 13, 0.68);
  border: 1px solid rgba(255, 221, 112, 0.48);
  border-radius: 8px;
  color: var(--text);
  min-height: 42px;
  outline: none;
  padding: 0 14px;
  pointer-events: auto;
}

.name-field input:focus {
  border-color: rgba(216, 180, 91, 0.82);
  box-shadow: 0 0 0 3px rgba(216, 180, 91, 0.18);
}

.primary-action {
  background: linear-gradient(135deg, #ffe17a, #ff9f2e);
  border-radius: 8px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.34);
  color: #171108;
  cursor: pointer;
  font-weight: 900;
  min-height: 48px;
  padding: 0 24px;
}

.secondary-action {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-weight: 900;
  min-height: 48px;
  padding: 0 22px;
}

.poster-start-button {
  background: linear-gradient(180deg, #fff58a 0%, #ffc32f 48%, #ff8d1d 100%);
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  box-shadow:
    0 8px 0 rgba(134, 62, 4, 0.8),
    0 18px 34px rgba(255, 181, 37, 0.48);
  color: #7b2f05;
  cursor: pointer;
  font-size: clamp(28px, 4.2vw, 54px);
  font-weight: 900;
  line-height: 1;
  min-height: clamp(62px, 8vw, 94px);
  padding: 0 clamp(34px, 7vw, 90px);
  pointer-events: auto;
  text-shadow:
    0 2px 0 rgba(255, 255, 255, 0.9),
    0 5px 8px rgba(122, 51, 0, 0.28);
  transform: scale(1);
  transition:
    box-shadow 180ms ease,
    filter 180ms ease,
    transform 180ms ease;
  will-change: transform;
}

.poster-start-button:hover {
  box-shadow:
    0 10px 0 rgba(134, 62, 4, 0.82),
    0 24px 42px rgba(255, 181, 37, 0.6);
  filter: brightness(1.08);
  transform: scale(1.08);
}

.poster-start-button:focus-visible {
  outline: 4px solid rgba(255, 255, 255, 0.86);
  outline-offset: 5px;
}

.poster-start-button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.45);
  opacity: 0.68;
}

.primary-action:disabled {
  cursor: not-allowed;
  filter: grayscale(0.65);
  opacity: 0.52;
}

.start-status {
  color: rgba(245, 239, 231, 0.78);
  font-size: 15px;
  font-weight: 700;
  min-height: 24px;
  margin: 16px 0 0;
}

.game-screen {
  margin: 0 auto;
  max-width: 1240px;
  min-height: 100vh;
  padding: 28px;
  position: relative;
  z-index: 1;
}

.game-screen::before {
  background:
    linear-gradient(180deg, rgba(8, 12, 28, 0.04), rgba(8, 12, 28, 0.16)),
    url("/static/assets/game-cartoon-background.webp") center / cover fixed;
  content: "";
  filter: saturate(1.08);
  inset: 0;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  pointer-events: none;
  position: fixed;
  z-index: -1;
}

.game-header {
  align-items: end;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow,
.phase-mark,
.role-card-kicker {
  color: var(--gold);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 8px;
}

.game-header h2 {
  font-size: clamp(34px, 5vw, 62px);
  line-height: 1;
  margin: 0;
}

.round-info {
  display: flex;
  gap: 10px;
}

.round-info span {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  color: var(--muted);
  padding: 8px 12px;
}

.table-area,
.phase-stage,
.event-log {
  background: rgba(13, 17, 26, 0.52);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 230, 168, 0.14);
  border-radius: 8px;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.34);
}

.table-area {
  padding: 16px;
}

.players {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(9, minmax(0, 1fr));
}

.player {
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  display: grid;
  justify-items: center;
  min-height: 164px;
  padding: 13px;
  text-align: center;
  transition: border-color 240ms ease, box-shadow 240ms ease, transform 240ms ease;
}

.player-avatar {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  display: block;
  height: 76px;
  margin-bottom: 10px;
  object-fit: contain;
  width: 76px;
}

.player-avatar-fallback {
  align-items: center;
  background:
    linear-gradient(135deg, rgba(255, 225, 122, 0.18), rgba(88, 152, 216, 0.16)),
    rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 230, 168, 0.22);
  color: var(--gold);
  display: grid;
  font-size: 30px;
  font-weight: 900;
  place-items: center;
}

.player.active-speaker {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(216, 180, 91, 0.16), 0 14px 38px rgba(216, 180, 91, 0.12);
  transform: translateY(-2px);
}

.player.dead {
  filter: grayscale(0.8);
  opacity: 0.5;
}

.player strong,
.player span {
  display: block;
}

.player strong {
  font-size: 16px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.player span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 7px;
}

.phase-stage {
  margin-top: 16px;
  min-height: 390px;
  overflow: hidden;
  position: relative;
}

.phase-panel {
  display: none;
  min-height: 390px;
  padding: 34px;
}

.phase-panel.active {
  display: grid;
  align-content: center;
  gap: 14px;
}

#phaseVoteResult.active {
  align-content: start;
}

.phase-panel h3 {
  font-size: clamp(34px, 5vw, 60px);
  line-height: 1;
  margin: 0;
}

.phase-panel p {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
  margin: 0;
  max-width: 760px;
}

#phaseVoteResult h3 {
  font-size: clamp(28px, 3.5vw, 42px);
}

#phaseVoteResult p {
  max-width: 640px;
}

#phaseVoteResult .primary-action {
  justify-self: start;
  margin-top: 8px;
}

.phase-mark.danger,
.role-card.werewolf .role-card-kicker,
.role-card.werewolf #roleCamp {
  color: var(--red);
}

.phase-mark.good,
.role-card.good .role-card-kicker,
.role-card.good #roleCamp {
  color: var(--blue);
}

.discussion-panel.active {
  align-content: stretch;
}

.speech-feed {
  display: grid;
  gap: 12px;
  max-height: 360px;
  overflow: auto;
  padding-right: 6px;
}

.vote-feed {
  display: grid;
  gap: 12px;
  max-height: 220px;
  overflow: auto;
  padding-right: 6px;
}

.speech-bubble {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  line-height: 1.7;
  padding: 13px 15px;
}

.speech-bubble strong {
  color: var(--gold);
  display: block;
  margin-bottom: 4px;
}

.thinking {
  color: rgba(216, 180, 91, 0.88);
  font-style: italic;
}

.human-speech {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

textarea,
select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: var(--text);
  padding: 12px;
}

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

.vote-box {
  display: flex;
  gap: 10px;
  max-width: 520px;
}

.vote-box select {
  flex: 1;
}

.choice-box {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  max-width: 560px;
}

.choice-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.choice-card {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  min-height: 52px;
  padding: 12px;
  text-align: left;
}

.choice-card:hover {
  border-color: var(--gold);
}

.status-line {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.event-log {
  margin-top: 16px;
  padding: 18px;
}

.event-log h3 {
  margin: 0 0 12px;
}

#events {
  display: grid;
  gap: 8px;
}

.event {
  color: rgba(245, 239, 231, 0.72);
  line-height: 1.6;
}

.modal {
  align-items: center;
  background: rgba(0, 0, 0, 0.68);
  display: grid;
  inset: 0;
  padding: 24px;
  place-items: center;
  position: fixed;
  z-index: 20;
}

.role-card {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent),
    var(--panel-strong);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  box-shadow: 0 30px 110px rgba(0, 0, 0, 0.72);
  max-width: 520px;
  padding: 34px;
  text-align: center;
  width: min(100%, 520px);
}

.name-card {
  background:
    linear-gradient(135deg, rgba(255, 225, 122, 0.12), transparent 44%),
    var(--panel-strong);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  box-shadow: 0 30px 110px rgba(0, 0, 0, 0.72);
  display: grid;
  gap: 18px;
  max-width: 440px;
  padding: 32px;
  text-align: left;
  width: min(100%, 440px);
}

.name-card h2 {
  font-size: clamp(34px, 6vw, 56px);
  line-height: 1;
  margin: 0;
}

.name-card .name-field {
  max-width: none;
  width: 100%;
}

.name-card .name-field input {
  background: rgba(8, 9, 13, 0.72);
}

.name-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(92px, 0.6fr) minmax(0, 1fr);
}

.name-status {
  color: rgba(245, 239, 231, 0.78);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
  margin: -4px 0 0;
  min-height: 22px;
}

.seer-reveal-card {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent),
    var(--panel-strong);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  box-shadow: 0 30px 110px rgba(0, 0, 0, 0.72);
  max-width: 560px;
  padding: 34px;
  text-align: center;
  width: min(100%, 560px);
}

.seer-reveal-card h2 {
  color: var(--blue);
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.08;
  margin: 0 0 18px;
}

.seer-reveal-card p {
  color: var(--text);
  font-size: 20px;
  line-height: 1.6;
  margin: 0 0 22px;
}

.role-card h2 {
  font-size: clamp(44px, 9vw, 86px);
  line-height: 1;
  margin: 0 0 18px;
}

.role-card.werewolf h2 {
  color: var(--red);
}

.role-card.good h2 {
  color: var(--blue);
}

.role-details {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 18px;
}

.role-details span {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 8px 13px;
}

#roleHint {
  color: var(--muted);
  line-height: 1.7;
  margin: 0 0 22px;
}

.role-teammates {
  color: var(--text);
  font-weight: 800;
  line-height: 1.6;
  margin: 0 0 14px;
}

.fog-transition {
  inset: 0;
  opacity: 0;
  pointer-events: none;
  position: fixed;
  transition: opacity 900ms ease;
  z-index: 30;
}

.fog-transition::before,
.fog-transition::after {
  animation: fogDrift 8s linear infinite;
  background:
    radial-gradient(circle at 18% 44%, rgba(255, 255, 255, 0.22), transparent 18%),
    radial-gradient(circle at 42% 54%, rgba(255, 255, 255, 0.18), transparent 22%),
    radial-gradient(circle at 68% 42%, rgba(255, 255, 255, 0.2), transparent 20%),
    radial-gradient(circle at 86% 58%, rgba(255, 255, 255, 0.16), transparent 18%),
    rgba(5, 7, 11, 0.78);
  content: "";
  filter: blur(18px);
  inset: -18%;
  position: absolute;
  transform: translateX(-5%) scale(1.08);
}

.fog-transition::after {
  animation-duration: 12s;
  animation-direction: reverse;
  opacity: 0.72;
  transform: translateX(5%) scale(1.14);
}

.fog-transition.active {
  opacity: 1;
  pointer-events: auto;
}

@keyframes fogDrift {
  0% {
    transform: translate3d(-8%, 1%, 0) scale(1.08);
  }
  50% {
    transform: translate3d(8%, -2%, 0) scale(1.18);
  }
  100% {
    transform: translate3d(-8%, 1%, 0) scale(1.08);
  }
}

@media (max-width: 980px) {
  .players {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .game-screen {
    padding: 18px;
  }

  .game-header,
  .vote-box,
  .role-details {
    align-items: stretch;
    flex-direction: column;
  }

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

  .start-screen {
    padding: 10px;
  }

  .poster-controls {
    bottom: 16px;
    width: min(86%, 360px);
  }

  .name-field {
    max-width: 230px;
  }

  .name-field input {
    min-height: 38px;
  }

  .name-card {
    padding: 24px;
  }

  .name-actions {
    grid-template-columns: 1fr;
  }

  .poster-start-button {
    min-height: 58px;
    padding: 0 34px;
  }

  .phase-panel {
    padding: 24px;
  }
}
