:root {
  color-scheme: light;
  --paper: #f6f0e5;
  --paper-deep: #eee4d3;
  --surface: rgba(255, 252, 246, 0.92);
  --surface-solid: #fffcf6;
  --ink: #202b2b;
  --muted: #6f7772;
  --line: rgba(39, 50, 48, 0.14);
  --line-strong: rgba(39, 50, 48, 0.25);
  --terracotta: #b6533f;
  --terracotta-dark: #8f3c2e;
  --terracotta-soft: #efd6cc;
  --sage: #527265;
  --sage-soft: #d9e4dc;
  --gold: #b58235;
  --gold-soft: #f0dfba;
  --danger: #9b3e3b;
  --shadow: 0 18px 45px rgba(68, 53, 35, 0.09);
  --shadow-small: 0 8px 24px rgba(68, 53, 35, 0.08);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --serif: "Iowan Old Style", "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
  --sans: Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 5%, rgba(195, 111, 82, 0.12), transparent 28rem),
    radial-gradient(circle at 90% 72%, rgba(76, 111, 94, 0.1), transparent 32rem),
    var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.is-dialog-open {
  overflow: hidden;
}

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

button {
  border: 0;
}

button:not(:disabled) {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(182, 83, 63, 0.24);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.page-noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.2;
  background-image: repeating-linear-gradient(100deg, transparent 0, transparent 9px, rgba(69, 56, 39, 0.025) 10px);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100% - 32px, 1180px);
  min-height: 80px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 0 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 4px;
  text-align: left;
  background: transparent;
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}

.brand-mark::before {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--terracotta);
  content: "";
}

.brand-mark i {
  position: absolute;
  width: 17px;
  height: 17px;
  border: 1px solid var(--ink);
  border-radius: 50%;
}

.brand-mark i:nth-child(1) { transform: translate(-7px, 1px); }
.brand-mark i:nth-child(2) { transform: translate(7px, 1px); }
.brand-mark i:nth-child(3) { transform: translateY(-7px); }

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.08em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 252, 246, 0.62);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #aaa49a;
}

.connection-pill[data-state="online"] {
  color: var(--sage);
  border-color: rgba(82, 114, 101, 0.26);
  background: rgba(217, 228, 220, 0.52);
}

.connection-pill[data-state="online"] .status-dot {
  background: #52916f;
  box-shadow: 0 0 0 4px rgba(82, 145, 111, 0.12);
}

.connection-pill[data-state="connecting"] .status-dot {
  background: var(--gold);
  animation: soft-pulse 1.1s ease-in-out infinite;
}

.connection-pill[data-state="error"] .status-dot {
  background: var(--danger);
}

main {
  width: min(100% - 32px, 1180px);
  margin: 0 auto;
  padding: 34px 0 calc(72px + env(safe-area-inset-bottom));
}

.entrance-view {
  display: grid;
  max-width: 950px;
  margin: 1.5vh auto 0;
}

.hero-copy {
  max-width: 650px;
  padding: 24px 4px 34px;
}

.eyebrow,
.mini-label {
  margin: 0;
  color: var(--terracotta);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero-copy h1 {
  max-width: 760px;
  margin: 14px 0 18px;
  font-family: var(--serif);
  font-size: clamp(38px, 11vw, 72px);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.04em;
}

.hero-copy h1 em {
  color: var(--terracotta);
  font-style: normal;
}

.hero-description {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.85;
}

.entrance-card,
.surface {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-small);
  backdrop-filter: blur(14px);
}

.entrance-card {
  padding: 7px;
  border-radius: var(--radius-xl);
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 18px;
  background: rgba(39, 50, 48, 0.055);
}

.mode-tab {
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 14px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  transition: 160ms ease;
}

.mode-tab.is-active {
  color: var(--ink);
  background: var(--surface-solid);
  box-shadow: 0 3px 14px rgba(68, 53, 35, 0.08);
}

.mode-panel {
  padding: 24px 16px 17px;
}

form label {
  display: block;
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.62);
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

input {
  height: 51px;
  padding: 0 15px;
  margin-bottom: 17px;
}

textarea {
  min-height: 100px;
  padding: 13px 14px;
  resize: vertical;
  line-height: 1.6;
}

input::placeholder,
textarea::placeholder {
  color: #a29e95;
}

