* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 50% 0%, rgba(248, 74, 75, 0.14), transparent 42%),
    #0f0d14;
  color: #f3f4f6;
}

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 14px 16px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header-compact {
  margin-bottom: 10px;
  flex-shrink: 0;
}

.title {
  margin: 0 0 2px;
  font-size: 22px;
  font-weight: 900;
  color: #ff4d5a;
}

.subtitle {
  margin: 0;
  color: #9ca3af;
  font-size: 12px;
  line-height: 1.4;
}

.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.screen[hidden] {
  display: none !important;
}

.lobby-panel {
  max-width: 420px;
  margin: 0 auto;
}

.panel {
  padding: 14px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-compact {
  margin-bottom: 10px;
}

.panel-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 700;
}

.hint {
  margin: 0 0 10px;
  color: #9ca3af;
  font-size: 12px;
  line-height: 1.45;
}

.hint-tight {
  margin-bottom: 8px;
}

.hint-inline {
  font-size: 11px;
  font-weight: 400;
  color: #9ca3af;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: #9ca3af;
}

.field.block {
  margin-bottom: 8px;
}

.field input,
.field textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.25);
  color: #f3f4f6;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}

.field-row {
  display: grid;
  gap: 8px;
  margin: 10px 0;
}

.owner-fields {
  grid-template-columns: 1fr;
}

.owner-details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #d1d5db;
  list-style: none;
}

.owner-details summary::-webkit-details-marker {
  display: none;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  margin-bottom: 6px;
}

.primary-button {
  background: #96232b;
  color: #fff;
}

.primary-button:hover:not(:disabled) {
  background: #b52d38;
}

.primary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.secondary-button {
  background: rgba(255, 255, 255, 0.06);
  color: #e5e7eb;
  border: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 0;
}

.join-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  margin-top: 10px;
}

.join-btn {
  width: auto;
  min-width: 72px;
  height: 38px;
}

.room-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.room-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.help-toggle-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 180, 67, 0.45);
  background: rgba(255, 180, 67, 0.12);
  color: #fde68a;
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}

.help-panel {
  margin-bottom: 8px;
  border-radius: 12px;
  border: 1px solid rgba(255, 180, 67, 0.25);
  background: rgba(15, 13, 20, 0.95);
  max-height: min(360px, 50vh);
  overflow-y: auto;
}

.help-panel-inner {
  padding: 12px 14px;
}

.help-title {
  margin: 0 0 8px;
  font-size: 14px;
  color: #fde68a;
}

.help-list {
  margin: 0 0 10px;
  padding-left: 1.1rem;
  font-size: 12px;
  line-height: 1.55;
  color: #d1d5db;
}

.help-list li {
  margin-bottom: 6px;
}

.help-close-btn {
  width: 100%;
  margin-bottom: 0;
}

.stat-nowinner-votes {
  border: 1px solid rgba(252, 165, 165, 0.4);
  color: #fca5a5;
}

.no-winner-vote-bar {
  margin-top: 8px;
}

.no-winner-vote-bar .secondary-button {
  width: auto;
  margin-bottom: 0;
}

.stat-pill {
  font-size: 11px;
  color: #d1d5db;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.stat-pill.is-host {
  border: 1px solid rgba(255, 180, 67, 0.45);
  color: #fde68a;
}

.stat-pill.is-owner {
  border: 1px solid rgba(134, 239, 172, 0.35);
  color: #bbf7d0;
}

.copy-room-btn {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: #e5e7eb;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.copy-room-btn.is-copied {
  color: #86efac;
  border-color: rgba(134, 239, 172, 0.45);
}

.host-confirm-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 4px;
}

.host-confirm-row .primary-button,
.host-confirm-row .secondary-button {
  margin-bottom: 0;
  width: 100%;
}

.danger-btn {
  border-color: rgba(252, 165, 165, 0.4) !important;
  color: #fca5a5 !important;
}

.room-error {
  margin: 6px 0 0;
  text-align: left;
  font-size: 12px;
}

.room-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(200px, 240px) minmax(0, 1fr) minmax(160px, 220px);
  gap: 10px;
}

.room-layout.sidebar-collapsed {
  grid-template-columns: minmax(200px, 240px) minmax(0, 1fr) 40px;
}

