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

:root {
  /* UltraKit (ultrakit/ultrakit.css): Room+1 defines no colour, face or
     metric of its own. Silver is the primary; colour is kept for meaning. */
  --bg: var(--uk-ground);
  --surface: var(--uk-surface);
  --surface2: var(--uk-primary-dim);
  --border: var(--uk-primary-dim);
  --text: var(--uk-text);
  --text-dim: var(--uk-muted);
  --accent: var(--uk-primary);
  --accent-hover: var(--uk-primary-hi);
  --ink: var(--uk-ground);           /* text on a lit block */
  --green: var(--uk-ice);            /* output, live */
  --red: var(--uk-record);
  --armed: var(--uk-armed);
  --radius: 0px;
  --border-width: 1px;

  /* Icon tokens — unicode symbols, overridable per theme */
  --icon-sound-on: '\266B';
  --icon-sound-off: '\2205';
  --icon-paint: '\2592';
  --icon-gamepad: '\2318';
  --icon-feed: '\25A0';
  --icon-play: '\25B6';
  --icon-stop: '\25A0';
  --icon-close: '\2715';
  --icon-add: '+';
}

body {
  font-family: var(--uk-font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
}

h1, h2, h3 {
  font-family: var(--uk-font-brand);
  font-weight: 400;
  letter-spacing: 0.02em;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 800px; margin: 0 auto; padding: 24px; }

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header h1 { font-size: 15px; font-weight: 700; }
.header h1 span { color: var(--accent); }

.header-brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.header-version {
  font-size: 9px;
  color: var(--text-dim);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-badge img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-discord {
  background: var(--accent);
  color: var(--ink);
}
.btn-discord:hover { background: var(--accent-hover); }

.btn-primary {
  background: var(--accent);
  color: var(--ink);
}
.btn-primary:hover { filter: brightness(0.85); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-small {
  padding: 6px 12px;
  font-size: 9px;
}

/* Forms */
input, textarea, select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 12px;
  accent-color: var(--accent);
  font-size: 11px;
  width: 100%;
  font-family: inherit;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-dim);
}

.form-group { margin-bottom: 16px; }

/* Landing page */
.landing {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 32px 180px;
}

.landing p { color: var(--text-dim); font-size: 17px; line-height: 1.6; }
.landing .landing-eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; margin-bottom: 16px; }
.landing-nav { display: flex; align-items: center; gap: 28px; padding: 24px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.landing-brand { margin-right: auto; font-family: var(--uk-font-brand); font-size: 36px; color: var(--text); }
.landing-brand span { color: var(--accent); }
.landing-hero { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 72px; align-items: center; padding: 80px 0; }
.landing h1 { font-size: clamp(56px, 6.5vw, 88px); line-height: 0.95; margin-bottom: 28px; }
.landing .landing-lede { color: var(--text); font-size: 22px; line-height: 1.45; margin-bottom: 18px; }
.landing-text-link { display: inline-block; margin-top: 24px; font-size: 16px; text-decoration: underline; text-underline-offset: 5px; }
.landing-signin { padding: 28px; background: var(--surface); border: 1px solid var(--border); scroll-margin-top: 24px; min-width: 0; }
.landing h2 { font-size: 38px; line-height: 1.05; }
.landing-signin > p:not(.landing-eyebrow) { font-size: 16px; margin: 14px 0 24px; }
.landing-signin .btn { justify-content: center; min-height: 44px; font-size: 16px; }
.landing-signin > .btn { display: flex; width: 100%; }
.landing-signin input { font-size: 16px !important; min-height: 44px; }
.landing-signin form { min-width: 0; }
.landing-signin form > input { min-width: 0; }
.landing-signin summary { cursor: pointer; font-size: 14px; line-height: 1.5; padding: 8px 0; }
.landing-login-options { margin-top: 8px; }
.landing-pair { border-top: 1px solid var(--border); margin-top: 20px; padding-top: 12px; }
.landing-pair p { font-size: 14px; margin: 4px 0 12px; }
.landing-how { border-top: 1px solid var(--border); padding: 40px 0 48px; scroll-margin-top: 24px; }
.landing-steps { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 36px; margin-top: 36px; }
.landing-step-number { display: block; color: var(--accent); font-family: var(--uk-font-mono); font-size: 13px; margin-bottom: 16px; }
.landing h3 { font-size: 30px; line-height: 1.1; margin-bottom: 12px; }
.landing-steps p { font-size: 16px; }
.landing-vision { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; border-top: 1px solid var(--border); padding-top: 40px; }
.landing-vision p + p { margin-top: 14px; }
.landing :is(a, button, input, summary):focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 4px; }
@media (max-width: 760px) {
  .landing { padding: 0 20px 160px; }
  .landing-nav { gap: 16px; font-size: 13px; }
  .landing-brand { font-size: 32px; }
  .landing-hero { grid-template-columns: 1fr; gap: 36px; padding: 44px 0; }
  .landing-intro { max-width: 540px; }
  .landing-signin { padding: 24px; }
  .landing-steps, .landing-vision { grid-template-columns: 1fr; gap: 28px; }
}

