/* Historical Clues live chat workspace. */
:root {
  --ink: #17221f;
  --muted: #64706d;
  --canvas: #f5f3ee;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --line: #dcded8;
  --accent: #176b5b;
  --accent-dark: #0f5044;
  --accent-soft: #dff1eb;
  --bili: #d84c7f;
  --bili-soft: #ffe5ef;
  --danger: #a93838;
  --warning: #98601b;
  --shadow: 0 10px 32px rgb(25 42 36 / 10%);
  --banner-height: 20dvh;
  --banner-focus-height: 15dvh;
  --banner-hard-max: 25dvh;
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui,
    -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at top left, rgb(23 107 91 / 9%), transparent 34rem),
    var(--canvas);
}

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

button {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.chat-app {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  width: min(100%, 900px);
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.app-header {
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: max(10px, env(safe-area-inset-top)) 18px 10px;
  color: #f9fffc;
  background: #17221f;
}

.header-title {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.header-title > div {
  min-width: 0;
}

.header-title h1,
.header-title p,
.identity span,
.identity strong {
  margin: 0;
}

.header-title h1 {
  overflow: hidden;
  font-size: 1rem;
  font-weight: 720;
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-title p {
  margin-top: 3px;
  overflow: hidden;
  color: #c6d2ce;
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 12px;
  color: #17221f;
  background: #aee4d6;
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.04em;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  margin-left: 10px;
}

.locale-switcher {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 2px;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 8px;
  background: rgb(255 255 255 / 6%);
}

.locale-switcher button {
  min-width: 31px;
  min-height: 28px;
  padding: 3px 7px;
  border: 0;
  border-radius: 6px;
  color: #aebdb8;
  background: transparent;
  font-size: 0.67rem;
  font-weight: 720;
  line-height: 1;
  cursor: pointer;
}

.locale-switcher button[aria-pressed="true"] {
  color: #16332d;
  background: #c9ede3;
}

.locale-switcher button:focus-visible {
  outline: 2px solid #f9fffc;
  outline-offset: 2px;
}

.identity {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.identity span {
  color: #9fb0aa;
  font-size: 0.66rem;
}

.identity strong {
  display: block;
  max-width: 34vw;
  overflow: hidden;
  font-size: 0.78rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.presentation {
  position: relative;
  z-index: 1;
  max-height: min(var(--banner-height), var(--banner-hard-max));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 16px 12px;
  border-bottom: 1px solid #cbd8d3;
  background:
    linear-gradient(120deg, rgb(255 255 255 / 86%), rgb(228 243 237 / 92%)),
    var(--accent-soft);
  scrollbar-width: thin;
  transition: max-height 160ms ease;
}

.chat-app.composer-focused .presentation {
  max-height: min(var(--banner-focus-height), var(--banner-hard-max));
}

.presentation-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  color: #53615c;
  font-size: 0.72rem;
}

.readonly-label,
.stage-label {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: rgb(23 107 91 / 11%);
  font-size: 0.67rem;
  font-weight: 740;
  letter-spacing: 0.04em;
}

.game-connection::before {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: #98a39f;
  content: "";
}

.game-connection.is-online::before {
  background: #19936d;
  box-shadow: 0 0 0 3px rgb(25 147 109 / 12%);
}

.announcement {
  margin: 8px 0 0;
  padding: 7px 9px;
  border-left: 3px solid #d8a646;
  border-radius: 0 6px 6px 0;
  color: #5f491d;
  background: rgb(255 247 218 / 78%);
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.game-presentation {
  margin-top: 9px;
}

.presentation-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.presentation-heading > div {
  min-width: 0;
}

.presentation-heading h2 {
  margin: 5px 0 0;
  font-size: 0.98rem;
  line-height: 1.35;
}

.countdown {
  flex: 0 0 auto;
  min-width: 58px;
  padding: 5px 8px;
  border: 1px solid rgb(23 107 91 / 16%);
  border-radius: 9px;
  color: var(--accent-dark);
  background: rgb(255 255 255 / 72%);
  font-variant-numeric: tabular-nums;
  font-weight: 780;
  text-align: center;
}

.countdown.is-ending {
  color: var(--danger);
  border-color: rgb(169 56 56 / 20%);
}

.question-context,
.question-text {
  margin: 7px 0 0;
  font-size: 0.8rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.question-context {
  color: var(--muted);
}

.question-text {
  font-weight: 650;
}

.option-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 10px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: option;
}

.option-list li {
  min-width: 0;
  padding: 4px 7px;
  border-radius: 6px;
  color: #33413c;
  background: rgb(255 255 255 / 58%);
  font-size: 0.76rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.option-code {
  margin-right: 5px;
  color: var(--accent-dark);
  font-weight: 800;
}

.option-votes {
  margin-left: 5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.option-description {
  display: block;
  margin: 2px 0 0 calc(1ch + 7px);
  color: var(--muted);
  font-size: 0.69rem;
  line-height: 1.4;
}

.vote-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 7px;
  color: #53615c;
  font-size: 0.72rem;
}

.vote-result {
  margin: 8px 0 0;
  padding: 6px 9px;
  border-radius: 7px;
  color: #16483d;
  background: rgb(166 224 208 / 42%);
  font-size: 0.8rem;
  font-weight: 720;
}

.messages-shell {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(rgb(248 247 243 / 91%), rgb(248 247 243 / 91%)),
    repeating-linear-gradient(45deg, transparent 0 10px, rgb(23 107 91 / 3%) 10px 11px);
}

.message-list {
  height: 100%;
  margin: 0;
  padding: 16px clamp(12px, 3vw, 24px) 22px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  list-style: none;
}

.history-status {
  position: absolute;
  z-index: 2;
  top: 8px;
  left: 50%;
  max-width: calc(100% - 32px);
  padding: 4px 9px;
  transform: translateX(-50%);
  border-radius: 999px;
  color: #68736f;
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 2px 8px rgb(25 42 36 / 8%);
  font-size: 0.69rem;
  pointer-events: none;
}

.history-status:empty {
  display: none;
}

.message-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 12px;
}

.message-row.is-self {
  justify-content: flex-end;
}

.message-row.is-system {
  justify-content: center;
  margin: 8px 0 14px;
}

.avatar {
  display: grid;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  place-items: center;
  margin-top: 20px;
  border: 1px solid rgb(23 107 91 / 12%);
  border-radius: 10px;
  color: #285348;
  background: #e3eee9;
  font-size: 0.72rem;
  font-weight: 760;
}

.message-row.is-bilibili .avatar {
  color: #8f3154;
  border-color: rgb(216 76 127 / 14%);
  background: var(--bili-soft);
}

.message-content {
  display: flex;
  min-width: 0;
  max-width: min(76%, 620px);
  flex-direction: column;
}

.message-row.is-self .message-content {
  align-items: flex-end;
}

.message-meta {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
  margin: 0 4px 4px;
  color: #6b7571;
  font-size: 0.69rem;
}

.message-row.is-self .message-meta {
  flex-direction: row-reverse;
}

.message-author {
  max-width: min(42vw, 260px);
  overflow: hidden;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-source {
  padding: 1px 5px;
  border-radius: 999px;
  color: #49625a;
  background: #e6ece9;
  font-size: 0.61rem;
  font-weight: 720;
}

.message-source.source-bilibili {
  color: #9b345a;
  background: var(--bili-soft);
}

.message-time {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.message-bubble {
  max-width: 100%;
  padding: 9px 12px;
  border: 1px solid #e1e3de;
  border-radius: 5px 16px 16px;
  color: #24302c;
  background: var(--surface-strong);
  box-shadow: 0 3px 10px rgb(25 42 36 / 5%);
  font-size: 0.91rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-row.is-self .message-bubble {
  border-color: #acd4c8;
  border-radius: 16px 5px 16px 16px;
  background: var(--accent-soft);
}

.message-row.is-bilibili .message-bubble {
  border-color: #f2ccda;
}

.system-message {
  max-width: 82%;
  padding: 4px 9px;
  border-radius: 999px;
  color: #6b7571;
  background: rgb(225 229 225 / 78%);
  font-size: 0.69rem;
  line-height: 1.4;
  text-align: center;
}

.jump-latest {
  position: absolute;
  right: 16px;
  bottom: 12px;
  padding: 7px 11px;
  border: 1px solid #c8d7d1;
  border-radius: 999px;
  color: var(--accent-dark);
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 4px 14px rgb(25 42 36 / 13%);
  font-size: 0.74rem;
  cursor: pointer;
}

.composer-notice {
  min-height: 0;
  padding: 0 16px;
  color: var(--danger);
  background: var(--surface-strong);
  font-size: 0.72rem;
  line-height: 1.8;
  text-align: center;
}

.composer-notice:empty {
  display: none;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface-strong);
}

.composer textarea {
  width: 100%;
  max-height: 108px;
  resize: none;
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid #d0d6d2;
  border-radius: 13px;
  outline: none;
  color: var(--ink);
  background: #f8f8f5;
  line-height: 1.45;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.composer textarea:focus {
  border-color: #4b9b88;
  box-shadow: 0 0 0 3px rgb(23 107 91 / 11%);
}

.composer textarea:disabled {
  color: #8a928f;
  background: #f0f1ef;
}

.composer button {
  flex: 0 0 auto;
  min-width: 64px;
  min-height: 42px;
  padding: 8px 14px;
  border: 0;
  border-radius: 12px;
  color: white;
  background: var(--accent);
  font-weight: 720;
  cursor: pointer;
}

.composer button:hover:not(:disabled) {
  background: var(--accent-dark);
}

.composer button:disabled {
  color: #a7afac;
  background: #e2e5e3;
  cursor: not-allowed;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--ink);
  background: var(--canvas);
}

@media (max-width: 560px) {
  .app-header {
    min-height: 58px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .header-title h1 {
    font-size: 0.92rem;
  }

  .header-actions {
    gap: 7px;
    margin-left: 7px;
  }

  .locale-switcher button {
    min-width: 29px;
    min-height: 27px;
    padding-right: 6px;
    padding-left: 6px;
  }

  .identity strong {
    max-width: 24vw;
  }

  .presentation {
    padding-right: 12px;
    padding-left: 12px;
  }

  .option-list {
    grid-template-columns: 1fr;
  }

  .message-content {
    max-width: 82%;
  }

  .avatar {
    width: 29px;
    height: 29px;
    border-radius: 9px;
  }
}

@media (max-width: 390px) {
  .header-title {
    gap: 7px;
  }

  .header-title h1 {
    max-width: 26vw;
  }

  .header-actions {
    gap: 5px;
    margin-left: 5px;
  }

  .identity span {
    display: none;
  }

  .identity strong {
    max-width: 22vw;
  }
}

@media (min-width: 901px) {
  body {
    padding: 16px 0;
  }

  .chat-app {
    height: calc(100dvh - 32px);
    border: 1px solid #dde1dc;
    border-radius: 18px;
  }
}

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