.col {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.col-left {
  overflow-y: auto;
}

.col-center {
  min-width: 0;
}

.col-right {
  position: relative;
  overflow: hidden;
}

.col-right.is-collapsed {
  grid-column: auto;
}

.col-right.is-collapsed .sidebar-body {
  display: none;
}

.col-right.is-collapsed .sidebar-toggle {
  left: 50%;
  transform: translateX(-50%);
}

.sidebar-toggle {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  color: #e5e7eb;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}

.sidebar-body {
  height: 100%;
  overflow-y: auto;
  padding-top: 36px;
  display: flex;
  flex-direction: column;
}

.sidebar-section {
  flex-shrink: 0;
}

.sidebar-players {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-players .player-list {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 0;
}

.panel-fill {
  height: 100%;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.center-panel {
  padding-bottom: 10px;
}

.center-keywords {
  flex-shrink: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.center-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.center-answers {
  flex-shrink: 0;
  min-height: 0;
}

.scroll-pane {
  max-height: min(240px, 35vh);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.center-answers .scroll-pane {
  max-height: min(320px, 42vh);
}

.center-compose {
  flex-shrink: 0;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 6px;
}

.keyword-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.keyword-chips li {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 77, 90, 0.12);
  border: 1px solid rgba(255, 77, 90, 0.28);
  font-size: 14px;
  font-weight: 600;
}

.keyword-chips .is-empty {
  background: transparent;
  border: none;
  color: #6b7280;
  font-weight: 400;
  font-size: 12px;
  padding: 0;
}

.answer-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.answer-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: start;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 13px;
}

.answer-item.is-pending-winner {
  border-color: rgba(255, 180, 67, 0.45);
  background: rgba(255, 180, 67, 0.08);
}

.answer-item .answer-name {
  font-weight: 700;
  white-space: nowrap;
}

.answer-item .answer-text {
  word-break: break-word;
}

.queue-list {
  margin: 0 0 8px;
  padding-left: 1.1rem;
  font-size: 12px;
}

.queue-list li {
  padding: 4px 0;
  color: #d1d5db;
}

.queue-list li.is-front {
  color: #fde68a;
  font-weight: 600;
}

.queue-list .is-empty {
  list-style: none;
  padding-left: 0;
  color: #6b7280;
}

.player-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.player-card {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 12px;
}

.player-card:last-child {
  border-bottom: none;
}

.player-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.player-name {
  font-weight: 700;
  font-size: 13px;
}

.player-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #9ca3af;
}

.badge.is-you {
  color: #fde68a;
}

.badge.is-host {
  color: #fde68a;
  border: 1px solid rgba(255, 180, 67, 0.35);
}

.badge.is-owner {
  color: #bbf7d0;
}

.player-round-speech {
  margin-top: 4px;
  color: #9ca3af;
  font-size: 11px;
  line-height: 1.4;
  word-break: break-word;
}

.player-round-speech strong {
  color: #6b7280;
  font-weight: 600;
}

.kick-btn {
  margin-left: auto;
  padding: 2px 6px;
  font-size: 10px;
  border-radius: 4px;
  border: 1px solid rgba(252, 165, 165, 0.35);
  background: transparent;
  color: #fca5a5;
  cursor: pointer;
  font-family: inherit;
}

.pick-winner-btn {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: #e5e7eb;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.pick-winner-btn:hover {
  border-color: rgba(255, 180, 67, 0.5);
}

.answer-form,
.compose-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.answer-form input,
.compose-form input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.25);
  color: #f3f4f6;
  font-size: 14px;
  font-family: inherit;
}

.answer-form .primary-button,
.compose-form .primary-button,
.compose-form .secondary-button {
  width: auto;
  min-width: 72px;
  margin-bottom: 0;
}

.compose-form.is-chat-mode .primary-button {
  background: rgba(139, 92, 246, 0.35);
  border-color: rgba(167, 139, 250, 0.45);
}

.compose-form.is-host-mode .primary-button {
  background: rgba(255, 180, 67, 0.25);
  border-color: rgba(255, 180, 67, 0.45);
}

.host-panel {
  border-color: rgba(255, 180, 67, 0.25);
  background: rgba(255, 180, 67, 0.04);
}

.feedback {
  min-height: 18px;
  font-size: 12px;
  font-weight: 600;
}

.feedback.is-wrong {
  color: #fca5a5;
}

.feedback.is-ok {
  color: #86efac;
}

.field-feedback {
  margin: 6px 0 0;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  min-height: 0;
}

.field-feedback[hidden] {
  display: none !important;
}

.field-feedback.is-wrong {
  color: #fca5a5;
}

.field-feedback.is-ok {
  color: #86efac;
}

.field-label {
  display: block;
  font-size: 11px;
  color: #9ca3af;
  margin-bottom: 4px;
}

.draft-kw-add {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.icon-btn {
  width: auto;
  min-width: 42px;
  padding-inline: 10px;
  margin-bottom: 0;
}

.draft-kw-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.draft-kw-list li {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
}

.draft-kw-list button {
  border: none;
  background: transparent;
  color: #fca5a5;
  cursor: pointer;
  padding: 0 2px;
  font-size: 14px;
  line-height: 1;
}

.host-kw-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}

.host-kw-stack input {
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.25);
  color: #f3f4f6;
  font-size: 13px;
  font-family: inherit;
}