/* Dashboard */
.dashboard { padding-top: 32px; }

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 16px;
  letter-spacing: 0.5px;
}

.room-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  margin-bottom: 12px;
  overflow: hidden;
}

.room-card.clickable { cursor: pointer; transition: border-color 0.15s; position: relative; }
.room-card.clickable:hover { border-color: var(--accent); }

.card-effect-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.room-card:hover .card-effect-canvas { opacity: 1; }

.room-card > div { position: relative; z-index: 2; }

.gear-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius);
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}
.room-card:hover .gear-btn { opacity: 1; }
.gear-btn:hover { background: var(--surface2); color: var(--text); }

.room-info-popup {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  z-index: 50;
  min-width: 200px;
}

.room-card h3 { margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.room-card .meta { font-size: 12px; color: var(--text-dim); }

.unread-badge {
  background: var(--accent);
  color: var(--ink);
  font-size: 8px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius);
  white-space: nowrap;
}

.server-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.server-tag {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px 10px;
  font-size: 8px;
  color: var(--text-dim);
}

.server-tag.shared {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink);
}

.adjacent-card {
  border-left: 3px solid var(--accent);
}

/* Server picker */
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.server-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s;
}

.server-option.selected { background: var(--surface2); border-color: var(--surface2); }

.server-option img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface2);
}

.server-option .name {
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Chat */
.room-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: fixed;
  inset: 0;
}

