:root {
  --bg: #07080c;
  --bg2: #0e1018;
  --surface: #151821;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f5f7;
  --muted: #8b91a1;
  --accent: #3dffa8;
  --accent-dim: rgba(61, 255, 168, 0.14);
  --danger: #ff5c7a;
  --heal: #5ce1ff;
  --font: "Outfit", system-ui, sans-serif;
  --radius: 14px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  filter: brightness(1.08);
}

.page {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(61, 255, 168, 0.08), transparent 55%),
    radial-gradient(900px 500px at 0% 100%, rgba(92, 225, 255, 0.05), transparent 50%),
    var(--bg);
}

.page--home .glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(61, 255, 168, 0.12), transparent 60%);
  animation: pulse 8s ease-in-out infinite alternate;
}

@keyframes pulse {
  from {
    opacity: 0.7;
  }
  to {
    opacity: 1;
  }
}

/* —— Atmospheric shadows / ghosts / wolf —— */
.haze {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.haze__fog {
  position: absolute;
  inset: -20% -10%;
  opacity: 0.35;
  filter: blur(40px);
}

.haze__fog--a {
  background:
    radial-gradient(ellipse 40% 30% at 20% 70%, rgba(255, 255, 255, 0.04), transparent 55%),
    radial-gradient(ellipse 35% 25% at 75% 40%, rgba(180, 200, 220, 0.03), transparent 50%);
  animation: fog-drift 22s ease-in-out infinite alternate;
}

.haze__fog--b {
  background:
    radial-gradient(ellipse 45% 28% at 60% 80%, rgba(0, 0, 0, 0.55), transparent 60%),
    radial-gradient(ellipse 30% 20% at 30% 30%, rgba(255, 255, 255, 0.025), transparent 55%);
  animation: fog-drift 28s ease-in-out infinite alternate-reverse;
}

@keyframes fog-drift {
  from {
    transform: translate3d(-2%, 1%, 0) scale(1);
  }
  to {
    transform: translate3d(3%, -2%, 0) scale(1.06);
  }
}

.haze__ghost {
  position: absolute;
  width: 140px;
  height: 180px;
  border-radius: 50% 50% 42% 42%;
  background:
    radial-gradient(ellipse 55% 45% at 50% 35%, rgba(220, 230, 240, 0.09), transparent 70%),
    radial-gradient(ellipse 40% 55% at 50% 70%, rgba(160, 180, 200, 0.05), transparent 72%);
  filter: blur(8px);
  opacity: 0;
  mix-blend-mode: screen;
}

.haze__ghost--1 {
  top: 18%;
  left: 8%;
  animation: ghost-float 16s ease-in-out infinite;
}

.haze__ghost--2 {
  top: 42%;
  right: 6%;
  width: 110px;
  height: 150px;
  animation: ghost-float 21s ease-in-out 4s infinite;
}

.haze__ghost--3 {
  bottom: 12%;
  left: 38%;
  width: 160px;
  height: 120px;
  border-radius: 50%;
  animation: ghost-float 19s ease-in-out 9s infinite;
}

@keyframes ghost-float {
  0%,
  100% {
    opacity: 0;
    transform: translate3d(0, 18px, 0) scale(0.92);
  }
  15% {
    opacity: 0.55;
  }
  45% {
    opacity: 0.35;
    transform: translate3d(28px, -24px, 0) scale(1.05);
  }
  70% {
    opacity: 0.5;
    transform: translate3d(-16px, -8px, 0) scale(1);
  }
  90% {
    opacity: 0;
    transform: translate3d(40px, -40px, 0) scale(1.08);
  }
}

.haze__wolf {
  position: absolute;
  bottom: 14%;
  left: -30%;
  width: min(280px, 55vw);
  height: auto;
  color: rgba(0, 0, 0, 0.72);
  filter: blur(0.4px) drop-shadow(0 0 18px rgba(0, 0, 0, 0.8));
  opacity: 0;
  animation: wolf-run 18s linear infinite;
}

.page--haze .haze__wolf {
  animation-duration: 22s;
}

@keyframes wolf-run {
  0%,
  62% {
    opacity: 0;
    transform: translate3d(0, 0, 0) scaleX(1);
  }
  64% {
    opacity: 0.55;
    transform: translate3d(0, 0, 0) scaleX(1);
  }
  78% {
    opacity: 0.85;
    transform: translate3d(70vw, -6px, 0) scaleX(1);
  }
  86% {
    opacity: 0.2;
    transform: translate3d(110vw, 4px, 0) scaleX(1);
  }
  87%,
  100% {
    opacity: 0;
    transform: translate3d(120vw, 0, 0) scaleX(1);
  }
}

.haze__shade {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 60% at 50% 110%, rgba(0, 0, 0, 0.55), transparent 55%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.25) 0%, transparent 28%, transparent 72%, rgba(0, 0, 0, 0.4) 100%);
  animation: shade-breathe 12s ease-in-out infinite alternate;
}

