:root {
  --bg: #120b1a;
  --bg-raised: #1c1226;
  --edge: #322040;
  --ink: #f2e9f7;
  --muted: #a898b6;
  --accent: #c77dff;
  --accent-deep: #7b2cbf;
  --gold: #ffd166;
  --grey: #7d8496;
  --danger: #ff8fa3;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1100px 620px at 50% -12%, #2a1338 0%, transparent 62%),
    var(--bg);
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.hidden { display: none !important; }

h1, h2 {
  margin: 0 0 6px;
  font-weight: 650;
  letter-spacing: -0.015em;
}
h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; }

.lede { margin: 0 0 18px; color: var(--muted); }
.muted { color: var(--muted); margin: 0; }
.fine {
  margin: 20px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  border-top: 1px solid var(--edge);
  padding-top: 14px;
}

.panel {
  background: var(--bg-raised);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 26px 22px;
  margin-top: 8vh;
}

/* ------------------------------------------------------------- form controls */

.field { display: block; margin: 0 0 14px; }
.field > span {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 6px;
}
.field.narrow { max-width: 140px; }

input, textarea {
  width: 100%;
  padding: 11px 13px;
  background: #0d0714;
  color: var(--ink);
  border: 1px solid var(--edge);
  border-radius: 10px;
  font: inherit;
}
textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  line-height: 1.45;
  word-break: break-all;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(199, 125, 255, 0.18);
}

button {
  padding: 11px 18px;
  border-radius: 10px;
  border: 1px solid var(--edge);
  background: #241732;
  color: var(--ink);
  font: inherit;
  font-weight: 560;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
}
button:hover:not([disabled]) { filter: brightness(1.18); }
button:active:not([disabled]) { transform: translateY(1px); }
button[disabled] { opacity: 0.42; cursor: not-allowed; }

button.primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-deep) 100%);
  border-color: transparent;
  color: #fff;
}
button.big { padding: 14px 28px; font-size: 1.05rem; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row input { flex: 1 1 200px; width: auto; }

.status { color: var(--accent); min-height: 1.3em; margin: 10px 0 0; font-size: 0.9rem; }
.error  { color: var(--danger); min-height: 1.3em; margin: 8px 0 0; font-size: 0.9rem; }

/* -------------------------------------------------------------------- room */

.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  margin-bottom: 14px;
}

.badge {
  background: var(--accent-deep);
  color: #fff;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 620;
  letter-spacing: 0.02em;
}

.verify { font-size: 0.82rem; color: var(--muted); }
.verify strong {
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.04em;
}

.link-state {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* ------------------------------------------------------------------- stage */

.stage {
  position: relative;
  background: radial-gradient(520px 320px at 50% 42%, #24133a 0%, #0e0816 72%);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
}

#dice {
  display: block;
  width: 100%;
  height: 340px;
}

.result {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  pointer-events: none;
  background: rgba(10, 5, 18, 0.34);
  animation: rise 0.45s ease-out;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

.sigil { width: 104px; height: 104px; }
#result-success { filter: drop-shadow(0 0 16px rgba(255, 209, 102, 0.55)); }

.result-number {
  font-size: 3.4rem;
  font-weight: 750;
  line-height: 1;
  letter-spacing: -0.03em;
}
.result-line {
  font-size: 0.86rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* --------------------------------------------------------------- challenge */

.challenge, .chat {
  background: var(--bg-raised);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}

.challenge-text {
  margin: 0 0 4px;
  font-size: 1.16rem;
  font-weight: 560;
}
.threshold { margin: 0; color: var(--muted); font-size: 0.9rem; }
.threshold strong { color: var(--gold); font-size: 1.05rem; }

.controls { margin-top: 16px; }
.roll-row { margin-top: 16px; }

/* -------------------------------------------------------------------- chat */

.log {
  height: 260px;
  overflow-y: auto;
  padding: 10px;
  background: #0d0714;
  border: 1px solid var(--edge);
  border-radius: 10px;
  margin-bottom: 12px;
  overscroll-behavior: contain;
}

.line { margin: 0 0 7px; line-height: 1.45; word-wrap: break-word; }
.line .who {
  font-weight: 640;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 8px;
  color: var(--accent);
}
.line.them .who { color: var(--gold); }
.line.system { color: var(--muted); font-size: 0.87rem; font-style: italic; }
.line.system .who { display: none; }
.line.success .who, .line.success .said { color: var(--gold); font-weight: 560; }
.line.failure .who, .line.failure .said { color: var(--grey); font-weight: 560; }

/* -------------------------------------------------------------- attachments */

.attachment {
  margin: 6px 0 2px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.attachment img,
.attachment video {
  display: block;
  max-width: 100%;
  max-height: 320px;
  border-radius: 10px;
  border: 1px solid var(--edge);
  background: #0d0714;
}

.download {
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--edge);
  border-radius: 8px;
  padding: 4px 10px;
  word-break: break-all;
}
.download:hover { filter: brightness(1.25); text-decoration: underline; }

.line.media .who { display: block; margin-bottom: 2px; }

input[type="file"] {
  padding: 8px;
  font-size: 0.86rem;
  cursor: pointer;
}
input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--edge);
  background: #241732;
  color: var(--ink);
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
}

@media (max-width: 560px) {
  .panel { margin-top: 4vh; padding: 20px 16px; }
  #dice { height: 260px; }
  .log { height: 210px; }
  .result-number { font-size: 2.8rem; }
  .sigil { width: 82px; height: 82px; }
}

@media (prefers-reduced-motion: reduce) {
  .result { animation: none; }
  button { transition: none; }
}
