:root {
  --ink: #0b0a09;
  --cream: #f3e7d3;
  --amber: #e8a23a;
  --amber-hot: #ffb347;
  --muted: rgba(243, 231, 211, 0.72);
  --line: rgba(232, 162, 58, 0.28);
  --panel: rgba(255, 255, 255, 0.035);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: "Outfit", sans-serif;
  color: var(--cream);
  background: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(232, 162, 58, 0.18), transparent 45%),
    radial-gradient(ellipse at 80% 100%, rgba(255, 179, 71, 0.1), transparent 40%),
    linear-gradient(180deg, #14110d 0%, #0b0a09 55%, #070605 100%);
}

.grain {
  position: fixed;
  inset: -12%;
  z-index: -1;
  pointer-events: none;
  opacity: 0.12;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.4'/%3E%3C/svg%3E");
  animation: grain 1.2s steps(2) infinite;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem clamp(1rem, 4vw, 2.5rem);
}

.mark {
  font-family: "Fraunces", serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.88rem;
}

.nav {
  display: flex;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.nav a:hover {
  color: var(--amber);
}

.lobby,
.room {
  width: min(980px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1rem 0 3rem;
}

.eyebrow {
  color: var(--amber);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 0.7rem;
}

.brand {
  font-family: "Fraunces", serif;
  font-weight: 800;
  font-size: clamp(2.6rem, 8vw, 5rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  margin-bottom: 0.85rem;
}

.brand span {
  background: linear-gradient(120deg, #fff4de 0%, #ffd28a 40%, #e8a23a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lead {
  max-width: 36rem;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 1.4rem;
}

.field {
  display: grid;
  gap: 0.4rem;
  max-width: 360px;
  margin-bottom: 1.25rem;
}

.field span {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

input {
  width: 100%;
  min-height: 2.9rem;
  border-radius: 0.35rem;
  border: 1px solid rgba(243, 231, 211, 0.18);
  background: rgba(0, 0, 0, 0.35);
  color: var(--cream);
  padding: 0 0.9rem;
  font: inherit;
}

input:focus {
  outline: 2px solid rgba(232, 162, 58, 0.45);
  outline-offset: 1px;
}

.rooms {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.room-card {
  text-align: left;
  border: 1px solid rgba(243, 231, 211, 0.12);
  background: var(--panel);
  border-radius: 0.5rem;
  padding: 1rem 1rem 0.95rem;
  color: inherit;
  cursor: pointer;
  transition: transform 0.25s var(--ease), border-color 0.25s var(--ease), background 0.25s var(--ease);
}

.room-card:hover {
  transform: translateY(-2px);
  border-color: rgba(232, 162, 58, 0.55);
  background: rgba(232, 162, 58, 0.08);
}

.room-card b {
  display: block;
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
}

.room-card span {
  color: var(--muted);
  font-size: 0.86rem;
}

.room-card em {
  display: inline-block;
  margin-top: 0.65rem;
  font-style: normal;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--amber);
}

.room-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.room-head h2 {
  font-family: "Fraunces", serif;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
}

.room-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.7rem;
  padding: 0 1rem;
  border-radius: 0.35rem;
  border: 0;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(180deg, var(--amber-hot), var(--amber));
  color: #1a1208;
}

.btn-ghost {
  background: transparent;
  color: var(--cream);
  border: 1px solid rgba(243, 231, 211, 0.28);
}

.btn-ghost[aria-pressed="true"] {
  border-color: rgba(248, 113, 113, 0.7);
  color: #fecaca;
}

.room-grid {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: 0.85rem;
  min-height: 420px;
}

.panel {
  border: 1px solid rgba(243, 231, 211, 0.1);
  border-radius: 0.55rem;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel h3 {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 0.75rem;
}

.peer-list {
  list-style: none;
  display: grid;
  gap: 0.45rem;
  overflow: auto;
}

.peer-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  border-radius: 0.35rem;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(243, 231, 211, 0.08);
}

.peer-list .dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5);
  animation: pulse 2s ease-out infinite;
}

.peer-list .muted .dot {
  background: #f87171;
  animation: none;
}

.chat-log {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding-right: 0.2rem;
  margin-bottom: 0.75rem;
}

.chat-line {
  font-size: 0.93rem;
  line-height: 1.4;
}

.chat-line b {
  color: var(--amber);
  font-weight: 700;
  margin-right: 0.35rem;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

.status {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  max-width: min(92vw, 520px);
  padding: 0.55rem 0.9rem;
  border-radius: 0.35rem;
  background: rgba(11, 10, 9, 0.88);
  border: 1px solid var(--line);
  color: var(--cream);
  font-size: 0.86rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease);
  z-index: 20;
}

.status.show {
  opacity: 1;
}

.hidden {
  display: none !important;
}

.audio-mount audio {
  display: none;
}

@keyframes grain {
  to {
    transform: translate(-1.5%, 1%);
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.45);
  }
  70% {
    box-shadow: 0 0 0 8px transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

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