input:focus,
textarea:focus {
  border-color: rgba(182, 83, 63, 0.65);
  background: #fffdfa;
  box-shadow: 0 0 0 4px rgba(182, 83, 63, 0.08);
  outline: none;
}

.room-code-input {
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.field-hint {
  margin: -7px 0 18px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.primary-button,
.secondary-button,
.quiet-button,
.danger-button,
.text-button,
.icon-text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  border-radius: 13px;
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
  transition: transform 140ms ease, background 140ms ease, opacity 140ms ease, box-shadow 140ms ease;
}

.primary-button {
  padding: 12px 17px;
  color: white;
  background: var(--terracotta);
  box-shadow: 0 8px 18px rgba(182, 83, 63, 0.2);
}

.primary-button:not(:disabled):hover {
  background: var(--terracotta-dark);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(143, 60, 46, 0.23);
}

.secondary-button {
  padding: 11px 17px;
  color: var(--terracotta-dark);
  border: 1px solid rgba(182, 83, 63, 0.25);
  background: var(--terracotta-soft);
}

.quiet-button,
.danger-button {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.72);
}

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

.text-button,
.icon-text-button {
  min-height: 38px;
  padding: 7px 10px;
  color: var(--terracotta-dark);
  background: transparent;
}

.primary-button:disabled,
.secondary-button:disabled,
.quiet-button:disabled,
.danger-button:disabled,
.text-button:disabled,
.icon-text-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.full-width {
  width: 100%;
}

.resume-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 10px 10px;
  padding: 13px 12px 13px 15px;
  border: 1px dashed rgba(182, 83, 63, 0.3);
  border-radius: 15px;
  background: rgba(239, 214, 204, 0.33);
}

.resume-panel strong {
  display: block;
  margin-top: 3px;
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: 0.08em;
}

.agent-manager-entry {
  display: grid;
  gap: 12px;
  margin: 0 10px 10px;
  padding: 14px 13px;
  border: 1px solid rgba(82, 114, 101, 0.2);
  border-radius: 15px;
  background: rgba(217, 228, 220, 0.28);
}

.agent-manager-entry p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

.agent-manager-entry .secondary-button {
  width: 100%;
}

.fair-play-note {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  max-width: 520px;
  margin: 26px auto 0;
  color: var(--muted);
}

.note-symbol {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(82, 114, 101, 0.28);
  border-radius: 50%;
  color: var(--sage);
}

.fair-play-note p {
  margin: 1px 0 0;
  font-size: 11px;
  line-height: 1.65;
}

.fair-play-note strong {
  color: var(--ink);
}

.open-rooms-panel {
  grid-column: 1 / -1;
  margin-top: 28px;
  padding: 18px;
  border-radius: var(--radius-xl);
}

.open-rooms-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.open-rooms-heading h2 {
  margin: 5px 0 0;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 550;
}

.open-rooms-refresh {
  display: flex;
  align-items: center;
  gap: 8px;
}

.open-rooms-refresh > span {
  color: var(--muted);
  font-size: 9px;
}

.open-rooms-intro {
  margin: 8px 0 15px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.open-rooms-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 10px;
}

.open-room-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(82, 114, 101, 0.21);
  border-radius: 15px;
  background: rgba(217, 228, 220, 0.25);
  text-align: left;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.open-room-card:hover {
  border-color: rgba(82, 114, 101, 0.42);
  background: rgba(217, 228, 220, 0.48);
  box-shadow: 0 8px 20px rgba(52, 67, 61, 0.08);
  transform: translateY(-1px);
}

.open-room-card:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  transform: none;
}

.open-room-card-top,
.open-room-owner,
.open-room-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
}

.open-room-code {
  overflow: hidden;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.open-room-badge {
  flex: 0 0 auto;
  padding: 4px 7px;
  border-radius: 999px;
  color: var(--sage);
  background: rgba(255, 255, 255, 0.6);
  font-size: 8px;
  font-weight: 750;
}

.open-room-owner {
  justify-content: flex-start;
  margin: 9px 0 11px;
  color: var(--muted);
  font-size: 9px;
}

.open-room-owner strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.open-room-progress {
  align-items: stretch;
}

.open-room-stat {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(39, 50, 48, 0.09);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.45);
}

.open-room-stat small,
.open-room-stat strong {
  display: block;
}

