:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --ink: #253243;
  --muted: #6b7280;
  --line: #111111;
  --button-border: 1.6px solid #111111;
  --primary: #0f8b8d;
  --primary-dark: #0a6668;
  --danger: #d1495b;
  --warning: #edae49;
  --success: #2a9d57;
  --shadow: 0 16px 45px rgba(33, 45, 60, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(15, 139, 141, 0.06), transparent 280px),
    var(--bg);
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  min-height: 38px;
  border: var(--button-border);
  border-radius: 8px;
  padding: 0 14px;
  color: #ffffff;
  background: var(--primary);
  cursor: pointer;
  transition: transform 0.14s ease, background 0.14s ease, border-color 0.14s ease;
}

button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

input,
textarea,
select {
  width: 100%;
  min-height: 40px;
  border: var(--button-border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: #ffffff;
}

.passphrase-input {
  min-width: 0;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.84rem;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-bar {
  min-height: 58px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 clamp(14px, 3vw, 34px);
  border-bottom: var(--button-border);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.brand-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.brand-link:hover {
  color: var(--ink);
}

.brand img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.brand span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.collapsed-panel-actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.header-expand-button {
  min-height: 32px;
  white-space: nowrap;
}

.account-button {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guest-account-label {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-color: transparent;
  color: var(--muted);
  background: transparent;
  cursor: default;
  user-select: none;
}

.guest-account-label:hover {
  color: var(--muted);
  background: transparent;
  transform: none;
}

.role-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: var(--button-border);
  border-radius: 8px;
  background: #ffffff;
}

.role-chip {
  min-height: 30px;
  padding: 0 10px;
  border: var(--button-border);
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  white-space: nowrap;
}

.role-chip:hover {
  color: var(--ink);
  background: #eef2f7;
}

.role-chip.active {
  color: #ffffff;
  background: var(--primary);
}

.icon-button {
  width: 40px;
  min-width: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: #eef2f7;
}

.icon-button:hover {
  color: #ffffff;
  background: var(--ink);
}

.mono-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.quiet-button {
  color: var(--ink);
  border: var(--button-border);
  background: #ffffff;
}

.quiet-button:hover {
  color: var(--ink);
  background: #f0f3f8;
}

.danger-button {
  background: var(--danger);
}

.danger-button:hover {
  background: #aa3242;
}

.lobby-layout,
.creation-layout {
  width: min(1180px, calc(100% - 28px));
  margin: 26px auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
}

.creation-layout {
  grid-template-columns: 1fr;
}

.lobby-main,
.profile-panel,
.arena-panel,
.side-panel,
.chat-panel,
.stat-panel,
.invite-panel,
.rule-panel {
  border: var(--button-border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.lobby-main,
.profile-panel,
.arena-panel,
.side-panel {
  padding: clamp(14px, 2.2vw, 22px);
}

.section-head,
.panel-head,
.band-head,
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.section-head h1,
.modal-head h2,
.band-head h2 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 2.25rem);
  line-height: 1.1;
}

.section-head.compact h1 {
  font-size: clamp(1.2rem, 2vw, 1.7rem);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.room-table-wrap {
  overflow-x: auto;
}

.room-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.room-table th,
.room-table td {
  padding: 13px 10px;
  border-bottom: var(--button-border);
  text-align: left;
  vertical-align: middle;
}

.room-table th {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.room-table tr:last-child td {
  border-bottom: 0;
}

.room-create-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.room-create-card {
  min-height: 190px;
  display: grid;
  align-content: space-between;
  gap: 14px;
  border: var(--button-border);
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
}

.room-create-card.open {
  background: #f7f9fc;
}

.room-create-card h2 {
  margin: 12px 0 4px;
  font-size: 1.18rem;
}

.room-create-card p {
  margin: 0;
  color: var(--muted);
}

.room-create-meta {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.84rem;
}

.room-name,
.connection-count {
  display: grid;
  gap: 3px;
}

.room-name span,
.connection-count span {
  color: var(--muted);
  font-size: 0.82rem;
}

.status-pill,
.connection-badge,
.role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.status-open,
.connection-badge,
.role-badge {
  color: #ffffff;
  background: var(--success);
}

.status-closed {
  color: var(--muted);
  background: #eef2f7;
}

.connection-badge.reconnecting {
  background: var(--warning);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.row-actions button {
  min-height: 34px;
  padding: 0 10px;
}

.profile-panel {
  align-self: start;
  display: grid;
  gap: 14px;
}

.mini-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mini-board div,
.stat-cell {
  min-height: 74px;
  display: grid;
  place-items: center;
  border: var(--button-border);
  border-radius: 8px;
  background: #fafbfe;
}

.mini-board strong,
.stat-cell strong {
  font-size: 1.5rem;
}

.mini-board span,
.stat-cell span {
  color: var(--muted);
  font-size: 0.78rem;
}

.room-layout {
  flex: 1;
  width: min(1380px, calc(100% - 22px));
  margin: 16px auto 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 14px;
}

.room-layout.chat-collapsed {
  grid-template-columns: minmax(0, 1fr);
}

.header-toggle-footer {
  width: min(1380px, calc(100% - 22px));
  margin: 0 auto 24px;
  display: flex;
  justify-content: center;
}

.header-toggle-card {
  width: auto;
  max-width: 100%;
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: center;
  gap: 8px;
  border: var(--button-border);
  border-radius: 8px;
  padding: 8px;
  background: #ffffff;
}

.header-toggle-label {
  min-width: 0;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  color: var(--ink);
  font-size: inherit;
  font-weight: 400;
  overflow-wrap: anywhere;
}

.header-toggle-option {
  min-width: 0;
  min-height: 38px;
  border: var(--button-border);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #ffffff;
  box-shadow: none;
  font-size: inherit;
  font-weight: 400;
}

.header-toggle-option:hover {
  color: var(--ink);
  background: #f0f3f8;
}

.header-toggle-option.active,
.header-toggle-option.active:hover {
  color: var(--ink);
  background: #f5a400;
  box-shadow: none;
  transform: none;
}

.room-shell.header-hidden .room-delete-header {
  top: 0;
}

.arena-panel {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 14px;
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.arena-panel > .question-display-panel {
  margin-bottom: 0;
}

.participants-panel {
  display: grid;
  gap: 12px;
  border: var(--button-border);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
  box-shadow: none;
}

.participants-panel-head {
  margin-bottom: 0;
}

.side-panel {
  min-height: 0;
  display: grid;
  grid-auto-rows: auto;
  gap: 14px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.round-state {
  min-width: 108px;
  min-height: 58px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
  border: var(--button-border);
  border-radius: 8px;
  color: #ffffff;
  background: var(--ink);
}

.room-status-head {
  justify-content: flex-end;
}

.round-state strong,
.round-state span {
  line-height: 1;
}

.round-state span {
  font-size: 0.78rem;
}

.question-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.question-step .tiny-button {
  min-width: 34px;
  min-height: 26px;
  border: var(--button-border);
  color: #ffffff;
  background: rgba(255, 255, 255, 0.24);
}

.question-step .tiny-button:hover {
  background: rgba(255, 255, 255, 0.38);
}

.question-step .pm-button {
  color: #111111;
  background: #ffffff;
  border: var(--button-border);
}

.question-step .pm-button:hover {
  color: #ffffff;
  background: #111111;
}

.round-reset-button {
  min-height: 28px;
  padding: 0 10px;
  border: var(--button-border);
  color: #ffffff;
  background: rgba(255, 255, 255, 0.16);
}

.round-state.judging .round-reset-button {
  border: var(--button-border);
  color: var(--ink);
}

.round-reset-button:hover,
.round-state.judging .round-reset-button:hover {
  color: #ffffff;
  background: var(--ink);
}

.round-state.open {
  background: var(--success);
}

.round-state.judging {
  background: var(--warning);
  color: var(--ink);
}

.round-state.closed {
  background: var(--danger);
}

.delete-request-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  border: var(--button-border);
  border-radius: 8px;
  padding: 10px;
  background: rgba(209, 73, 91, 0.08);
}

.room-delete-header {
  width: min(1380px, calc(100% - 22px));
  margin: 10px auto 0;
  position: sticky;
  top: 58px;
  z-index: 4;
}

.delete-request-panel div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.delete-request-panel span {
  color: var(--muted);
  font-size: 0.82rem;
}

.arena-top-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.arena-top-row .round-state {
  justify-self: end;
}

.provider-strip {
  min-height: 36px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.provider-strip span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--muted);
  background: #eef2f7;
}

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

.primary-player-grid {
  grid-template-columns: 1fr;
}

.player-card {
  min-height: 154px;
  display: grid;
  align-content: start;
  gap: 10px;
  border: var(--button-border);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
  box-shadow: inset 5px 0 0 #aab4c3;
}

.player-card.own-card {
  grid-column: 1 / -1;
}

.primary-player-grid .player-card.own-card {
  grid-column: auto;
}

.player-card.slashed {
  box-shadow: inset 5px 0 0 var(--warning);
}

.player-card.correct,
.player-card.winner {
  box-shadow: inset 5px 0 0 var(--success);
}

.player-card.wrong,
.player-card.eliminated {
  box-shadow: inset 5px 0 0 var(--danger);
}

.player-card.locked {
  box-shadow: inset 5px 0 0 #8b5cf6;
}

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

.player-name {
  min-width: 0;
  display: grid;
  gap: 3px;
}

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

.player-avatar {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: var(--button-border);
  object-fit: cover;
  background: #ffffff;
}

.player-name strong,
.player-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-name span,
.meter-row {
  color: var(--muted);
  font-size: 0.82rem;
}

.score-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(56px, auto));
  gap: 6px;
}

.score-box {
  min-height: 54px;
  min-width: 56px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 2px;
  border-radius: 8px;
  border: var(--button-border);
  font-weight: 800;
  background: #f7f9fc;
}

.score-box span {
  font-size: 0.7rem;
  line-height: 1;
}

.score-box strong {
  font-size: 1.45rem;
  line-height: 1;
}

.score-adjust {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.score-adjust .tiny-button {
  min-width: 30px;
  min-height: 24px;
}

.score-box-correct {
  color: #1f6d42;
  border: var(--button-border);
  background: rgba(42, 157, 87, 0.09);
}

.score-box-wrong {
  color: #8f2130;
  border: var(--button-border);
  background: rgba(209, 73, 91, 0.1);
}

.meter-row,
.card-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.meter-row span {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 8px;
  background: #f1f4f8;
}

.player-board {
  display: grid;
  gap: 7px;
  border: var(--button-border);
  border-radius: 8px;
  padding: 9px;
  background: #fafbfe;
}

.player-board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.player-board-head strong {
  font-size: 0.86rem;
}

.board-toggle-button {
  min-width: 96px;
}

.board-answer {
  display: grid;
  gap: 8px;
}

.board-answer.with-image {
  align-items: start;
}

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

.board-answer.layout-side {
  grid-template-columns: minmax(180px, 44%) minmax(0, 1fr);
}

.board-answer.layout-side p {
  grid-column: 2;
  grid-row: 1;
}

.board-answer.layout-side .board-answer-image {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
}

.board-answer p {
  margin: 0;
  min-height: 26px;
  overflow-wrap: anywhere;
}

.board-answer-image,
.question-display-image {
  display: block;
  max-width: 100%;
  max-height: 360px;
  border: var(--button-border);
  border-radius: 8px;
  object-fit: contain;
  background: #f7f9fc;
}

.card-actions button {
  flex: 1 1 74px;
  min-height: 34px;
}

.tiny-button {
  min-width: 42px;
  min-height: 28px;
  border: var(--button-border);
  padding: 0 8px;
  color: var(--ink);
  background: #eef2f7;
}

.pm-button {
  border: var(--button-border);
  color: #111111;
  background: #ffffff;
  font-weight: 800;
}

.pm-button:hover {
  color: #ffffff;
  background: #111111;
}

.stat-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px;
  box-shadow: none;
}

.compact-panel-head {
  margin-bottom: 0;
}

.panel-title-row {
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.panel-title-row .eyebrow {
  margin: 0;
}

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.panel-actions .tiny-button {
  min-width: 56px;
}

.question-display-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  border: var(--button-border);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
  box-shadow: none;
}

.question-display-panel.is-collapsed {
  gap: 0;
}

.question-display-body,
.question-display-form {
  display: grid;
  gap: 10px;
}

.question-display-form textarea {
  min-height: 120px;
  resize: vertical;
}

.question-display-form.is-locked textarea {
  color: var(--muted);
  background: #edf1f5;
}

.question-display-form.is-locked .draft-image-preview button {
  display: none;
}

.question-display-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.question-display-actions .draft-image-preview.show {
  margin-right: auto;
}

.question-display-text {
  min-height: 96px;
  display: grid;
  gap: 12px;
  border: var(--button-border);
  border-radius: 8px;
  padding: 14px;
  color: var(--ink);
  background: #fafbfe;
  font-size: clamp(1.05rem, 2vw, 1.45rem);
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.question-display-text.with-image {
  align-items: start;
}

.question-display-text.layout-wide {
  grid-template-columns: 1fr;
}

.question-display-text.layout-side {
  grid-template-columns: minmax(180px, 44%) minmax(0, 1fr);
}

.question-display-text.layout-side p {
  grid-column: 2;
  grid-row: 1;
}

.question-display-text.layout-side .question-display-image {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
}

.question-display-text p {
  margin: 0;
}

.question-display-text.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.chat-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  box-shadow: none;
}

.chat-panel.is-collapsed {
  grid-template-rows: auto;
}

.chat-panel-body {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
}

.chat-capacity {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.invite-panel,
.rule-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  box-shadow: none;
}

.invite-panel .panel-head,
.rule-panel .panel-head {
  margin-bottom: 0;
}

.copy-label {
  display: grid;
  gap: 6px;
}

.copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.copy-row input {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-form {
  display: grid;
  gap: 10px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

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

.rule-summary div {
  min-height: 58px;
  display: grid;
  align-content: center;
  gap: 3px;
  border: var(--button-border);
  border-radius: 8px;
  padding: 8px;
  background: #fafbfe;
}

.rule-summary span {
  color: var(--muted);
  font-size: 0.76rem;
}

.rule-summary strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.info-section {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.info-section:first-of-type {
  margin-top: 0;
}

.info-section h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.info-url {
  display: grid;
  gap: 6px;
}

.participant-list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.participant-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: var(--button-border);
  border-radius: 8px;
  padding: 8px;
  background: #ffffff;
}

.participant-item img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: var(--button-border);
  object-fit: cover;
  background: #ffffff;
}

.participant-item div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.participant-item strong,
.participant-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participant-item span {
  color: var(--muted);
  font-size: 0.78rem;
}

.chat-log {
  min-height: 260px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 8px;
  padding-right: 3px;
}

.chat-message {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 2px 8px;
  border: var(--button-border);
  border-radius: 8px;
  padding: 8px;
  background: #ffffff;
}

.chat-message span {
  color: var(--muted);
  font-size: 0.76rem;
}

.chat-message strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-message p {
  grid-column: 1 / -1;
  margin: 0;
  overflow-wrap: anywhere;
}

.chat-delete-button {
  min-height: 24px;
  padding: 0 8px;
  border: var(--button-border);
  color: var(--muted);
  background: #ffffff;
  font-size: 0.76rem;
}

.chat-delete-button:hover {
  color: #ffffff;
  background: var(--danger);
}

.chat-image-button {
  grid-column: 1 / -1;
  justify-self: start;
  min-height: 0;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
}

.chat-image-button:hover {
  background: transparent;
  transform: none;
}

.chat-image {
  display: block;
  max-width: 100%;
  max-height: 320px;
  border: var(--button-border);
  border-radius: 8px;
  object-fit: contain;
  background: #f7f9fc;
}

.chat-image-preview.show {
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px;
  align-items: center;
  padding-right: 8px;
  border-right: var(--button-border);
}

.chat-image-preview img {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  border: var(--button-border);
  object-fit: cover;
  background: #f7f9fc;
}

.chat-image-preview.is-empty img,
.draft-image-preview.is-empty img {
  opacity: 0.78;
}

.image-input-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.draft-image-preview.show {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: var(--button-border);
  border-radius: 8px;
  padding: 6px;
  background: #fafbfe;
}

.draft-image-preview img {
  width: 72px;
  height: 72px;
  border: var(--button-border);
  border-radius: 8px;
  object-fit: cover;
  background: #ffffff;
}

.file-button {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: var(--button-border);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.action-file-button {
  min-height: 38px;
  padding: 0 14px;
  font-weight: 400;
}

.file-button input {
  display: none;
}

.image-modal {
  max-width: 100%;
  overflow: auto;
}

.chat-image-full {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
}

.chat-message.system {
  color: var(--muted);
  background: #f4f7fb;
}

.chat-form,
.board-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.chat-form {
  margin: 0;
}

.chat-composer {
  min-width: 0;
  min-height: 54px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  border: var(--button-border);
  border-radius: 8px;
  padding: 6px;
  background: #ffffff;
}

.chat-composer:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.12);
}

.chat-composer textarea {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 82px;
  border: 0;
  padding: 4px;
  outline: none;
  resize: vertical;
}

.board-editor {
  margin-top: 10px;
  display: block;
}

.board-composer {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: start;
}

.board-composer textarea {
  min-height: 96px;
  resize: vertical;
}

.chat-action-stack,
.board-action-stack {
  width: 64px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.chat-action-stack .file-button,
.chat-action-stack button,
.board-action-stack .file-button,
.board-action-stack button {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 0 8px;
}

.confirm-message {
  margin: 4px 0 18px;
  line-height: 1.7;
}

.controller {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: fixed;
  left: 50%;
  bottom: 12px;
  width: min(1380px, calc(100% - 22px));
  transform: translateX(-50%);
  border: var(--button-border);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  z-index: 4;
}

.controller-left,
.controller-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.primary-control {
  width: 58px;
  min-width: 58px;
  min-height: 58px;
  padding: 0;
  font-size: 1.4rem;
  background: var(--success);
}

.slash-button {
  min-width: 230px;
  min-height: 62px;
  display: grid;
  place-items: center;
  background: var(--danger);
}

.slash-button.in-card {
  width: 100%;
  min-width: 0;
  min-height: 54px;
  border-radius: 8px;
}

.slash-button.slashed-button {
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  padding: 6px 12px;
}

.slash-button:hover {
  background: #aa3242;
}

.slash-button.slashed-button:disabled {
  opacity: 1;
  color: #ffffff;
  background: var(--ink);
}

.slash-button span,
.slash-button strong {
  line-height: 1;
}

.slash-button .slash-rank {
  grid-row: 1 / span 2;
  align-self: center;
  justify-self: start;
  min-width: 48px;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 900;
}

.slash-button .slash-label {
  justify-self: center;
}

.slash-button span {
  font-size: 0.78rem;
}

.slash-button strong {
  font-size: 1.55rem;
}

.player-controller {
  justify-content: flex-start;
}

.spectator-note {
  width: 100%;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.empty-state {
  min-height: 80px;
  display: grid;
  place-items: center;
  border: var(--button-border);
  border-radius: 8px;
  color: var(--muted);
  background: #fafbfe;
}

.detached-shell {
  min-height: 100vh;
}

.detached-top-bar {
  position: static;
}

.detached-layout {
  flex: 1;
  min-height: 0;
  width: min(920px, calc(100% - 22px));
  margin: 14px auto;
  display: grid;
}

.detached-panel {
  min-height: 0;
  margin-bottom: 0;
}

.detached-layout .chat-panel {
  height: calc(100vh - 92px);
}

.detached-layout .chat-log {
  min-height: 0;
}

.detached-layout .question-display-panel {
  align-self: start;
}

.detached-layout .question-display-text {
  min-height: min(62vh, 520px);
  font-size: clamp(1.35rem, 4vw, 2.4rem);
}

.detached-layout .question-display-image {
  max-height: calc(100vh - 190px);
}

.loading-view {
  flex: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
}

.pulse {
  width: 44px;
  height: 44px;
  border: 5px solid #d8dee9;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(37, 50, 67, 0.38);
  z-index: 20;
}

.modal {
  width: min(680px, 100%);
  max-height: min(820px, calc(100vh - 36px));
  overflow: auto;
  border-radius: 8px;
  padding: 18px;
  background: #ffffff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
}

.avatar-edit {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.avatar-edit img {
  width: 96px;
  height: 96px;
  border-radius: 8px;
  border: var(--button-border);
  object-fit: cover;
  background: #ffffff;
}

.avatar-edit-fields {
  display: grid;
  gap: 8px;
}

.account-summary {
  display: grid;
  gap: 4px;
  border: var(--button-border);
  border-radius: 8px;
  padding: 10px;
  background: #fafbfe;
}

.account-summary span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.account-summary strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid.single {
  grid-template-columns: 1fr;
}

.form-error {
  margin: -4px 0 0;
  color: var(--danger);
  font-size: 0.92rem;
  font-weight: 700;
}

.form-error[hidden] {
  display: none;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.check-row span {
  margin: 0;
}

.modal-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.admin-layout {
  width: min(1120px, calc(100% - 28px));
  margin: 18px auto 34px;
}

.admin-panel,
.admin-notice,
.report-card {
  border: var(--button-border);
  border-radius: 8px;
  background: #ffffff;
}

.admin-panel {
  padding: 16px;
}

.admin-notice {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.admin-notice h2,
.admin-notice p {
  margin: 0;
}

.report-list {
  display: grid;
  gap: 12px;
}

.report-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.report-card.resolved {
  background: #f8fafc;
}

.report-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.report-card-head h2 {
  margin: 8px 0 0;
  font-size: 1rem;
}

.report-message {
  margin: 0;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.report-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin: 0;
}

.report-meta div,
.report-context {
  min-width: 0;
  border: var(--button-border);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fafbfe;
}

.report-meta dt,
.report-context span,
.subtle-note {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.report-meta dd,
.report-context strong {
  display: block;
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}

.subtle-note {
  margin: -4px 0 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 104px;
  max-width: min(460px, calc(100% - 28px));
  padding: 10px 14px;
  border-radius: 8px;
  color: #ffffff;
  background: var(--ink);
  box-shadow: var(--shadow);
  transform: translate(-50%, 10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 30;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 960px) {
  .lobby-layout,
  .room-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-auto-rows: auto;
  }

  .controller {
    position: static;
    width: min(1380px, calc(100% - 22px));
    margin: 0 auto 12px;
    transform: none;
    flex-wrap: wrap;
  }

  .room-layout {
    margin-bottom: 14px;
  }
}

@media (max-width: 680px) {
  .top-bar {
    padding: 0 10px;
  }

  .brand span {
    max-width: 180px;
  }

  .section-head,
  .modal-head,
  .compact-panel-head,
  .controller {
    align-items: stretch;
  }

  .role-switch {
    width: 100%;
    justify-content: stretch;
  }

  .role-chip {
    flex: 1;
    min-width: 0;
  }

  .report-card-head,
  .report-meta {
    grid-template-columns: 1fr;
  }

  .report-card-head {
    display: grid;
  }

  .section-head,
  .controller,
  .provider-controller,
  .player-controller,
  .delete-request-panel {
    flex-direction: column;
  }

  .form-grid,
  .stat-panel,
  .settings-grid,
  .rule-summary,
  .board-answer.layout-side,
  .question-display-text.layout-side {
    grid-template-columns: 1fr;
  }

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

  .arena-top-row {
    grid-template-columns: 1fr;
  }

  .arena-top-row .round-state {
    justify-self: stretch;
  }

  .slash-button {
    width: 100%;
    min-width: 0;
  }

  .chat-form,
  .board-editor,
  .board-composer,
  .question-display-actions {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .chat-form,
  .board-editor,
  .board-composer {
    display: grid;
  }

  .chat-action-stack,
  .board-action-stack {
    width: 100%;
  }

  .chat-action-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .question-display-actions {
    flex-direction: column;
  }

  .panel-actions {
    justify-content: stretch;
  }

  .panel-actions .tiny-button {
    flex: 1 1 72px;
  }

  .avatar-edit {
    grid-template-columns: 1fr;
  }

  .controller-left,
  .controller-right {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .primary-control {
    width: 100%;
  }
}

