:root {
  color-scheme: light;
  --ink: #1d1b16;
  --muted: #756f64;
  --paper: #fffaf0;
  --panel: #fffef9;
  --line: #e5d5bb;
  --copper: #c85f2a;
  --gold: #f1b840;
  --green: #4f8f34;
  --teal: #2d8b8a;
  --blue: #246db7;
  --rose: #cf3f5f;
  --night: #172127;
  --shadow: 0 24px 80px rgb(63 43 16 / 22%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  color: var(--ink);
  font-family:
    Inter, "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background:
    radial-gradient(circle at 18% 18%, rgb(46 139 138 / 58%), transparent 28%),
    radial-gradient(circle at 84% 22%, rgb(207 63 95 / 38%), transparent 26%),
    linear-gradient(120deg, #10181e 0%, #213523 45%, #161b2a 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  color: white;
  background: var(--copper);
  cursor: pointer;
  box-shadow: 0 8px 20px rgb(200 95 42 / 22%);
}

button.secondary {
  color: var(--ink);
  background: #eee3d0;
  box-shadow: none;
}

.shell {
  display: grid;
  grid-template-columns: minmax(720px, 1fr) 320px;
  gap: 18px;
  align-items: center;
  min-height: 100vh;
  padding: 16px;
}

.stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: calc(100vh - 32px);
}

.ambient-word {
  position: absolute;
  color: rgb(255 255 255 / 70%);
  font-weight: 700;
  text-shadow: 0 2px 12px rgb(0 0 0 / 40%);
}

.word-a {
  top: 16%;
  left: 17%;
}

.word-b {
  top: 14%;
  right: 20%;
}

.word-c {
  top: 27%;
  left: 24%;
}

.word-d {
  top: 28%;
  right: 16%;
}

.word-e {
  bottom: 18%;
  right: 22%;
}

.game-card {
  position: relative;
  width: min(94vw, 720px);
  min-height: 92vh;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 2px 6px 10px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  color: var(--copper);
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1;
  text-shadow: 0 2px 0 #ffd27c;
}

h2 {
  margin: 0 0 10px;
  font-size: 19px;
}

.round-pill {
  min-width: 76px;
  border: 1px solid #eacb92;
  border-radius: 999px;
  padding: 8px 12px;
  color: #87411d;
  font-weight: 900;
  text-align: center;
  background: #fff4dc;
}

.round-stack {
  display: grid;
  gap: 5px;
  justify-items: end;
}

#roundStatus {
  border-radius: 999px;
  padding: 4px 10px;
  color: white;
  font-size: 12px;
  font-weight: 1000;
  background: linear-gradient(90deg, var(--teal), var(--blue));
}

.live-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.live-strip div {
  min-width: 0;
  border: 1px solid #e9d4ad;
  border-radius: 8px;
  padding: 8px 10px;
  background: linear-gradient(180deg, #fffef8, #fff0d8);
}

.live-strip span,
.spotlight-card span,
.settlement-panel span {
  display: block;
  color: #8b7556;
  font-size: 11px;
  font-weight: 1000;
}

.live-strip strong {
  display: block;
  overflow: hidden;
  color: #2f3429;
  font-size: 16px;
  font-weight: 1000;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.answer-panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px 12px;
  background: linear-gradient(180deg, #fffefa, #fff2df);
}

.answer-panel.urgent {
  border-color: #d74b2d;
  box-shadow: 0 0 0 3px rgb(215 75 45 / 12%);
}

.timer {
  display: grid;
  gap: 8px;
  align-items: center;
  grid-template-columns: 80px 1fr;
}

#timerText {
  color: #8c1f0e;
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
}

.timer-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #ded5c8;
}

#timerBar {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--copper), var(--gold), var(--green));
  transition: width 220ms ease;
}

.answer-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 9px;
}

.answer-meta strong {
  color: #a63218;
  font-size: 28px;
}

.answer-meta span {
  border: 1px solid #e6c7a3;
  border-radius: 999px;
  padding: 5px 12px;
  color: #8a4b24;
  font-weight: 800;
  background: #fff8ed;
}

