:root {
  --bg: #0f1c19;
  --bg2: #14231f;
  --card: #1a2d28;
  --line: #2a433c;
  --ink: #eaf2ec;
  --muted: #9db3aa;
  --accent: #f2b544;
  --accent2: #6fd3b8;
  --danger: #ff7a6b;
  --ok: #7ed98a;
  --radius: 14px;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 Inter, system-ui, sans-serif; }
a { color: var(--accent2); }
h1, h2, .title { font-family: Fraunces, Georgia, serif; letter-spacing: -0.01em; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 22px 0 10px; }
.eyebrow { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); font-weight: 600; }

/* --- Header --- */
.top { display: flex; gap: 20px; align-items: center; justify-content: space-between; padding: 14px 22px; border-bottom: 1px solid var(--line); background: var(--bg2); }
.brand { display: flex; gap: 12px; align-items: center; }
.brand h1 { margin: 0; font-size: 22px; }
.sub { margin: 0; color: var(--muted); font-size: 13px; }
.logo { width: 38px; height: 38px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffe08a, var(--accent) 45%, #b9741e); box-shadow: 0 0 0 3px #f2b54433, inset -4px -4px 0 #0002; position: relative; }
.logo::before, .logo::after { content: ""; position: absolute; top: 14px; width: 5px; height: 7px; border-radius: 3px; background: #1b1b1b; }
.logo::before { left: 11px; } .logo::after { left: 21px; }
.director-msg { max-width: 560px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 14px; }
.director-msg p { margin: 2px 0 0; font-size: 14px; }

/* --- Layout --- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 450px; gap: 0; height: calc(100vh - 118px); min-height: 560px; }
.layout > * { min-width: 0; }
body { overflow-x: hidden; }
.stage { position: relative; padding: 16px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#world { max-width: 100%; height: auto; max-height: 100%; border-radius: 18px; box-shadow: 0 20px 60px #0008; cursor: pointer; image-rendering: auto; }
.clock { position: absolute; top: 26px; left: 28px; background: #0009; backdrop-filter: blur(6px); border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.hint { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); margin: 0; font-size: 12px; color: var(--muted); background: #0007; padding: 3px 10px; border-radius: 999px; }
.tooltip { position: absolute; pointer-events: none; background: #0b1412ee; border: 1px solid var(--line); padding: 6px 10px; border-radius: 10px; font-size: 13px; white-space: nowrap; }

.panel { border-left: 1px solid var(--line); background: var(--bg2); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 2px; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.tabs button { background: transparent; border: 1px solid transparent; color: var(--muted); padding: 6px 8px; border-radius: 999px; font: inherit; font-size: 12.5px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--ink); border-color: var(--line); }
.tabs button { flex: 0 0 auto; }
.tabs .cta { color: var(--bg); background: var(--accent); margin-left: auto; font-weight: 600; }
.tabs .cta[aria-selected="true"] { background: #ffd27a; color: var(--bg); }
.tabpanel { padding: 14px 18px 30px; overflow-y: auto; flex: 1; min-height: 0; }
.lead { color: var(--muted); font-size: 14px; margin-top: 0; }

/* --- Stats --- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats.small { grid-template-columns: repeat(3, 1fr); margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.stat b { display: block; font-size: 20px; font-family: Fraunces, serif; }
.stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

/* --- Events --- */
.events { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.events li { background: var(--card); border-left: 3px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 13.5px; }
.events li small { color: var(--muted); font-family: var(--mono); font-size: 11px; margin-right: 6px; }
.events li.death, .events li.attack { border-left-color: var(--danger); }
.events li.built, .events li.science, .events li.network { border-left-color: var(--accent2); }
.events li.director, .events li.era { border-left-color: var(--accent); }
.events li.winner { border-left-color: var(--ok); background: #1f3a2a; }

/* --- Agents --- */
.agent-list { display: flex; flex-direction: column; gap: 6px; }
.agent-row { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; cursor: pointer; text-align: left; color: inherit; font: inherit; width: 100%; }
.agent-row:hover { border-color: var(--accent2); }
.agent-row.dead { opacity: .5; }
.dot { width: 24px; height: 24px; border-radius: 50%; box-shadow: inset -3px -3px 0 #0003; }
.agent-row small { color: var(--muted); display: block; font-size: 12px; }
.pill { font-family: var(--mono); font-size: 12px; background: #0004; border-radius: 999px; padding: 2px 8px; }
.agent-detail .back { background: none; border: 0; color: var(--accent2); font: inherit; cursor: pointer; padding: 0; margin-bottom: 8px; }
.agent-head { display: flex; gap: 12px; align-items: center; }
.agent-head .dot { width: 44px; height: 44px; }
.agent-head h2 { margin: 0; font-size: 24px; }
.thought { background: #0003; border-radius: 12px; padding: 10px 12px; font-style: italic; margin: 12px 0; border: 1px dashed var(--line); }
.bars { display: grid; grid-template-columns: 90px 1fr 34px; gap: 6px 10px; align-items: center; font-size: 13px; }
.bar { height: 8px; background: #0005; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent2); border-radius: 99px; }
.bar i.low { background: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; }
.chip code, .word { font-family: var(--mono); color: var(--accent); }
.memory { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13.5px; }
.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; font-size: 13.5px; }
.checks li::before { content: "○"; margin-right: 8px; color: var(--muted); }
.checks li.ok::before { content: "●"; color: var(--ok); }

/* --- Dictionary --- */
input[type=search], .create input:not([type=range]):not([type=color]), .create textarea {
  width: 100%; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font: inherit; }
.dict { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.word-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.word-card .word { font-size: 16px; display: block; }
.word-card .mean { font-size: 13.5px; }
.word-card small { color: var(--muted); font-size: 11.5px; }
.word-card.tentativa { opacity: .65; border-style: dashed; }
.conf { height: 4px; background: #0005; border-radius: 99px; margin-top: 6px; overflow: hidden; }
.conf i { display: block; height: 100%; background: var(--accent); }

/* --- Science & challenge --- */
.task { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 8px; }
.task code, .programs code { font-family: var(--mono); font-size: 12.5px; color: var(--accent2); word-break: break-all; }
.task .acc { float: right; font-family: Fraunces, serif; font-size: 20px; }
.programs { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.programs div { display: grid; grid-template-columns: 1fr 52px; gap: 8px; padding: 6px 8px; background: #0002; border-radius: 8px; }
.programs .full { color: var(--ok); }
.challenge { display: flex; flex-direction: column; gap: 6px; }
.c-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.c-dots { display: flex; gap: 4px; }
.c-dots i { width: 12px; height: 12px; border-radius: 50%; background: #0005; border: 1px solid var(--line); }
.c-dots i.ok { background: var(--ok); border-color: var(--ok); }
.legend { font-size: 12px; color: var(--muted); margin-top: 10px; }
.winner-card { background: linear-gradient(135deg, #2b4d34, #1a2d28); border: 1px solid var(--ok); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.teachings { display: flex; flex-direction: column; gap: 6px; }
.teach { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; }
.teach b { display: block; }
.history { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.history div { background: var(--card); border-radius: 10px; padding: 8px 10px; border: 1px solid var(--line); }

/* --- Create --- */
.create { display: flex; flex-direction: column; gap: 12px; }
.create label { display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; }
.create fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 6px; }
.create fieldset label { flex-direction: row; justify-content: space-between; align-items: center; }
.create input[type=range] { width: 55%; accent-color: var(--accent); }
.create .color { flex-direction: row; align-items: center; justify-content: space-between; }
.create input[type=color] { width: 54px; height: 32px; border: 0; background: none; }
.primary { background: var(--accent); color: #1b1404; border: 0; border-radius: 999px; padding: 11px 18px; font: inherit; font-weight: 600; cursor: pointer; }
.primary:disabled { opacity: .6; cursor: wait; }
#createMsg.err { color: var(--danger); } #createMsg.ok { color: var(--ok); }

.foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 22px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); background: var(--bg2); }

/* --- Responsive --- */
@media (max-width: 980px) {
  .top { flex-direction: column; align-items: stretch; padding: 12px 14px; }
  .director-msg { max-width: none; }
  .layout { grid-template-columns: 1fr; height: auto; }
  .stage { padding: 10px; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .tabpanel { max-height: none; }
  .dict { grid-template-columns: 1fr; }
  .hint { display: none; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs button { flex: 0 0 auto; }
  .tabs .cta { margin-left: 4px; }
  .clock { top: 16px; left: 18px; }
}

/* --- Sociedad, saber, conversaciones --- */
.talk { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.talk li { background: var(--card); border-radius: 12px 12px 12px 4px; padding: 7px 11px; font-size: 13.5px; border: 1px solid var(--line); }
.talk li b { color: var(--accent); font-weight: 600; }
.talk li small { color: var(--muted); }
.cards { display: flex; flex-direction: column; gap: 6px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; }
.card b { display: block; }
.card small { color: var(--muted); }
.card.on { border-color: var(--ok); }
.card p { margin: 6px 0 0; white-space: pre-wrap; }
.es-list { display: grid; grid-template-columns: 1fr; gap: 4px; margin: 10px 0; }
.es-row { display: grid; grid-template-columns: 90px 1fr 60px; gap: 8px; align-items: center; font-size: 13px; }
.reason { font-size: 13px; color: var(--muted); background: #0002; border-radius: 10px; padding: 8px 10px; }

.zoom { position: absolute; top: 26px; right: 28px; display: flex; gap: 4px; align-items: center; background: #0009; backdrop-filter: blur(6px); border-radius: 999px; padding: 3px 6px; }
.zoom button { background: transparent; border: 0; color: var(--ink); font-size: 16px; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; }
.zoom button:hover { background: #ffffff22; }
.zoom span { font-size: 12px; color: var(--muted); min-width: 34px; text-align: center; }
.chat { display: flex; gap: 6px; margin: 10px 0; }
.chat input { flex: 1; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; }
.chat .primary { padding: 8px 14px; }
@media (max-width: 980px) { .zoom { top: 16px; right: 18px; } }