.host-kw-send {
  width: 100%;
  padding: 6px 10px;
  font-size: 12px;
  margin-bottom: 0;
}

.host-round-block .primary-button {
  margin-top: 4px;
}

.field-wide select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.25);
  color: #f3f4f6;
  font-size: 13px;
  font-family: inherit;
}

.compose-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
}

.compose-tab {
  flex: 1;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #9ca3af;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.compose-tab.is-active {
  color: #fde68a;
  border-color: rgba(255, 180, 67, 0.4);
  background: rgba(255, 180, 67, 0.1);
}

.compose-form.is-blocked input {
  border-color: rgba(252, 165, 165, 0.35);
}

.action-toast {
  position: fixed;
  top: calc(var(--site-nav-height, 52px) + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  z-index: 10001;
  padding: 10px 20px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.95), rgba(22, 163, 74, 0.95));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 24px rgba(34, 197, 94, 0.35);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.action-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.host-chat-box {
  margin: 8px 0;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.inline-form input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.25);
  color: #f3f4f6;
  font-size: 13px;
  font-family: inherit;
}

.inline-form .secondary-button {
  width: auto;
  min-width: 56px;
  margin-bottom: 0;
}

.chat-stream {
  flex-shrink: 0;
  padding: 0;
}

.stream-title {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  color: #9ca3af;
  position: sticky;
  top: 0;
  background: rgba(15, 13, 20, 0.92);
  padding: 4px 0;
  z-index: 1;
}

.chat-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.chat-list li {
  font-size: 12px;
  line-height: 1.4;
  padding: 3px 0;
  word-break: break-word;
}

.host-chat-stream .chat-list li {
  color: #fde68a;
}

.answered-chat-stream .chat-list li {
  color: #c4b5fd;
}

.stat-next-votes {
  border: 1px solid rgba(96, 165, 250, 0.4);
  color: #93c5fd;
}

.next-vote-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.next-vote-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(96, 165, 250, 0.35);
  background: rgba(59, 130, 246, 0.12);
  color: #bfdbfe;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.next-vote-btn.is-active {
  background: rgba(59, 130, 246, 0.28);
  border-color: rgba(96, 165, 250, 0.65);
  color: #fff;
}

.next-vote-bar .secondary-button {
  width: auto;
  margin-bottom: 0;
  padding: 8px 12px;
}

.next-vote-bar.is-voting .next-vote-btn {
  display: none;
}

.player-card.is-voting-next .player-name {
  color: #93c5fd;
}

@media (max-width: 900px) {
  .page {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: auto;
    padding-bottom: env(safe-area-inset-bottom, 16px);
  }

  .room-layout,
  .room-layout.sidebar-collapsed {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    gap: 8px;
  }

  .col-left {
    order: 2;
    max-height: none;
    overflow: visible;
  }

  .col-center {
    order: 1;
    min-height: 50vh;
    min-height: 50dvh;
  }

  .col-right {
    order: 3;
  }

  .col-right.is-collapsed .sidebar-body {
    display: flex;
  }

  .sidebar-body {
    padding-top: 0;
  }

  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .panel-fill {
    min-height: 280px;
  }

  .center-compose {
    position: sticky;
    bottom: 0;
    background: linear-gradient(180deg, transparent, rgba(15, 13, 20, 0.92) 12%);
    padding-bottom: env(safe-area-inset-bottom, 8px);
    z-index: 2;
  }

  .host-kw-stack,
  .inline-form,
  .compose-form,
  .answer-form,
  .draft-kw-add {
    grid-template-columns: 1fr;
  }

  .inline-form .secondary-button,
  .compose-form .primary-button,
  .compose-form .secondary-button,
  .answer-form .primary-button {
    width: 100%;
  }

  .scroll-pane {
    max-height: min(200px, 28vh);
  }

  .center-answers .scroll-pane {
    max-height: min(260px, 36vh);
  }

  .field-row.owner-fields {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .title {
    font-size: 20px;
  }

  .room-meta {
    gap: 4px;
  }

  .stat-pill {
    font-size: 10px;
    padding: 3px 7px;
  }
}