.open-room-stat small {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 8px;
}

.open-room-stat strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.open-room-composition {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.open-room-composition span {
  padding: 5px 7px;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.42);
  font-size: 8px;
}

.open-room-composition .has-human-space {
  color: var(--terracotta-dark);
  background: var(--terracotta-soft);
}

.open-rooms-placeholder {
  grid-column: 1 / -1;
  display: grid;
  justify-items: center;
  gap: 8px;
  min-height: 118px;
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
}

.open-rooms-placeholder p {
  max-width: 330px;
  margin: 0;
  font-size: 10px;
  line-height: 1.65;
}

.open-rooms-placeholder strong {
  color: var(--ink);
  font-size: 11px;
}

.open-rooms-placeholder .secondary-button {
  min-height: 36px;
  padding-block: 7px;
}

.open-rooms-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(82, 114, 101, 0.18);
  border-top-color: var(--sage);
  border-radius: 50%;
  animation: rotate 0.8s linear infinite;
}

.room-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 15px;
  margin: 8px 0 22px;
}

.room-heading h1 {
  margin: 5px 0 0;
  font-family: var(--serif);
  font-size: clamp(31px, 8vw, 49px);
  font-weight: 500;
  letter-spacing: -0.025em;
}

.room-heading h1 span {
  color: var(--terracotta);
  letter-spacing: 0.06em;
}

.room-code-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 9px;
}

.copy-icon {
  position: relative;
  width: 14px;
  height: 14px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
}

.copy-icon::before {
  position: absolute;
  top: -4px;
  left: -4px;
  width: 10px;
  height: 10px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  content: "";
}

.phase-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  padding: 20px;
  overflow: hidden;
  border: 1px solid rgba(82, 114, 101, 0.2);
  border-radius: var(--radius-lg);
  background: linear-gradient(120deg, rgba(217, 228, 220, 0.9), rgba(255, 252, 246, 0.78));
}

.phase-index {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(82, 114, 101, 0.34);
  border-radius: 50%;
  color: var(--sage);
  font-family: var(--serif);
  font-size: 22px;
}

.phase-banner p,
.phase-banner h2 {
  margin: 0;
}

.phase-banner > div:last-child {
  min-width: 0;
}

.phase-banner #phase-kicker {
  margin-bottom: 2px;
  color: var(--sage);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.12em;
}

.phase-banner h2 {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 550;
}

.phase-banner #phase-description {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.game-layout,
.main-column,
.side-column {
  display: grid;
  gap: 16px;
}

.surface {
  padding: 19px;
  border-radius: var(--radius-lg);
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 17px;
}

.section-heading h2 {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 550;
}

.section-meta {
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

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

.player-card {
  position: relative;
  min-width: 0;
  min-height: 120px;
  padding: 13px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.46);
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.player-card.is-current {
  border-color: rgba(182, 83, 63, 0.52);
  box-shadow: inset 0 0 0 1px rgba(182, 83, 63, 0.1), 0 7px 18px rgba(182, 83, 63, 0.09);
  transform: translateY(-1px);
}

.player-card.is-current::after {
  position: absolute;
  right: -19px;
  bottom: -22px;
  width: 65px;
  height: 65px;
  border: 10px solid rgba(182, 83, 63, 0.08);
  border-radius: 50%;
  content: "";
}

.player-card.is-dead {
  opacity: 0.56;
  filter: grayscale(0.35);
}

.player-card.is-empty {
  display: grid;
  place-items: center;
  border-style: dashed;
  color: #98978f;
  background: rgba(255, 255, 255, 0.2);
  text-align: center;
}

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

.player-avatar,
.timeline-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: var(--surface-solid);
  background: var(--sage);
  font-weight: 800;
}

.player-avatar {
  width: 36px;
  height: 36px;
  font-size: 11px;
}

.player-card.is-ai .player-avatar,
.timeline-avatar.is-ai {
  color: #6b4c17;
  background: var(--gold-soft);
}

.player-kind,
.player-state,
.you-badge {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(39, 50, 48, 0.06);
  font-size: 9px;
  font-weight: 750;
}