.room-header {
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.room-header h2 {
  font-size: 12px;
  font-family: var(--heading-font, inherit);
  font-weight: var(--heading-weight, inherit);
  font-style: var(--heading-style, normal);
}
.room-header .origin { font-size: 9px; color: var(--text-dim); }
.room-header .via-more { color: var(--accent); cursor: pointer; text-decoration: underline; text-decoration-style: dotted; }
.room-header .via-more:hover { color: var(--accent-hover); }

.messages-wrapper {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.messages {
  position: relative;
  z-index: 1;
  height: 100%;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.has-canvas .messages {
  height: 100%;
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: auto;
  cursor: none;
  user-select: none;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.has-canvas .message {
  background: var(--canvas-msg-bg, rgba(13, 13, 13, 0.8));
  border: var(--border-width, 1px) solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px;
  pointer-events: auto;
  user-select: text;
  cursor: text;
  width: fit-content;
}

.has-canvas .message img {
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
}

.has-canvas .messages-wrapper {
  cursor: default;
}

.canvas-focused .messages {
  opacity: 0.1;
  pointer-events: none;
}

.canvas-focused .presence {
  opacity: 0.1;
}

.message {
  display: flex;
  gap: 10px;
  padding: 6px 0;
}

.message img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
}

.message .body { flex: 1; }

.message .author {
  font-size: 10px;
  font-weight: var(--heading-weight, 600);
  font-family: var(--heading-font, inherit);
  font-style: var(--heading-style, normal);
  margin-bottom: 2px;
}

.msg-popover {
  position: absolute;
  left: 42px;
  top: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  z-index: 50;
  min-width: 160px;
  font-size: 10px;
}
.msg-popover a { display: block; padding: 4px 0; color: var(--accent); text-decoration: none; }
.msg-popover a:hover { text-decoration: underline; }
.msg-popover .pop-via { font-size: 8px; color: var(--text-dim); margin-bottom: 6px; }

.message .author .via {
  font-weight: 400;
  color: var(--text-dim);
  font-size: 8px;
  margin-left: 6px;
}

.ban-link {
  font-weight: 400;
  font-size: 8px;
  color: var(--red);
  margin-left: 8px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.message:hover .ban-link {
  opacity: 0.6;
}

.ban-link:hover {
  opacity: 1 !important;
  text-decoration: underline;
}

.message .author .time {
  font-weight: 400;
  color: var(--text-dim);
  font-size: 8px;
  margin-left: 8px;
}

.message .text {
  font-size: 11px;
  line-height: 1.4;
  word-break: break-word;
}

.chat-input-area {
  padding: 12px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.chat-input-area form { display: flex; gap: 8px; }

.chat-input-area input {
  flex: 1;
}

/* Presence sidebar */
.presence {
  padding: 8px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 9px;
  color: var(--text-dim);
}

/* Bio snippet */
.bio-snippet {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}

.bio-snippet pre {
  background: var(--surface2);
  padding: 12px;
  border-radius: var(--radius);
  font-size: 10px;
  white-space: pre-wrap;
  margin: 8px 0;
  color: var(--text);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal h2 { margin-bottom: 16px; }

/* Gate screen */
.gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  text-align: center;
  gap: 16px;
}

.gate h2 { font-size: 18px; }
.gate p { color: var(--text-dim); max-width: 400px; font-size: 11px; }

.gate .server-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 8px 0;
}

.denied {
  background: var(--red);
  color: var(--ink);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-weight: 600;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 10px;
  color: var(--text);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 200;
  pointer-events: none;
  white-space: nowrap;
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Settings toggle */
.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.toggle-label input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* By Lucian Labs */
/* Shop widget — the external <ll-shop> element pins itself bottom-right from
   inside its shadow DOM via :host. Page-level rules on the host element win
   over :host, so this is the supported way to reposition it without forking
   the CDN script. */
ll-shop {
  right: auto;
  left: 18px;
}

/* Settings panel */
.settings-panel {
  position: fixed;
  top: 52px;
  right: 16px;
  width: min(320px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 50;
}

.settings-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.settings-section .section-title {
  margin-bottom: 10px;
}

/* Deploy cards */
.deploy-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}
.deploy-card:hover { border-color: var(--accent); }
.deploy-card.deploy-fail { border-left: 3px solid var(--red); }
.deploy-card.deploy-ok { border-left: 3px solid var(--green); }

.deploy-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 11px;
}

.deploy-meta {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.deploy-info {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.deploy-steps {
  font-size: 8px;
  font-family: monospace;
  color: var(--text-dim);
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: var(--radius);
}

.deploy-time {
  font-size: 8px;
  color: var(--text-dim);
}

.deploy-branch {
  font-size: 8px;
  font-family: monospace;
  color: var(--accent);
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: var(--radius);
}

.deploy-detail-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 8px;
  font-size: 10px;
}
.deploy-detail-row label {
  min-width: 70px;
  font-size: 8px;
  margin-bottom: 0;
}

.deploy-error {
  background: var(--surface2);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 9px;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--red);
  width: 100%;
  margin: 0;
}

/* Paint panel (graffiti chat toy) */
.paint-panel {
  position: fixed;
  top: 52px;
  right: 16px;
  width: min(220px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 50;
  padding: 12px;
}

.brush-sizes {
  display: flex;
  gap: 4px;
}

.brush-sizes button {
  flex: 1;
  padding: 6px 0;
  font-size: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.brush-sizes button:hover { background: var(--border); }
.brush-sizes button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--ink);
}

.paint-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  transition: border-color 0.15s, color 0.15s;
}
.paint-toggle:hover { border-color: var(--accent); color: var(--text); }
.paint-toggle.active {
  border-color: var(--accent);
  color: var(--ink);
  background: var(--accent);
}

.paint-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.paint-color-row input[type="color"] {
  width: 32px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
  cursor: pointer;
  background: var(--surface2);
}

.paint-color-row label {
  margin-bottom: 0;
  font-size: 8px;
}

/* Prevent iOS zoom on input focus */
@media (max-width: 768px) {
  input, textarea, select { font-size: 16px; }
}

/* Responsive */
@media (max-width: 600px) {
  .landing h1 { font-size: 24px; }
  .server-grid { grid-template-columns: 1fr; }
  .container { padding: 16px; }
  .header { padding: 10px 16px; }
  .room-header { padding: 8px 12px; }
  .messages { padding: 8px 12px; }
  .chat-input-area { padding: 8px 12px; }
  .presence { padding: 6px 12px; }
  .modal { padding: 16px; width: 95%; }
  .gear-btn { opacity: 0.6; }
  .ban-link { opacity: 0.4; }
  .message img { width: 24px; height: 24px; }
}

/* --- Catastrophe chat toy ---------------------------------------------- */
/* Escalates through sign → build → imminent, then resolves to something
   mundane. The colour ramp does most of the work; the copy does the rest. */

.catastrophe-toy {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 10px 12px;
}

.cat-stage {
  min-height: 42px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
  transition: border-color 0.45s ease, background 0.45s ease;
}

.cat-line {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-dim);
  transition: color 0.35s ease, font-size 0.2s ease;
}

.cat-sign { border-color: #4a4a52; }
.cat-sign .cat-line { color: var(--text); }

.cat-build { border-color: #8a6a2a; background: rgba(180, 130, 40, 0.07); }
.cat-build .cat-line { color: #d8b064; }

.cat-imminent { border-color: var(--red, #c0392b); background: rgba(200, 60, 45, 0.13); }
.cat-imminent .cat-line {
  color: #ff6b5e;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1.5px;
}

/* The deflation: everything drains back out, deliberately faster than it
   built up. The anticlimax should feel abrupt, not gentle. */
.cat-resolve { border-color: var(--border); background: rgba(0, 0, 0, 0.18); }
.cat-resolve .cat-line { color: var(--text-dim); font-style: italic; }

.cat-bracers { font-size: 9px; color: var(--text-dim); min-height: 11px; }
.cat-tally { opacity: 0.85; }
.cat-live { color: #d8b064; }

.cat-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.cat-brace {
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 6px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--red, #c0392b);
  background: transparent;
  color: var(--red, #c0392b);
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.cat-brace:hover:not(:disabled) { background: rgba(200, 60, 45, 0.15); }
.cat-brace:disabled { opacity: 0.3; cursor: default; }

.cat-score { font-size: 9px; color: var(--text-dim); }

@keyframes cat-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-3px); }
  40% { transform: translateX(3px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}
.cat-pulse { animation: cat-shake 0.4s ease-in-out; }

@media (prefers-reduced-motion: reduce) {
  .cat-pulse { animation: none; }
}