.prompt {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.spotlight-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  border: 1px solid #d6b881;
  border-radius: 8px;
  padding: 10px 12px;
  background:
    linear-gradient(90deg, rgb(36 109 183 / 12%), transparent 42%),
    #fffdf6;
}

.spotlight-card strong {
  display: block;
  color: #18535a;
  font-size: 25px;
  font-weight: 1000;
  line-height: 1;
}

.spotlight-card p {
  max-width: 280px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  text-align: right;
}

.reveal-banner {
  position: absolute;
  z-index: 5;
  top: 118px;
  left: 50%;
  min-width: 260px;
  max-width: calc(100% - 42px);
  transform: translateX(-50%) translateY(-10px);
  border: 2px solid #ffd37a;
  border-radius: 8px;
  padding: 12px 20px;
  opacity: 0;
  color: #8b270f;
  font-size: 28px;
  font-weight: 1000;
  text-align: center;
  pointer-events: none;
  background: linear-gradient(180deg, #fff7dc, #ffd9a0);
  box-shadow: 0 14px 34px rgb(116 63 16 / 26%);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.reveal-banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.reveal-banner.pulse {
  animation: reveal-pop 460ms ease;
}

.effect-layer {
  position: absolute;
  z-index: 6;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.effect-burst {
  position: absolute;
  top: 42%;
  left: calc(50% + var(--offset-x, 0px));
  min-width: 220px;
  transform: translate(-50%, -50%);
  border: 2px solid rgb(255 255 255 / 64%);
  border-radius: 8px;
  padding: 10px 16px;
  color: white;
  font-size: 22px;
  font-weight: 1000;
  text-align: center;
  text-shadow: 0 2px 4px rgb(0 0 0 / 28%);
  box-shadow: 0 18px 42px rgb(32 25 14 / 30%);
  animation: effect-rise 1500ms ease forwards;
}

.effect-burst.gift {
  background: linear-gradient(135deg, #d53b25, #f3b83d);
}

.effect-burst.like {
  background: linear-gradient(135deg, #cf3f5f, #f58aa4);
}

.effect-burst.follow {
  background: linear-gradient(135deg, #246db7, #2d8b8a);
}

.effect-burst.clue {
  background: linear-gradient(135deg, #18535a, #f1b840);
}

.effect-burst.hit {
  background: linear-gradient(135deg, #8c1f0e, #f1b840);
}

.effect-burst.answer {
  background: linear-gradient(135deg, #8f4dc6, #2d8b8a);
}

.hit-modal {
  position: absolute;
  z-index: 8;
  top: 50%;
  left: 50%;
  width: min(480px, calc(100% - 48px));
  border: 3px solid #ffd37a;
  border-radius: 8px;
  padding: 20px 24px;
  opacity: 0;
  color: white;
  text-align: center;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgb(140 31 14 / 92%), rgb(200 95 42 / 92%)),
    #8c1f0e;
  box-shadow: 0 24px 70px rgb(70 20 8 / 42%);
  transform: translate(-50%, -50%) scale(0.86);
  transition:
    opacity 160ms ease,
    transform 180ms ease;
}

.hit-modal.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  animation: hit-shine 880ms ease;
}

.hit-modal span {
  display: block;
  color: #ffe7a6;
  font-size: 15px;
  font-weight: 1000;
}

.hit-modal strong {
  display: block;
  margin-top: 6px;
  font-size: 30px;
  font-weight: 1000;
  line-height: 1.15;
}

.hit-modal p {
  display: inline-block;
  margin: 12px 0 0;
  border-radius: 999px;
  padding: 7px 16px;
  color: #5f1b0e;
  font-size: 22px;
  font-weight: 1000;
  background: #ffe7a6;
}

.voice-card {
  position: absolute;
  z-index: 3;
  right: 214px;
  bottom: 88px;
  left: 16px;
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  align-items: center;
  border: 1px solid rgb(24 83 90 / 38%);
  border-radius: 8px;
  padding: 9px 12px;
  background: linear-gradient(90deg, rgb(24 83 90 / 92%), rgb(36 109 183 / 84%));
  box-shadow: 0 14px 36px rgb(13 40 47 / 26%);
}

.voice-card span {
  color: #d5fffb;
  font-size: 12px;
  font-weight: 1000;
}

.voice-card strong {
  overflow: hidden;
  color: white;
  font-size: 16px;
  font-weight: 1000;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-card.pulse {
  animation: voice-pulse 520ms ease;
}

body.round-revealed .voice-card {
  bottom: 136px;
}

.board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 188px;
  gap: 10px;
  margin-top: 10px;
}

.guess-list,
.rank-card,
.gift-card,
.activity-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.guess-list {
  overflow: hidden;
  min-height: 464px;
}

.table-head,
.guess-row {
  display: grid;
  grid-template-columns: minmax(128px, 1.2fr) 62px 94px 86px;
  gap: 8px;
  align-items: center;
}

.table-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: #3b3328;
  font-size: 13px;
  font-weight: 900;
}

.guess-row {
  min-height: 51px;
  padding: 8px 10px;
  border-bottom: 1px solid #efe4d2;
}

.guess-row:last-child {
  border-bottom: 0;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.avatar {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), var(--gold));
}

.nickname {
  overflow: hidden;
  font-size: 13px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.level {
  border: 1px solid #ddc9ac;
  border-radius: 999px;
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  background: #fff8ed;
}

.guess-word {
  border: 1px solid #cdb797;
  border-radius: 8px;
  padding: 6px 5px;
  font-size: 22px;
  font-weight: 900;
  text-align: center;
  background: white;
}

.score {
  display: grid;
  gap: 4px;
  font-size: 14px;
  font-weight: 900;
}

.score-bar {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2dfd9;
}

.score-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.side-panel {
  display: grid;
  gap: 10px;
  align-content: start;
}

.rank-card,
.gift-card,
.activity-card {
  padding: 10px;
}

.rank-row {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  gap: 7px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #efe4d2;
  font-size: 12px;
  font-weight: 900;
}

.rank-row:last-child {
  border-bottom: 0;
}

.rank-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gift-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #efe4d2;
  font-size: 13px;
  font-weight: 900;
}

.gift-row:last-child {
  border-bottom: 0;
}

.activity-item {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.activity-item.gift,
.activity-item.gift_clue,
.activity-item.hit {
  color: #a63218;
  font-weight: 1000;
}

.activity-item.voice {
  color: #18535a;
}

.settlement-panel {
  position: absolute;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 4;
  display: grid;
  grid-template-columns: 120px 1fr 1.4fr;
  gap: 10px;
  align-items: center;
  border: 2px solid #f5c05a;
  border-radius: 8px;
  padding: 12px;
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgb(255 250 232 / 96%), rgb(255 229 178 / 96%));
  box-shadow: 0 20px 50px rgb(73 43 13 / 28%);
  transform: translateY(16px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.settlement-panel.show {
  opacity: 1;
  transform: translateY(0);
}

.settlement-panel strong {
  display: block;
  color: #8b270f;
  font-size: 22px;
  font-weight: 1000;
}

#settlementTop {
  display: grid;
  gap: 5px;
}

.settlement-row {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 8px;
  align-items: center;
  border-radius: 8px;
  padding: 5px 8px;
  background: rgb(255 255 255 / 58%);
}

.settlement-row strong,
.settlement-row em {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settlement-row em {
  color: #1d6b5e;
  font-style: normal;
  font-weight: 1000;
}

.empty-state {
  padding: 16px 10px;
  color: #9a8b76;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.control-panel {
  display: grid;
  gap: 12px;
  align-content: start;
  max-height: calc(100vh - 32px);
  padding: 16px;
  overflow: auto;
  border: 1px solid rgb(255 255 255 / 20%);
  border-radius: 8px;
  color: white;
  background: rgb(25 26 31 / 88%);
}

.control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-kicker {
  margin: 0 0 2px;
  color: #f2c986;
  font-size: 11px;
  font-weight: 1000;
  letter-spacing: 0;
}

#connectionBadge {
  border: 1px solid rgb(139 224 172 / 48%);
  border-radius: 999px;
  padding: 5px 9px;
  color: #a4f0ba;
  font-size: 12px;
  font-weight: 900;
  background: rgb(55 133 81 / 24%);
}

#connectionBadge[data-tone="warn"] {
  border-color: rgb(244 187 85 / 55%);
  color: #ffd48a;
  background: rgb(162 96 29 / 26%);
}

.control-section {
  display: grid;
  gap: 10px;
  border-top: 1px solid rgb(255 255 255 / 12%);
  padding-top: 12px;
}

.control-section h3 {
  margin: 0;
  color: white;
  font-size: 15px;
}

.control-panel label {
  display: grid;
  gap: 6px;
  color: #f8eee2;
  font-size: 13px;
  font-weight: 800;
}

.control-panel input {
  width: 100%;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 8px;
  padding: 10px 11px;
  color: white;
  background: rgb(255 255 255 / 10%);
  outline: none;
}

.control-panel select {
  width: 100%;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 8px;
  padding: 10px 11px;
  color: white;
  background: rgb(255 255 255 / 10%);
  outline: none;
}

.control-panel select option {
  color: #1d1b16;
}

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

.message-types label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  border: 1px solid rgb(255 255 255 / 14%);
  border-radius: 8px;
  color: white;
  background: rgb(255 255 255 / 8%);
}

.message-types input {
  width: 14px;
  height: 14px;
  padding: 0;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.quick-grid button {
  min-width: 0;
  padding: 8px 6px;
  font-size: 13px;
}

#statusText {
  min-height: 20px;
  margin: 0;
  color: #f2c986;
  font-size: 13px;
  font-weight: 800;
}

body.obs .shell {
  display: block;
  padding: 0;
}

body.obs .stage {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

body.obs .control-panel {
  display: none;
}

body.obs .game-card {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

body.obs .live-strip div {
  padding: 7px 10px;
}

body.obs .answer-panel {
  padding: 9px 14px 11px;
}

body.obs .spotlight-card {
  padding: 9px 12px;
}

body.obs .board {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

body.obs .guess-list {
  min-height: 0;
}

body.obs .side-panel {
  min-height: 0;
  overflow: hidden;
}

body.obs .activity-card {
  max-height: 118px;
  overflow: hidden;
}

@keyframes reveal-pop {
  0% {
    transform: translateX(-50%) translateY(8px) scale(0.92);
  }
  65% {
    transform: translateX(-50%) translateY(0) scale(1.04);
  }
  100% {
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

@keyframes effect-rise {
  0% {
    opacity: 0;
    transform: translate(-50%, -30%) scale(0.88);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.03);
  }
  82% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -95%) scale(0.98);
  }
}

@keyframes hit-shine {
  0% {
    box-shadow: 0 24px 70px rgb(70 20 8 / 42%);
  }
  55% {
    box-shadow:
      0 24px 70px rgb(70 20 8 / 42%),
      0 0 0 12px rgb(255 211 122 / 28%);
  }
  100% {
    box-shadow: 0 24px 70px rgb(70 20 8 / 42%);
  }
}

@keyframes voice-pulse {
  0% {
    transform: translateY(4px);
  }
  60% {
    transform: translateY(-2px);
  }
  100% {
    transform: translateY(0);
  }
}

@media (max-width: 1040px) {
  .shell {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  body {
    overflow: auto;
  }

  .control-panel {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .game-card {
    width: min(100%, 520px);
    min-height: auto;
  }

  .game-header,
  .spotlight-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .round-stack {
    justify-items: start;
  }

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

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

  .guess-list {
    min-height: 0;
  }

  .table-head,
  .guess-row {
    grid-template-columns: minmax(90px, 1fr) 50px 74px 70px;
  }

  .settlement-panel {
    position: static;
    grid-template-columns: 1fr;
    margin-top: 10px;
  }

  .voice-card {
    position: static;
    grid-template-columns: 1fr;
    margin-top: 10px;
  }

  .spotlight-card p {
    max-width: none;
    text-align: left;
  }
}
