:root {
  color-scheme: dark;
  --lf-bg: #081014;
  --lf-panel: rgba(16, 26, 30, 0.9);
  --lf-panel-strong: rgba(22, 36, 40, 0.96);
  --lf-line: rgba(226, 238, 232, 0.16);
  --lf-text: #eef7f2;
  --lf-muted: #8ea39c;
  --lf-teal: #47e2c5;
  --lf-gold: #ffd17a;
  --lf-coral: #ff6f61;
  --lf-green: #9be564;
  --lf-shadow: 0 8px 12px rgba(0, 0, 0, 0.26);
  --lf-z-popover: 20;
  --lf-space-1: 4px;
  --lf-space-2: 8px;
  --lf-space-3: 12px;
  --lf-space-4: 16px;
  --lf-space-5: 20px;
  --lf-space-6: 24px;
  --lf-space-7: 32px;
  --lf-toast-z: 30;
}

* {
  box-sizing: border-box;
}

body.lyrics-fill-body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(71, 226, 197, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(255, 209, 122, 0.08), transparent 30%),
    var(--lf-bg);
  color: var(--lf-text);
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.lyrics-fill-app {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: var(--lf-space-6) 0 40px;
}

.lyrics-fill-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--lf-space-4);
  padding: 12px 0 var(--lf-space-6);
}

.lf-home-link,
.lf-secondary-btn,
.lf-primary-btn,
.lf-danger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--lf-space-2);
  min-height: 44px;
  border: 1px solid var(--lf-line);
  border-radius: 8px;
  padding: 0 var(--lf-space-4);
  color: var(--lf-text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.lf-home-link {
  display: inline-flex;
  align-items: center;
}

.lf-primary-btn {
  border: 0;
  color: #06100e;
  font-weight: 800;
  background: linear-gradient(135deg, var(--lf-teal), var(--lf-gold));
}

.lf-secondary-btn:hover,
.lf-home-link:hover,
.lf-primary-btn:hover,
.lf-danger-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(71, 226, 197, 0.55);
}

.lf-danger-btn {
  border-color: rgba(255, 111, 97, 0.45);
  color: #ffd8d2;
}

.lf-report-btn {
  border-color: rgba(255, 209, 122, 0.42);
  color: var(--lf-gold);
}

.lf-home-link:focus-visible,
.lf-secondary-btn:focus-visible,
.lf-primary-btn:focus-visible,
.lf-danger-btn:focus-visible {
  outline: 2px solid rgba(71, 226, 197, 0.9);
  outline-offset: 2px;
}

.lf-secondary-btn:disabled,
.lf-primary-btn:disabled,
.lf-danger-btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.lf-brand {
  text-align: center;
}

.lf-brand p,
.lf-section-head p,
.lf-room-bar span,
.lf-lyric-stack span {
  margin: 0 0 5px;
  color: var(--lf-muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.lf-brand h1,
.lf-section-head h2 {
  margin: 0;
}

.lf-section-head {
  margin-bottom: var(--lf-space-3);
}

.lf-section-head h2 {
  font-size: 1.45rem;
  line-height: 1.2;
}

.lf-brand h1 {
  font-size: 3.1rem;
  line-height: 0.95;
}

.lf-volume-control {
  display: grid;
  grid-template-columns: auto 120px 44px;
  align-items: center;
  gap: 8px;
  color: var(--lf-muted);
  font-size: 0.86rem;
}

.lf-volume-control input {
  width: 120px;
}

.lf-alerts {
  position: fixed;
  top: var(--lf-space-4);
  left: 50%;
  z-index: var(--lf-toast-z);
  width: min(420px, calc(100vw - 32px));
  display: grid;
  gap: var(--lf-space-2);
  pointer-events: none;
  transform: translateX(-50%);
}

.lf-alert {
  border: 1px solid var(--lf-line);
  border-radius: 8px;
  padding: var(--lf-space-3) var(--lf-space-4);
  background: rgba(16, 26, 30, 0.92);
  box-shadow: var(--lf-shadow);
  pointer-events: auto;
}

.lf-alert.good {
  border-color: rgba(155, 229, 100, 0.5);
}

.lf-alert.bad {
  border-color: rgba(255, 111, 97, 0.55);
}

.lf-setup-grid,
.lf-room-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: var(--lf-space-5);
  align-items: start;
}

.lf-panel {
  border: 1px solid var(--lf-line);
  border-radius: 8px;
  padding: var(--lf-space-5);
  background: var(--lf-panel);
  box-shadow: var(--lf-shadow);
}

.lf-entry-panel {
  display: grid;
  gap: 14px;
}

.lf-field {
  display: grid;
  gap: 7px;
  color: var(--lf-muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.lf-field input,
.lf-join-row input,
.lf-answer-row input,
.lf-chat-row input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--lf-line);
  border-radius: 8px;
  padding: 0 13px;
  color: var(--lf-text);
  background: rgba(4, 10, 12, 0.7);
  outline: none;
}

.lf-field input:focus,
.lf-join-row input:focus,
.lf-answer-row input:focus,
.lf-chat-row input:focus {
  border-color: rgba(71, 226, 197, 0.75);
}

.lf-field input::placeholder,
.lf-join-row input::placeholder,
.lf-answer-row input::placeholder,
.lf-chat-row input::placeholder {
  color: rgba(238, 247, 242, 0.58);
}

.lf-join-row,
.lf-answer-row,
.lf-chat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--lf-space-2);
}

