/* Kleros. Materiales translucidos sobre la ciudad (skill apple-design, seccion 12): la interfaz
   flota encima sin taparla, la letra es la del sistema, y el movimiento lo hacen muelles en JS. */

:root {
  --bg: #e9dcc2;
  --ink: #1f1a14;
  --ink-2: #5d5346;
  --ink-3: #8c8273;
  --glass: rgba(252, 248, 240, 0.72);
  --glass-thick: rgba(250, 246, 238, 0.86);
  --glass-edge: rgba(255, 255, 255, 0.55);
  --line: rgba(60, 45, 25, 0.12);
  --card: rgba(255, 255, 255, 0.62);
  --accent: #b5552e;
  --accent-ink: #fff8f0;
  --sea: #2f7f9a;
  --olive: #6f8f3a;
  --gold: #c99a2e;
  --red: #b23b2a;
  --yes: #4f8a3c;
  --no: #b5452e;
  --shadow: 0 10px 40px rgba(60, 40, 15, 0.18), 0 1px 3px rgba(60, 40, 15, 0.12);
  --radius: 18px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #f4ede1;
    --ink-2: #cfc4b2;
    --ink-3: #9d927f;
    --glass: rgba(34, 29, 23, 0.7);
    --glass-thick: rgba(30, 26, 21, 0.88);
    --glass-edge: rgba(255, 255, 255, 0.12);
    --line: rgba(255, 240, 220, 0.12);
    --card: rgba(255, 245, 230, 0.07);
    --accent: #e07a4c;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); }
body {
  font: 100%/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}
#app { position: fixed; inset: 0; }
.world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

button { font: inherit; color: inherit; cursor: pointer; -webkit-user-select: none; user-select: none; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 10px; }

/* ------------------------------------------------------------- materiales */
.glass, .glass-thick {
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  backdrop-filter: blur(22px) saturate(170%);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow);
}
.glass-thick { background: var(--glass-thick); -webkit-backdrop-filter: blur(34px) saturate(180%); backdrop-filter: blur(34px) saturate(180%); }
@media (prefers-reduced-transparency: reduce) {
  .glass, .glass-thick { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  .glass, .glass-thick { background: var(--bg); border-color: var(--ink); }
}

/* ------------------------------------------------------------- barra superior */
.topbar {
  position: absolute; top: calc(10px + var(--safe-t)); left: 12px; right: 12px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 6px; border-radius: 999px; z-index: 20;
  max-width: 560px; margin: 0 auto;
}
.city-chip { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 4px 10px; border-radius: 999px; }
.city-chip:active { transform: scale(0.97); transition: transform 100ms ease-out; }
.city-name { font-family: ui-serif, "New York", Georgia, serif; font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; }
.regime { font-size: 0.75rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; letter-spacing: 0.01em; background: rgba(79, 138, 60, 0.15); color: var(--yes); }
.regime-oligarquia { background: rgba(201, 154, 46, 0.18); color: #9a7419; }
.regime-tirania { background: rgba(178, 59, 42, 0.16); color: var(--red); }
.top-actions { display: flex; align-items: center; gap: 6px; }
.find-me { border: 0; background: none; padding: 0; border-radius: 999px; line-height: 0; }
.find-me .face { box-shadow: 0 0 0 2px #ffc94d; }
.find-me:active { transform: scale(0.92); transition: transform 90ms ease-out; }
.jornadas { position: relative; width: 44px; height: 44px; border: 0; background: none; padding: 0; border-radius: 999px; display: grid; place-items: center; }
.jornadas:active { transform: scale(0.94); transition: transform 100ms ease-out; }
.jornadas .ring-wrap { position: absolute; inset: 0; line-height: 0; pointer-events: none; }
.jornadas .ring { width: 44px; height: 44px; transform: rotate(-90deg); display: block; }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 4; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; transition: stroke-dasharray 400ms ease; }
.jornadas-n { position: relative; font-weight: 700; font-size: 1rem; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

/* ------------------------------------------------------------- barra de pestanas */
.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; justify-content: space-around; align-items: stretch;
  border-radius: 22px 22px 0 0; border-bottom: 0;
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: none; border: 0; color: var(--ink-3); position: relative; padding: 6px 0; }
.tab .tab-icon svg { width: 25px; height: 25px; display: block; }
.tab-label { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.01em; }
.tab.on { color: var(--accent); }
.tab:active .tab-icon { transform: scale(0.88); transition: transform 90ms ease-out; }
.badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 0.7rem; font-weight: 700; display: grid; place-items: center; }

/* ------------------------------------------------------------- la hoja */
.sheet {
  position: absolute; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b) - 18px); z-index: 25;
  height: calc(100dvh - var(--tabbar-h) - var(--safe-b) - var(--safe-t) - 64px);
  border-radius: 24px 24px 0 0; border-bottom: 0;
  display: flex; flex-direction: column; will-change: transform; visibility: hidden;
  padding-bottom: 18px;
}
.sheet-grip { display: flex; justify-content: center; padding: 8px 0 2px; touch-action: none; cursor: grab; }
.sheet-grip span { width: 38px; height: 5px; border-radius: 3px; background: var(--ink-3); opacity: 0.45; }
.sheet-head { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 4px 16px 10px 20px; touch-action: none; }
.sheet-head.has-back { grid-template-columns: auto 1fr auto; padding-left: 12px; }
.sheet-head.has-back h2 { font-size: 1.22rem; letter-spacing: -0.015em; }
.sheet-head h2 { margin: 0; font-size: 1.6rem; line-height: 1.1; letter-spacing: -0.025em; font-weight: 750; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-actions { display: flex; gap: 6px; }
.icon-btn { width: 34px; height: 34px; border-radius: 999px; border: 0; background: var(--card); display: grid; place-items: center; color: var(--ink-2); }
.icon-btn svg { width: 18px; height: 18px; display: block; }
.icon-btn:active { transform: scale(0.92); transition: transform 90ms ease-out; }
.sheet-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 2px 16px 28px; scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--ink-3) 45%, transparent) transparent; -webkit-overflow-scrolling: touch;
  mask-image: linear-gradient(to bottom, transparent 0, #000 10px, #000 calc(100% - 16px), transparent 100%); }

@media (min-width: 900px) {
  .topbar { left: 16px; right: auto; width: 400px; margin: 0; }
  .sheet { left: 16px; right: auto; top: calc(78px + var(--safe-t)); bottom: 98px; width: 400px; height: auto; border-radius: var(--radius); border-bottom: 1px solid var(--glass-edge); padding-bottom: 0; }
  .sheet-grip { display: none; }
  .sheet-head { padding-top: 12px; }
  .tabbar { left: 50%; right: auto; bottom: 18px; transform: translateX(-50%); width: 460px; border-radius: 22px; border-bottom: 1px solid var(--glass-edge); padding: 0 6px; height: var(--tabbar-h); }
}

/* ------------------------------------------------------------- contenido */
h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); margin: 22px 16px 7px; font-weight: 650; }
.group { margin-bottom: 6px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--line); min-height: 44px; }
.row:last-child { border-bottom: 0; }
.label { color: var(--ink-2); }
.muted { color: var(--ink-3); }
.small { font-size: 0.86rem; }
.center { text-align: center; }
.card { display: block; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; margin: 8px 0; }
.card-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card-title { font-weight: 650; font-size: 1.02rem; letter-spacing: -0.01em; }
.card p { margin: 6px 0; }
.card.danger { border-color: rgba(178, 59, 42, 0.35); background: rgba(178, 59, 42, 0.07); }
button.card.catalog:active { transform: scale(0.985); transition: transform 90ms ease-out; }
.note { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0; padding: 10px 12px; border-radius: 12px; background: var(--card); color: var(--ink-2); font-size: 0.9rem; }
.note.warn { background: rgba(201, 154, 46, 0.15); color: #7a5b10; }
.note.lock { color: var(--ink-2); }
.note-icon svg { width: 16px; height: 16px; display: block; margin-top: 2px; }

.pill { font-size: 0.74rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); white-space: nowrap; color: var(--ink-2); }
.pill.warn { color: #8a6514; border-color: rgba(201, 154, 46, 0.4); }
.pill.passed { color: var(--yes); border-color: rgba(79, 138, 60, 0.4); }
.pill.rejected, .pill.void { color: var(--no); border-color: rgba(181, 69, 46, 0.35); }
.pill.gold { color: #8a6514; background: rgba(201, 154, 46, 0.16); }
.pill.red { color: var(--red); background: rgba(178, 59, 42, 0.12); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

.btn { display: block; width: 100%; min-height: 48px; margin: 10px 0 2px; border-radius: 14px; border: 0; font-weight: 650; font-size: 1rem; letter-spacing: -0.005em; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 8px rgba(181, 85, 46, 0.3); }
.btn.plain { background: var(--card); border: 1px solid var(--line); color: var(--accent); min-height: 42px; }
.btn.danger { background: var(--red); color: #fff; }
.btn:active:not(:disabled) { transform: scale(0.97); filter: brightness(0.95); transition: transform 100ms ease-out; }
.btn:disabled { opacity: 0.42; cursor: default; box-shadow: none; }
.link { background: none; border: 0; color: var(--accent); padding: 6px 0; font-weight: 600; text-align: left; }

.item { display: inline-flex; align-items: center; gap: 4px; font-weight: 650; font-variant-numeric: tabular-nums; padding: 3px 9px 3px 5px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); }
.item.done { opacity: 0.5; }
.item-icon svg { width: 20px; height: 20px; display: block; }
.inv { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.inv .item { justify-content: center; padding: 8px; }
.cost { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.yield { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.craft, .trade { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.craft .btn, .card-row .btn { width: auto; min-width: 104px; margin: 0; padding: 0 16px; }
.arrow { color: var(--ink-3); font-weight: 700; }
.need-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; }
.need-actions { display: flex; gap: 6px; }
.need-actions .btn { width: auto; min-height: 36px; padding: 0 12px; margin: 0; font-size: 0.9rem; }
.donate { display: flex; flex-direction: column; }

.bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 8px 0; }
.bar span { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.bar.warm span { background: linear-gradient(90deg, #d29b55, var(--accent)); }
.bar.gold span { background: var(--gold); }
.bar.red span { background: var(--red); }
.jornadas-big { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.jornadas-big strong { font-size: 1.6rem; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

.face { display: inline-block; line-height: 0; border-radius: 999px; box-shadow: 0 0 0 2px var(--glass-thick); }
.face svg { display: block; }
.faces { display: inline-flex; align-items: center; }
.faces .face + .face { margin-left: -7px; }
.faces .more { font-size: 0.75rem; font-weight: 700; margin-left: 4px; color: var(--ink-3); }
.person { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; min-width: 0; }
.person > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.proclama { margin: 4px 0 10px; padding: 16px 18px 14px; border-radius: 18px; background: rgba(201, 154, 46, 0.1); border: 1px solid rgba(201, 154, 46, 0.3); }
.proclama blockquote { margin: 0 0 10px; font-family: ui-serif, "New York", Georgia, serif; font-size: 1.12rem; line-height: 1.42; letter-spacing: -0.005em; }
.proclama figcaption { display: flex; align-items: center; gap: 7px; font-size: 0.86rem; font-weight: 600; }

/* ------------------------------------------------------------- listas agrupadas (iOS) */
.list { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.cell { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 9px 14px; background: none; border: 0; text-align: left; position: relative; color: var(--ink); }
.cell + .cell::before { content: ''; position: absolute; top: 0; left: 58px; right: 0; height: 1px; background: var(--line); }
button.cell:active { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.cell-icon { flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; background: var(--ink-3); }
.cell-icon svg { width: 19px; height: 19px; display: block; }
.cell-icon.soft { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.cell-icon.soft svg { width: 22px; height: 22px; }
.cell-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cell-title { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-title.danger { color: var(--red); }
.cell-sub { font-size: 0.84rem; color: var(--ink-3); line-height: 1.3; }
.cell-detail { color: var(--ink-3); font-size: 0.92rem; text-align: right; flex: none; max-width: 50%; display: inline-flex; align-items: center; gap: 6px; }
.cell-chevron svg { width: 16px; height: 16px; display: block; color: var(--ink-3); opacity: 0.6; }

/* cifras */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 4px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 10px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat strong { font-size: 1.45rem; line-height: 1.1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; font-weight: 720; }
.stat span { font-size: 0.74rem; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; text-align: center; }
.stat.warm strong { color: var(--accent); }

/* ficha de perfil */
.hero { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px 0 4px; }
.hero-avatar { position: relative; border: 0; background: none; padding: 0; border-radius: 999px; }
.hero-avatar .face { box-shadow: 0 0 0 4px var(--glass-thick), 0 8px 24px rgba(60, 40, 15, 0.25); }
.hero-avatar:active { transform: scale(0.96); transition: transform 100ms ease-out; }
.hero-edit { position: absolute; right: -2px; bottom: 2px; width: 30px; height: 30px; border-radius: 999px; display: grid; place-items: center; background: var(--accent); color: #fff; box-shadow: 0 0 0 3px var(--glass-thick); }
.hero-edit svg { width: 15px; height: 15px; display: block; }
.hero-name { font-size: 1.65rem; font-weight: 750; letter-spacing: -0.03em; line-height: 1.1; }
.hero-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.chip { font-size: 0.78rem; font-weight: 650; padding: 4px 10px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink-2); }
.chip.green { background: rgba(79, 138, 60, 0.16); color: var(--yes); }
.chip.sand { background: rgba(201, 154, 46, 0.18); color: #8a6514; }
.chip.gold { background: rgba(201, 154, 46, 0.2); color: #8a6514; }
.chip.red { background: rgba(178, 59, 42, 0.15); color: var(--red); }
.chip.blue { background: rgba(63, 127, 150, 0.16); color: var(--sea); }

/* ciudadania */
.card.citizen { padding: 14px; }
.citizen-head { display: flex; gap: 12px; align-items: center; }
.citizen-head p { margin: 2px 0 0; }
.ring-box { flex: none; line-height: 0; }
.progress-ring { width: 46px; height: 46px; transform: rotate(-90deg); }
.progress-ring .ring-bg, .big-ring .ring-bg { stroke-width: 5; }
.progress-ring .ring-fg, .big-ring .ring-fg { stroke-width: 5; stroke: var(--yes); }
.steps { list-style: none; padding: 0; margin: 10px 0 4px; border-top: 1px solid var(--line); }
.steps li { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); color: var(--ink); flex-wrap: nowrap; }
.step-dot { flex: none; width: 22px; height: 22px; border-radius: 999px; border: 2px solid color-mix(in srgb, var(--ink-3) 60%, transparent); display: grid; place-items: center; }
.steps li.ok .step-dot { background: var(--yes); border-color: var(--yes); color: #fff; }
.step-dot svg { width: 13px; height: 13px; display: block; }
.step-text { flex: 1; }
.steps li.ok .step-text { color: var(--ink-3); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--ink-3) 50%, transparent); }
.steps li .btn { width: auto; min-height: 34px; margin: 0; padding: 0 12px; font-size: 0.86rem; }

/* jornadas */
.jornadas-card { display: flex; gap: 14px; align-items: center; padding: 14px; }
.big-ring-box { line-height: 0; flex: none; }
.big-ring { width: 60px; height: 60px; transform: rotate(-90deg); }
.big-ring .ring-fg { stroke: var(--accent); }
.jornadas-count strong { font-size: 1.9rem; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.jornadas-count span { color: var(--ink-3); font-weight: 600; }

/* boton tintado */
.btn.tinted { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-icon svg { width: 18px; height: 18px; display: block; }

/* avatares */
.face img { display: block; width: 100%; height: 100%; border-radius: 999px; image-rendering: pixelated; object-fit: cover; background: #e9d7b4; }
.avatar-dialog { width: min(94vw, 460px); max-height: 88dvh; overflow-y: auto; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h2 { margin: 0; }
.avatar-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0 4px; }
.avatar-pick { border: 0; padding: 0; background: none; border-radius: 18px; aspect-ratio: 1; overflow: hidden; box-shadow: 0 0 0 1px var(--line); transition: transform 120ms ease-out; }
.avatar-pick img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.avatar-pick.on { box-shadow: 0 0 0 3px var(--accent); }
.avatar-pick:active { transform: scale(0.94); }
.upload { display: grid; grid-template-columns: 96px 1fr; gap: 8px 14px; align-items: center; }
.upload-preview { grid-row: span 3; width: 96px; height: 96px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 7%, transparent); image-rendering: pixelated; }
.upload .btn { margin: 0; }
.upload > .btn.primary { grid-column: 1 / -1; display: none; }
.upload.has > .btn.primary { display: block; }
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 0.9rem; color: var(--ink-2); }
.switch-row input { width: 22px; height: 22px; accent-color: var(--accent); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------------------- chat */
.agora-seg { position: sticky; top: 0; z-index: 3; margin: 0 0 10px; background: color-mix(in srgb, var(--glass-thick) 96%, var(--ink) 4%); box-shadow: 0 6px 14px -8px rgba(40, 25, 10, 0.25); }
.agora-seg button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; font-size: 0.9rem; padding: 0 4px; white-space: nowrap; }
.agora-seg .seg-dot { min-width: 16px; height: 16px; font-size: 0.64rem; }
.seg-dot { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 0.7rem; font-weight: 700; display: inline-grid; place-items: center; line-height: 1; }
.chip-row { display: flex; gap: 8px; margin: 0 0 8px; }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: 0.88rem; color: var(--ink-2); }
.chip-btn.on { background: var(--accent); color: #fff; border-color: transparent; }
.chat { display: flex; flex-direction: column; min-height: 48dvh; }
.chat-list { display: flex; flex-direction: column; gap: 2px; padding: 4px 0 8px; flex: 1; }
.chat-more { align-self: center; border: 0; background: none; color: var(--accent); font-weight: 600; padding: 8px; }
.chat-time { align-self: center; font-size: 0.74rem; color: var(--ink-3); margin: 10px 0 4px; font-weight: 600; }
.msg { display: flex; align-items: flex-end; gap: 8px; max-width: 86%; }
.msg.first { margin-top: 8px; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-col { display: flex; flex-direction: column; min-width: 0; }
.msg.mine .msg-col { align-items: flex-end; }
.msg-name { font-size: 0.76rem; font-weight: 650; color: var(--ink-3); margin: 0 0 3px 12px; }
.chat-face-gap { width: 30px; flex: none; }
.msg .face { flex: none; }
.bubble { padding: 8px 13px; border-radius: 19px; background: var(--card); border: 1px solid var(--line); line-height: 1.38; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.97rem; }
.msg.theirs:not(.last) .bubble { border-bottom-left-radius: 7px; }
.msg.theirs:not(.first) .bubble { border-top-left-radius: 7px; }
.msg.mine .bubble { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.msg.mine:not(.last) .bubble { border-bottom-right-radius: 7px; }
.msg.mine:not(.first) .bubble { border-top-right-radius: 7px; }
.msg-actions { display: flex; gap: 12px; align-items: center; margin: 3px 0 0 10px; }
.link.danger { color: var(--red); }
.chat-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 32px 16px; color: var(--ink-3); text-align: center; }
.chat-empty-icon svg { width: 34px; height: 34px; display: block; opacity: 0.6; }
.chat-composer { position: sticky; bottom: -14px; display: flex; align-items: flex-end; gap: 8px; padding: 6px; margin: 6px -4px 0; border-radius: 26px;
  background: var(--glass-thick); border: 1px solid var(--glass-edge); box-shadow: 0 8px 24px -10px rgba(40, 25, 10, 0.35); }
.chat-input { flex: 1; resize: none; min-height: 42px; max-height: 120px; padding: 10px 14px; border-radius: 21px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: 16px; line-height: 1.35; }
.chat-input:disabled { opacity: 0.7; }
.chat-send { flex: none; width: 42px; height: 42px; border-radius: 999px; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; }
.chat-send svg { width: 20px; height: 20px; display: block; }
.chat-send:disabled { opacity: 0.35; }
.chat-send:active:not(:disabled) { transform: scale(0.92); transition: transform 90ms ease-out; }
.debate-btn { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; border: 0; background: none; color: var(--accent); font-weight: 650; font-size: 0.9rem; padding: 4px 0; }

/* granero y obras */
.granary { padding: 14px; }
.granary-title { display: flex; gap: 10px; align-items: center; }
.granary.famine { border-color: rgba(178, 59, 42, 0.45); background: rgba(178, 59, 42, 0.08); }
.granary.abundance { border-color: rgba(79, 138, 60, 0.4); background: rgba(79, 138, 60, 0.07); }
.granary.low { border-color: rgba(201, 154, 46, 0.45); }
.feed-row { display: flex; gap: 8px; }
.feed-row .btn { margin: 4px 0 0; }
.zone-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 2px 0 6px; }
.work-option.dim { opacity: 0.6; }
.work-option .chip { flex: none; }

/* sucesos */
.card.suceso { padding: 16px; border-width: 1.5px; background: linear-gradient(160deg, rgba(201, 154, 46, 0.14), transparent 60%), var(--card); border-color: rgba(201, 154, 46, 0.45); }
.suceso-piratas, .suceso-incendio, .suceso-plaga { background: linear-gradient(160deg, rgba(178, 59, 42, 0.13), transparent 60%), var(--card) !important; border-color: rgba(178, 59, 42, 0.4) !important; }
.suceso-oraculo, .suceso-embajada, .suceso-mercader { background: linear-gradient(160deg, rgba(63, 127, 150, 0.14), transparent 60%), var(--card) !important; border-color: rgba(63, 127, 150, 0.4) !important; }
.suceso-kicker { font-size: 0.72rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.suceso-title { font-family: ui-serif, "New York", Georgia, serif; font-size: 1.35rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; margin: 6px 0 2px; }
.suceso-options { display: grid; gap: 8px; margin: 12px 0 6px; }
.suceso-opt { position: relative; overflow: hidden; display: flex; align-items: center; gap: 10px; text-align: left; padding: 11px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--glass-thick); min-height: 56px; }
.suceso-opt.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.suceso-opt:disabled { cursor: default; }
.suceso-opt:active:not(:disabled) { transform: scale(0.985); transition: transform 90ms ease-out; }
.opt-main { flex: 1; display: flex; flex-direction: column; gap: 2px; position: relative; z-index: 1; }
.opt-hint { font-size: 0.84rem; color: var(--ink-3); line-height: 1.3; }
.opt-count { font-weight: 750; font-variant-numeric: tabular-nums; color: var(--ink-2); position: relative; z-index: 1; }
.opt-bar { position: absolute; left: 0; top: 0; bottom: 0; background: color-mix(in srgb, var(--accent) 12%, transparent); pointer-events: none; }
.effects { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.chip.effect-sequia, .chip.effect-racion { background: rgba(201, 154, 46, 0.18); color: #8a6514; }
.chip.effect-bendicion, .chip.effect-herramientas { background: rgba(79, 138, 60, 0.16); color: var(--yes); }

/* juicios y ambicion */
.trial.open { border-color: rgba(178, 59, 42, 0.35); }
.trial-sides { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.vs { font-family: ui-serif, Georgia, serif; font-style: italic; color: var(--ink-3); font-size: 0.9rem; }
.defense { margin: 8px 0; padding: 10px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
.defense p { margin: 4px 0 0; font-family: ui-serif, Georgia, serif; font-style: italic; }
.juror { margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: rgba(201, 154, 46, 0.12); }
.vote-actions.two { grid-template-columns: 1fr 1fr; }
.daily.ready { border-color: rgba(79, 138, 60, 0.5); box-shadow: 0 0 0 2px rgba(79, 138, 60, 0.18); }
.daily.claimed { opacity: 0.75; }
.party-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 6px; border-radius: 999px; font-weight: 650; font-size: 0.86rem; background: color-mix(in srgb, var(--pc) 16%, transparent); color: var(--ink); }
.party-chip i { width: 12px; height: 12px; border-radius: 999px; background: var(--pc); display: block; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 0; }
.swatch { width: 30px; height: 30px; border-radius: 999px; border: 0; box-shadow: 0 0 0 2px var(--glass-thick); }
.swatch.on { box-shadow: 0 0 0 2px var(--glass-thick), 0 0 0 4px var(--ink); }
.party-new .field { margin-top: 8px; }
.patron { color: var(--gold); font-weight: 600; margin: 4px 0; }
.btn.danger { background: var(--red); color: #fff; }

/* version */
.version { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; margin: 8px 0 0; }
.update-bar { position: absolute; left: 50%; transform: translateX(-50%); top: calc(70px + var(--safe-t)); z-index: 55; border-radius: 999px; padding: 10px 18px; font-weight: 650; color: var(--accent); border: 1px solid var(--glass-edge); }

/* leyes */
.law-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.reason { font-family: ui-serif, Georgia, serif; font-style: italic; color: var(--ink-2); }
.votes { margin-top: 8px; }
.vote-bar { position: relative; height: 10px; border-radius: 5px; background: var(--line); display: flex; overflow: visible; }
.vote-bar .yes { background: var(--yes); border-radius: 5px 0 0 5px; }
.vote-bar .no { background: var(--no); margin-left: auto; border-radius: 0 5px 5px 0; }
.vote-bar .mark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); opacity: 0.55; border-radius: 1px; }
.vote-legend { display: flex; justify-content: space-between; margin-top: 8px; align-items: center; gap: 8px; }
.yes-t { color: var(--yes); font-weight: 650; display: inline-flex; align-items: center; gap: 4px; }
.no-t { color: var(--no); font-weight: 650; display: inline-flex; align-items: center; gap: 4px; }
.vote-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 10px; }
.vote-btn { min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 650; }
.vote-btn.si.on { background: var(--yes); color: #fff; border-color: transparent; }
.vote-btn.no.on { background: var(--no); color: #fff; border-color: transparent; }
.vote-btn.abst.on { background: var(--ink-3); color: #fff; border-color: transparent; }
.vote-btn:active { transform: scale(0.96); transition: transform 90ms ease-out; }
.law.compact .reason { display: none; }

/* elecciones */
.choices { display: grid; gap: 8px; margin-top: 8px; }
.choices.two { grid-template-columns: 1fr 1fr; }
.choice { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 48px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); text-align: left; }
.choice.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.choice .count { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.choice:disabled { opacity: 0.7; cursor: default; }
.cands { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.ostrakon { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.ostrakon .btn { margin: 0; width: auto; padding: 0 16px; }

/* formularios */
.form { display: flex; flex-direction: column; gap: 10px; }
.field { width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: 16px; }
textarea.field { resize: vertical; min-height: 80px; }
.field-row { display: grid; grid-template-columns: 1fr 1.4fr; align-items: center; gap: 10px; }
.field-row.col { grid-template-columns: 1fr; }
.field-row > span { color: var(--ink-2); font-size: 0.92rem; }
.trade-form { display: grid; grid-template-columns: auto 80px 1fr; gap: 8px; align-items: center; }
.segmented { display: flex; background: var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.segmented button { flex: 1; min-height: 36px; border: 0; border-radius: 9px; background: none; font-weight: 600; color: var(--ink-2); }
.segmented button.on { background: var(--glass-thick); color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); }
.segmented.small button { min-height: 30px; font-size: 0.8rem; padding: 0 10px; }

/* perfil */
.profile { display: flex; gap: 14px; align-items: center; margin: 6px 0 4px; }
.profile-name { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }
.steps { list-style: none; padding: 0; margin: 6px 0; }
.steps li { display: flex; align-items: center; gap: 10px; padding: 8px 4px; flex-wrap: wrap; color: var(--ink-2); }
.steps li.ok { color: var(--yes); }
.steps li .btn { width: auto; min-height: 36px; margin: 0 0 0 auto; padding: 0 12px; font-size: 0.88rem; }
.step-icon svg { width: 20px; height: 20px; display: block; }
.chronicle { list-style: none; padding: 0; margin: 0; }
.chronicle li { display: grid; grid-template-columns: 74px 1fr; gap: 8px; padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.chronicle li:last-child { border-bottom: 0; }

/* aviso */
.toast { position: absolute; left: 50%; top: calc(66px + var(--safe-t)); z-index: 60; max-width: min(92vw, 440px); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 0.92rem;
  transform: translate(-50%, -12px) scale(0.96); opacity: 0; pointer-events: none; transition: opacity 180ms ease, transform 260ms cubic-bezier(.22,1,.36,1); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.toast.err { color: var(--red); }
.toast.ok { color: var(--yes); }

/* dialogos */
.dialog { border-radius: 22px; max-width: min(92vw, 440px); padding: 22px; color: var(--ink); }
.dialog::backdrop { background: rgba(30, 20, 10, 0.32); }
.dialog h2 { margin: 0 0 10px; letter-spacing: -0.02em; }
.welcome h2 { font-family: ui-serif, Georgia, serif; font-size: 1.6rem; }
.welcome p { color: var(--ink-2); line-height: 1.5; }
.dots { display: flex; gap: 6px; justify-content: center; margin: 14px 0 4px; }
.dots span { width: 20px; height: 7px; border-radius: 4px; background: var(--line); transform: scaleX(0.35); transition: transform 220ms cubic-bezier(.22,1,.36,1); }
.dots span.on { transform: scaleX(1); background: var(--accent); }

/* portada */
.auth-wrap { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; z-index: 40; background: linear-gradient(to bottom, rgba(233,220,194,0) 40%, rgba(233,220,194,0.35)); }
.auth { width: min(100%, 400px); border-radius: 26px; padding: 26px 22px 18px; }
.brand { text-align: center; margin-bottom: 16px; }
.wordmark { font-family: ui-serif, "New York", Georgia, serif; font-size: clamp(2.4rem, 9vw, 3.2rem); line-height: 1.02; letter-spacing: -0.03em; margin: 0; font-weight: 600; }
.tagline { margin: 8px 0 0; color: var(--ink-2); line-height: 1.4; }
.auth .segmented { margin-bottom: 14px; }
.auth-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
.fatal { position: absolute; inset: 20% 16px auto; margin: auto; max-width: 420px; padding: 24px; border-radius: 22px; text-align: center; }

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

/* Modo oscuro de las piezas: al final, para ganar a las reglas claras de arriba. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .chip.sand, :root:not([data-theme="light"]) .chip.gold { color: #f0cf7a; }
  .note.warn { color: #e8c777; }
  .chip.sand, .chip.gold { color: #f0cf7a; }
  .chip.blue { color: #8cc6da; }
  .chip.green { color: #a9dc93; }
  .face img { background: #3a3128; }
  .regime { background: rgba(120, 190, 100, 0.2); color: #a9dc93; }
  .regime-oligarquia { background: rgba(230, 190, 90, 0.2); color: #f0cf7a; }
  .regime-tirania { background: rgba(230, 100, 80, 0.22); color: #f3a08f; }
}