.player-card h3 {
  max-width: 100%;
  margin: 12px 0 5px;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-card p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.player-card.is-current .player-state {
  color: var(--terracotta-dark);
  background: var(--terracotta-soft);
}

.player-card.is-ready:not(.is-current) .player-state {
  color: var(--sage);
  background: var(--sage-soft);
}

.empty-seat-mark {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  margin: 0 auto 8px;
  border: 1px dashed var(--line-strong);
  border-radius: 50%;
  font-size: 17px;
}

.word-card {
  position: relative;
  padding: 21px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  color: #f8f1e5;
  background:
    radial-gradient(circle at 100% 0, rgba(241, 211, 174, 0.12), transparent 15rem),
    #263b37;
  box-shadow: var(--shadow);
}

.word-card::after {
  position: absolute;
  top: -80px;
  right: -52px;
  width: 190px;
  height: 190px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  box-shadow: 0 0 0 25px rgba(255, 255, 255, 0.025), 0 0 0 50px rgba(255, 255, 255, 0.015);
  content: "";
  pointer-events: none;
}

.word-card-topline {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.word-card .mini-label {
  color: #c3d8cd;
}

.word-card h2 {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 500;
}

.privacy-badge {
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  color: #c7d4cf;
  font-size: 9px;
}

.word-reveal {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  min-height: 105px;
  padding: 20px 0 10px;
  color: inherit;
  background: transparent;
  text-align: left;
}

.word-value {
  max-width: 100%;
  overflow: hidden;
  font-family: var(--serif);
  font-size: clamp(34px, 10vw, 48px);
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: filter 180ms ease, opacity 180ms ease;
}

.word-value.is-hidden {
  color: #acbeb7;
  letter-spacing: 0.18em;
  filter: blur(2px);
}

.word-action {
  margin-top: 7px;
  color: #a9bbb4;
  font-size: 10px;
}

.word-help {
  position: relative;
  z-index: 1;
  margin: 0;
  color: #a9bbb4;
  font-size: 10px;
  line-height: 1.6;
}

.timeline {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 11px;
  padding: 0 0 18px;
}

.timeline-item:not(:last-child)::before {
  position: absolute;
  top: 36px;
  bottom: 1px;
  left: 16px;
  width: 1px;
  background: var(--line);
  content: "";
}

.timeline-avatar {
  width: 34px;
  height: 34px;
  font-size: 10px;
}

.timeline-content {
  min-width: 0;
  padding-top: 1px;
}

.timeline-byline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 9px;
  margin-bottom: 4px;
}

.timeline-byline strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-byline span {
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.timeline-content blockquote {
  margin: 0;
  color: #404b48;
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.62;
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 22px 10px 24px;
  color: #aaa69c;
  text-align: center;
}

.empty-state span {
  display: block;
  height: 33px;
  font-family: var(--serif);
  font-size: 46px;
  line-height: 1;
}

.empty-state p {
  margin: 6px 0 0;
  font-size: 11px;
}

.compact-heading {
  align-items: center;
}

.turn-pulse {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--terracotta-dark);
  font-size: 10px;
  font-weight: 750;
}

.turn-pulse i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--terracotta);
  box-shadow: 0 0 0 5px rgba(182, 83, 63, 0.12);
  animation: soft-pulse 1.2s ease-in-out infinite;
}

.action-state > p {
  margin: 0 0 15px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.action-state .secondary-button,
.action-state .primary-button + .secondary-button {
  margin-top: 9px;
}

.waiting-orbit {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin: 9px auto 13px;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.waiting-orbit::before {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--sage);
  content: "";
}

.waiting-orbit i {
  position: absolute;
  inset: -1px;
  border-top: 1px solid var(--terracotta);
  border-radius: 50%;
  animation: rotate 2.4s linear infinite;
}

#waiting-action p {
  text-align: center;
}

.input-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 6px 1px 12px;
  color: var(--muted);
  font-size: 9px;
}

.vote-options {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.vote-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 45px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.5);
  text-align: left;
}