.lf-muted {
  margin: 0;
  color: var(--lf-muted);
  line-height: 1.5;
}

.lf-filter-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.lf-filter-head strong {
  color: var(--lf-gold);
  white-space: nowrap;
}

.lf-tag-grid {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.lf-tag-toolbar,
.lf-tag-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.lf-tag-group-title {
  width: 100%;
  margin: 0 0 2px;
  color: var(--lf-muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.lf-tag-chip {
  min-height: 34px;
  border: 1px solid var(--lf-line);
  border-radius: 8px;
  padding: 0 11px;
  color: var(--lf-text);
  background: rgba(255, 255, 255, 0.05);
}

.lf-tag-chip.is-active {
  border-color: rgba(71, 226, 197, 0.85);
  color: #06100e;
  background: var(--lf-teal);
}

.lf-room-view {
  display: grid;
  gap: var(--lf-space-5);
}

.lf-room-bar {
  display: grid;
  grid-template-columns: minmax(150px, auto) minmax(120px, 1fr) auto;
  align-items: center;
  gap: var(--lf-space-4);
  border: 1px solid var(--lf-line);
  border-radius: 8px;
  padding: var(--lf-space-4);
  background: var(--lf-panel-strong);
}

.lf-room-bar strong {
  display: block;
  font-size: 1.8rem;
  letter-spacing: 0;
}

.lf-room-bar p {
  margin: 0;
  color: var(--lf-gold);
  font-weight: 900;
  text-align: center;
}

.lf-room-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--lf-space-2);
}

.lf-room-actions .lf-primary-btn {
  min-width: 116px;
}

.lf-report-menu {
  position: relative;
}

.lf-report-trigger {
  min-width: 116px;
  list-style: none;
}

.lf-report-trigger::-webkit-details-marker {
  display: none;
}

.lf-report-menu[open] .lf-report-trigger {
  border-color: rgba(255, 209, 122, 0.5);
  color: var(--lf-gold);
  background: rgba(255, 209, 122, 0.08);
}

.lf-report-popover {
  position: absolute;
  top: calc(100% + var(--lf-space-2));
  right: 0;
  z-index: var(--lf-z-popover);
  display: grid;
  width: min(320px, calc(100vw - 32px));
  gap: var(--lf-space-3);
  border: 1px solid rgba(255, 209, 122, 0.28);
  border-radius: 8px;
  padding: var(--lf-space-4);
  background: #101a1e;
  box-shadow: var(--lf-shadow);
}

.lf-report-status {
  margin: 0;
  color: var(--lf-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.lf-report-status.good {
  color: var(--lf-green);
}

.lf-report-status.bad {
  color: #ffd8d2;
}

.lf-report-status.info {
  color: var(--lf-teal);
}

.lf-report-popover .lf-report-btn {
  width: 100%;
}

.lf-player-panel {
  position: sticky;
  top: 14px;
}

.lf-players-list,
.lf-feedback-list,
.lf-chat-messages {
  display: grid;
  gap: var(--lf-space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.lf-player-item,
.lf-feedback-list li,
.lf-chat-messages li {
  border: 1px solid var(--lf-line);
  border-radius: 8px;
  padding: var(--lf-space-3);
  background: rgba(255, 255, 255, 0.04);
}

.lf-player-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.lf-player-rank {
  color: var(--lf-gold);
  font-weight: 900;
}

.lf-player-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.lf-player-score {
  color: var(--lf-teal);
  font-weight: 900;
}

.lf-player-sub {
  grid-column: 2 / 4;
  color: var(--lf-muted);
  font-size: 0.82rem;
}

.lf-stage {
  display: grid;
  gap: var(--lf-space-5);
}

.lf-stage-panel {
  min-height: 392px;
  display: grid;
  gap: var(--lf-space-4);
  align-content: start;
  background:
    linear-gradient(180deg, rgba(71, 226, 197, 0.09), transparent 44%),
    var(--lf-panel-strong);
}

.lf-stage-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--lf-space-3);
}

#lfRoundLabel {
  color: var(--lf-muted);
  font-weight: 900;
}

#lfTimerLabel {
  min-width: 86px;
  text-align: right;
  color: var(--lf-gold);
  font-size: 2rem;
}

.lf-lyric-stack {
  display: grid;
  gap: var(--lf-space-3);
}

.lf-lyric-stack > div {
  border: 1px solid var(--lf-line);
  border-radius: 8px;
  padding: var(--lf-space-4);
  background: rgba(4, 10, 12, 0.42);
}

.lf-lyric-stack p {
  min-height: 1.5em;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 1.35rem;
  line-height: 1.55;
  letter-spacing: 0;
}

.lf-target-line {
  border-color: rgba(255, 209, 122, 0.42) !important;
}

.lf-target-line p {
  color: var(--lf-gold);
  font-size: 2rem;
  font-weight: 900;
}

.lf-stage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--lf-space-2);
}