@keyframes shade-breathe {
  from {
    opacity: 0.75;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .haze__fog,
  .haze__ghost,
  .haze__wolf,
  .haze__shade,
  .page--home .glow {
    animation: none !important;
  }

  .haze__ghost {
    opacity: 0.15;
  }

  .haze__wolf {
    display: none;
  }
}

.shell {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 1rem 1.15rem 2.5rem;
  position: relative;
  z-index: 1;
}

.shell--narrow {
  width: min(420px, 100%);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.logo {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
  color: var(--text);
}

.topbar__nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar__link {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.95rem;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.topbar__link.is-on,
.topbar__link:hover {
  color: var(--text);
}

.topbar__form {
  margin: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 999px;
  padding: 0.75rem 1.25rem;
  font: inherit;
  font-weight: 700;
  background: var(--accent);
  color: #04140c;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.btn--ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.btn--sm {
  padding: 0.45rem 0.9rem;
  font-size: 0.9rem;
}

.btn--block {
  width: 100%;
}

.home {
  padding: 2.5rem 0 1rem;
  animation: rise 0.6s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.home__brand {
  margin: 0 0 0.75rem;
  font-size: clamp(3rem, 12vw, 4.5rem);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 0.9;
}

.home__title {
  margin: 0 0 0.85rem;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.home__lead {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 28rem;
}

.home__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 2.5rem;
}

.home__steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.home__steps li {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.98rem;
}

.home__steps span {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  flex: 0 0 auto;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.35rem 1.25rem;
  box-shadow: var(--shadow);
}

.panel__title {
  margin: 0 0 1rem;
  font-size: 1.45rem;
  letter-spacing: -0.03em;
}

.panel__foot {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.form {
  display: grid;
  gap: 0.85rem;
}

.field {
  display: grid;
  gap: 0.35rem;
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 500;
}

.input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  font: inherit;
}

.input:focus {
  outline: 2px solid rgba(61, 255, 168, 0.35);
  border-color: transparent;
}

.input--code {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  font-size: 1.2rem;
}

.errors {
  margin: 0 0 0.85rem;
  padding: 0.75rem 0.9rem;
  list-style: none;
  background: rgba(255, 92, 122, 0.12);
  color: #ffb3c1;
  border-radius: 12px;
}

.muted {
  color: var(--muted);
}

.pagehead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.pagehead__title {
  margin: 0;
  font-size: 1.7rem;
  letter-spacing: -0.03em;
}

.pagehead__actions {
  display: flex;
  gap: 0.5rem;
}

.table-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.table-list__item {
  display: grid;
  gap: 0.2rem;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.table-list__item:hover {
  border-color: rgba(61, 255, 168, 0.35);
  transform: translateY(-1px);
}

.table-list__name {
  font-weight: 700;
  font-size: 1.05rem;
}

.table-list__meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.table-list__meta code {
  color: var(--accent);
  font-family: inherit;
  font-weight: 600;
}

/* —— Table / chat —— */
.page--table {
  background: var(--bg);
}

.table-app {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  max-width: 720px;
  margin: 0 auto;
}

.table-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 8, 12, 0.9);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.table-bar__back {
  color: var(--muted);
  font-size: 1.2rem;
  padding: 0.25rem 0.4rem;
}

.table-bar__main {
  flex: 1;
  min-width: 0;
}

.table-bar__title {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-bar__code {
  margin: 0.1rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.table-bar__code code {
  color: var(--accent);
  font-family: inherit;
  font-weight: 600;
}

.story-strip {
  padding: 0.75rem 1rem;
  background: var(--accent-dim);
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}

.story-strip p {
  margin: 0;
}

.master-box {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg2);
}

.master-box summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.form--inline {
  margin-top: 0.65rem;
}

.hero-gate {
  padding: 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.hero-gate h2 {
  margin: 0 0 0.35rem;
  font-size: 1.2rem;
}

.chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.chat__log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.9rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.msg {
  max-width: 92%;
  animation: msg-in 0.2s ease both;
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.msg--chat {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px 16px 16px 6px;
  padding: 0.55rem 0.8rem;
}

.msg--roll,
.msg--system {
  align-self: center;
  text-align: center;
}

.msg__who {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.15rem;
}

.msg__body {
  font-size: 0.98rem;
  word-break: break-word;
}

.msg__body--sys {
  color: var(--muted);
  font-size: 0.92rem;
}

.msg--roll .msg__body--sys {
  color: #d7ffe9;
  background: rgba(61, 255, 168, 0.1);
  border: 1px solid rgba(61, 255, 168, 0.2);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  display: inline-block;
}

.chat__dock {
  border-top: 1px solid var(--line);
  background: rgba(7, 8, 12, 0.96);
  padding: 0.55rem 0.75rem calc(0.65rem + env(safe-area-inset-bottom));
  position: sticky;
  bottom: 0;
}

.chat__quick {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.45rem;
  overflow-x: auto;
}

.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.chip:hover {
  border-color: rgba(61, 255, 168, 0.4);
}

.chip--heal {
  color: var(--heal);
}

.chat__form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem;
}

.chat__input {
  border-radius: 999px;
}

.chat__form .btn {
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border-radius: 50%;
  font-size: 1.15rem;
}

.party {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(320px, 92vw);
  background: var(--bg2);
  border-left: 1px solid var(--line);
  z-index: 20;
  padding: 0.85rem;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: slide 0.2s ease;
}

@keyframes slide {
  from {
    transform: translateX(12px);
    opacity: 0.6;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.party__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.party__head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.party__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.party__card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.75rem;
}

.party__top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.party__hp {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
}

.hpbar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  margin-bottom: 0.35rem;
}

.hpbar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #8dffcb);
  border-radius: inherit;
}

.party__meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.party__ops {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

@media (min-width: 860px) {
  .table-app {
    max-width: 900px;
  }
}

/* Voice */
.voice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  max-width: min(100%, 16rem);
}

.voice--live {
  padding: 0.2rem 0.35rem;
  border-radius: 999px;
  background: var(--accent-dim);
}

.voice__status {
  margin: 0;
  flex: 1 1 100%;
  font-size: 0.72rem;
  color: var(--muted);
}

.voice__status--err {
  color: #ffb3c1;
}

.voice__roster {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  flex: 1 1 100%;
}

.voice__peer {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.voice__peer.is-self {
  color: var(--accent);
}

.voice #voiceMute.is-muted {
  opacity: 0.65;
}

.voice__audio {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 640px) {
  .table-bar {
    flex-wrap: wrap;
  }

  .voice {
    order: 3;
    max-width: 100%;
    flex: 1 1 100%;
  }
}