.vote-option span:first-child {
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vote-option small {
  color: var(--muted);
  font-size: 9px;
}

.vote-option.is-selected {
  color: var(--terracotta-dark);
  border-color: rgba(182, 83, 63, 0.48);
  background: rgba(239, 214, 204, 0.52);
  box-shadow: inset 0 0 0 1px rgba(182, 83, 63, 0.08);
}

.vote-progress {
  margin: 10px 0 0 !important;
  text-align: center;
}

.result-card {
  padding: 17px;
  border-radius: 15px;
  background: linear-gradient(140deg, rgba(217, 228, 220, 0.7), rgba(255, 252, 246, 0.9));
}

.result-overline {
  margin-bottom: 3px !important;
  color: var(--sage) !important;
  font-size: 9px !important;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.result-card h3 {
  margin: 0 0 7px;
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 550;
}

.result-words {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 13px;
}

.result-word {
  padding: 10px;
  border: 1px solid rgba(82, 114, 101, 0.2);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.54);
}

.result-word small,
.result-word strong {
  display: block;
}

.result-word small {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 8px;
}

.result-word strong {
  overflow: hidden;
  font-family: var(--serif);
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-roles {
  display: grid;
  gap: 5px;
  margin-top: 12px;
}

.result-role-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  font-size: 10px;
}

.result-role-row span:last-child {
  color: var(--muted);
}

.panel-intro,
.security-note {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.62;
}

.panel-intro {
  margin: -2px 0 14px;
}

.security-note {
  margin: 13px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.lock-symbol {
  color: var(--gold);
  font-size: 22px;
}

.ai-invites {
  display: grid;
  gap: 10px;
}

.ai-invite-card {
  padding: 13px;
  border: 1px solid rgba(181, 130, 53, 0.23);
  border-radius: 14px;
  background: rgba(240, 223, 186, 0.25);
}

.ai-invite-card.is-persistent {
  border-color: rgba(82, 114, 101, 0.24);
  background: rgba(217, 228, 220, 0.3);
}

.room-agent-summary {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.55;
}

.legacy-invites-heading {
  margin: 5px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.legacy-invites-heading strong {
  display: block;
  font-size: 10px;
}

.legacy-invites-heading span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.5;
}

.ai-invite-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  margin-bottom: 10px;
}

.ai-invite-heading strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invite-status {
  color: #795c28;
  font-size: 8px;
  font-weight: 750;
}

.secret-row {
  margin-top: 9px;
}

.secret-row > label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.secret-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px;
}

.secret-field code {
  display: block;
  min-width: 0;
  padding: 8px 9px;
  overflow: hidden;
  border: 1px solid rgba(39, 50, 48, 0.12);
  border-radius: 8px;
  color: #4d514c;
  background: rgba(255, 255, 255, 0.58);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tiny-button {
  min-width: 48px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.66);
  font-size: 9px;
  font-weight: 750;
}

.token-toggle-button {
  display: inline-block;
  margin-top: 5px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  font-size: 9px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ai-card-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

.ai-card-actions button {
  padding: 4px 0;
  color: var(--muted);
  background: transparent;
  font-size: 9px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.manage-agents-button {
  margin-top: 12px;
}

.toast-region {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 100;
  display: grid;
  width: min(360px, calc(100% - 32px));
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 13px;
  color: #f8f3e9;
  background: rgba(31, 43, 41, 0.95);
  box-shadow: 0 12px 32px rgba(23, 29, 28, 0.22);
  font-size: 11px;
  line-height: 1.5;
  animation: toast-in 180ms ease-out both;
}

.toast::before {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  margin-top: 5px;
  border-radius: 50%;
  background: #8fc0a6;
  content: "";
}

.toast.is-error::before {
  background: #e88d81;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(25, 33, 32, 0.48);
  backdrop-filter: blur(5px);
}

.dialog {
  width: min(100%, 430px);
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 22px;
  background: var(--surface-solid);
  box-shadow: 0 24px 70px rgba(23, 29, 28, 0.23);
  animation: dialog-in 180ms ease-out both;
}

.agent-manager-dialog {
  width: min(100%, 700px);
  max-height: min(88dvh, 760px);
  overflow: auto;
  overscroll-behavior: contain;
}

.agent-dialog-heading,
.registered-agent-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
}

.agent-dialog-heading h2 {
  margin-bottom: 0;
}

.agent-dialog-intro {
  margin-top: 12px !important;
}

.agent-register-form {
  margin-top: 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(245, 239, 228, 0.52);
}

.agent-form-fields {
  display: grid;
  gap: 0 12px;
}

.agent-form-fields label span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 500;
}

.registered-agent-section {
  margin-top: 22px;
}