.lf-guess-hint {
  min-height: 1.5em;
  margin: calc(var(--lf-space-2) * -1) 0 0;
  color: var(--lf-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.lf-guess-hint.good {
  color: var(--lf-green);
}

.lf-guess-hint.bad {
  color: #ffd8d2;
}

.lf-guess-hint.info {
  color: var(--lf-teal);
}

.lf-stage-panel.is-ended .lf-lyric-stack,
.lf-stage-panel.is-ended .lf-answer-row,
.lf-stage-panel.is-ended .lf-guess-hint {
  display: none;
}

.lf-stage-panel.is-ended {
  min-height: 0;
}

.lf-result-panel {
  display: grid;
  gap: var(--lf-space-3);
  border: 1px solid rgba(255, 209, 122, 0.36);
  border-radius: 8px;
  padding: var(--lf-space-5);
  background:
    linear-gradient(180deg, rgba(255, 209, 122, 0.1), rgba(255, 209, 122, 0.04)),
    rgba(4, 10, 12, 0.46);
}

.lf-result-status {
  margin: 0;
  color: var(--lf-muted);
  font-weight: 900;
}

.lf-result-answer span {
  display: block;
  margin-bottom: var(--lf-space-1);
  color: var(--lf-muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.lf-result-answer strong {
  display: block;
  color: var(--lf-gold);
  font-size: 2.15rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.lf-result-song {
  margin: 0;
  color: var(--lf-text);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.lf-result-song::before {
  content: "歌曲 ";
  color: var(--lf-muted);
  font-weight: 800;
}

.lf-social-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: var(--lf-space-5);
  align-items: stretch;
}

.lf-feedback-panel,
.lf-chat-panel {
  display: grid;
  gap: var(--lf-space-3);
  align-content: start;
}

.lf-feedback-list {
  max-height: 178px;
  overflow: auto;
}

.lf-feedback-list li.good {
  border-color: rgba(155, 229, 100, 0.44);
}

.lf-feedback-list li.bad {
  border-color: rgba(255, 111, 97, 0.44);
}

.lf-feedback-list li.info {
  border-color: rgba(71, 226, 197, 0.38);
}

.lf-chat-messages {
  min-height: 120px;
  max-height: 178px;
  overflow: auto;
  margin-bottom: 0;
}

.lf-chat-messages small {
  display: block;
  color: var(--lf-muted);
  margin-bottom: 3px;
}

@media (max-width: 860px) {
  .lyrics-fill-app {
    width: min(100% - 18px, 680px);
    padding-top: 12px;
  }

  .lyrics-fill-topbar,
  .lf-room-bar {
    align-items: stretch;
  }

  .lyrics-fill-topbar {
    flex-direction: column;
  }

  .lf-room-bar {
    grid-template-columns: 1fr;
  }

  .lf-room-bar p {
    text-align: left;
  }

  .lf-room-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .lf-report-menu {
    grid-column: auto;
  }

  .lf-room-actions > .lf-primary-btn,
  .lf-room-actions > .lf-danger-btn,
  .lf-report-trigger {
    width: 100%;
  }

  .lf-report-popover {
    position: static;
    width: 100%;
    margin-top: var(--lf-space-2);
  }

  .lf-brand {
    text-align: left;
  }

  .lf-brand h1 {
    font-size: 2.35rem;
  }

  .lf-lyric-stack p {
    font-size: 1.12rem;
  }

  .lf-target-line p {
    font-size: 1.45rem;
  }

  .lf-volume-control {
    grid-template-columns: auto minmax(0, 1fr) 44px;
  }

  .lf-volume-control input {
    width: 100%;
  }

  .lf-setup-grid,
  .lf-room-layout,
  .lf-social-grid {
    grid-template-columns: 1fr;
  }

  .lf-player-panel {
    position: static;
  }

  .lf-join-row,
  .lf-answer-row,
  .lf-chat-row {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lf-secondary-btn,
  .lf-home-link,
  .lf-primary-btn,
  .lf-danger-btn {
    transition: none;
  }
}