.registered-agent-heading {
  align-items: flex-end;
  margin-bottom: 11px;
}

.registered-agent-heading h3 {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 550;
}

.registered-agent-heading > span {
  color: var(--muted);
  font-size: 10px;
}

.registered-agent-list {
  display: grid;
  gap: 10px;
}

.registered-agent-card {
  padding: 14px;
  border: 1px solid rgba(82, 114, 101, 0.22);
  border-radius: 15px;
  background: rgba(217, 228, 220, 0.27);
}

.registered-agent-card .ai-card-actions {
  flex-wrap: wrap;
}

.registered-agent-card .remove-agent-button {
  color: var(--danger);
}

.registered-agent-empty {
  margin: 0;
  padding: 17px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
  text-align: center;
}

.dialog h2 {
  margin: 6px 0 9px;
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 550;
}

.dialog > p:not(.mini-label) {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

noscript {
  display: block;
  margin: 20px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-solid);
  text-align: center;
}

.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.is-loading::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 15px;
  height: 15px;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-top-color: currentColor;
  border-radius: 50%;
  color: white;
  content: "";
  animation: rotate 0.8s linear infinite;
}

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

@keyframes soft-pulse {
  50% { opacity: 0.42; transform: scale(0.85); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
}

@media (min-width: 560px) {
  .site-header,
  main {
    width: min(100% - 48px, 1180px);
  }

  .entrance-card {
    padding: 9px;
  }

  .mode-panel {
    padding: 29px 24px 23px;
  }

  .agent-manager-entry {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .agent-manager-entry .secondary-button {
    width: auto;
  }

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

  .players-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .player-card {
    min-height: 132px;
  }

  .surface,
  .word-card {
    padding: 23px;
  }
}

@media (min-width: 820px) {
  main {
    padding-top: 52px;
  }

  .entrance-view {
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.8fr);
    column-gap: clamp(40px, 8vw, 95px);
    align-items: center;
    margin-top: 7vh;
  }

  .hero-copy {
    padding: 0;
  }

  .fair-play-note {
    grid-column: 1 / -1;
    justify-self: center;
    margin-top: 44px;
  }

  .open-rooms-panel {
    margin-top: 34px;
    padding: 22px;
  }

  .room-heading {
    margin-top: 18px;
  }

  .phase-banner {
    padding: 21px 25px;
  }
}

@media (min-width: 980px) {
  .game-layout {
    grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.72fr);
    align-items: start;
  }

  .side-column {
    position: sticky;
    top: 20px;
  }

  .word-card {
    min-height: 237px;
  }

  .surface {
    border-radius: 23px;
  }
}

@media (max-width: 420px) {
  .brand small {
    display: none;
  }

  .connection-pill {
    padding-inline: 9px;
  }

  .room-heading {
    align-items: flex-start;
  }

  .room-heading > .quiet-button {
    margin-top: 16px;
  }

  .icon-text-button {
    padding-left: 4px;
  }

  .open-rooms-heading {
    align-items: flex-start;
  }

  .open-rooms-refresh {
    flex-direction: column;
    align-items: flex-end;
  }

  .agent-manager-dialog {
    max-height: calc(100dvh - 20px);
    padding: 18px;
    border-radius: 18px;
  }

  .agent-dialog-heading .quiet-button {
    min-height: 34px;
    padding-inline: 10px;
  }
}

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

/* --- Phase countdown & timeout aesthetics (bond, 2026-07-13) --- */

.phase-countdown {
  margin-left: auto;
  flex-shrink: 0;
  padding: 8px 14px;
  border: 1px solid rgba(82, 114, 101, 0.28);
  border-radius: 999px;
  background: rgba(255, 252, 246, 0.85);
  font-family: var(--serif);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--sage);
}

.phase-countdown.is-urgent {
  border-color: rgba(182, 83, 63, 0.45);
  background: var(--terracotta-soft);
  color: var(--terracotta-dark);
  animation: countdown-breathe 1.2s ease-in-out infinite;
}

@keyframes countdown-breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

@media (prefers-reduced-motion: reduce) {
  .phase-countdown.is-urgent { animation: none; }
}

.timeline-item.is-timeout .timeline-content blockquote {
  font-style: italic;
  color: var(--muted);
}

.timeline-item.is-timeout .timeline-avatar {
  opacity: 0.55;
}
