/* Fuentes guardadas dentro de la app: el juego se ve igual sin conexión. */
@font-face { font-family: 'Cormorant Garamond'; font-weight: 500; font-display: swap; src: url('assets/fonts/cormorant-garamond-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 600; font-display: swap; src: url('assets/fonts/cormorant-garamond-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 700; font-display: swap; src: url('assets/fonts/cormorant-garamond-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 400; font-display: swap; src: url('assets/fonts/inter-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 500; font-display: swap; src: url('assets/fonts/inter-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-display: swap; src: url('assets/fonts/inter-latin-600-normal.woff2') format('woff2'); }

:root {
  --bg: #0c1620;
  --panel: #13222e;
  --panel-2: #172836;
  --line: #243543;
  --gold: #c9a35a;
  --gold-soft: #8f7440;
  --parch: #e6d9b8;
  --ink: #1d1710;
  --ink-soft: #4a3f2c;
  --text: #d5dbe0;
  --muted: #8a98a5;
  --red: #d0675f;
  --serif: 'Cormorant Garamond', 'Georgia', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: #060c12;
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

#app {
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
@media (min-width: 480px) {
  #app { height: min(100dvh, 900px); margin: auto; border: 1px solid var(--line); border-radius: 24px; }
  body { align-items: center; }
}

/* ---------- Cabecera ---------- */
.top { display: flex; align-items: center; gap: 12px; padding: 18px 20px 6px; }
.crest {
  width: 34px; height: 34px; flex: none; border: 1px solid var(--gold-soft);
  border-radius: 6px; display: grid; place-items: center; color: var(--gold);
}
.top .head { flex: 1; min-width: 0; }
.eyebrow { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); }
.top h1 { font-family: var(--serif); font-weight: 600; font-size: 28px; line-height: 1.05; color: #f1ead6; margin-top: 2px; }
.menu-btn { color: var(--muted); padding: 6px; font-size: 22px; line-height: 1; letter-spacing: 1px; }

/* ---------- Contenido ---------- */
main { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 20px 16px; display: flex; flex-direction: column; }
main::-webkit-scrollbar { width: 0; }

/* Medidores */
.meters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 6px 0 12px; }
.meter .row { display: flex; align-items: center; gap: 6px; }
.meter .ico { color: var(--gold); display: grid; place-items: center; }
.meter .val { font-size: 20px; font-weight: 500; color: #f1ead6; font-variant-numeric: tabular-nums; }
.meter .lbl { font-size: 11px; color: var(--muted); margin-top: 2px; }
.bar { height: 2px; background: var(--line); margin-top: 3px; border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--gold); transition: width .5s cubic-bezier(.2, .8, .2, 1), background .3s; }
.meter.danger .bar i { background: var(--red); }
.meter.danger .val { color: #ecaaa5; }
.meter.up .val { animation: pulse-up .8s; }
.meter.down .val { animation: pulse-down .8s; }
@keyframes pulse-up { 30% { color: #9ad9a5; transform: translateY(-2px); } }
@keyframes pulse-down { 30% { color: var(--red); transform: translateY(2px); } }

.prev { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.prev::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* Carta */
.card-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.card {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  border: 1px solid var(--gold-soft); border-radius: 14px; overflow: hidden;
  background: var(--parch); touch-action: pan-y; user-select: none; cursor: grab;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  transition: transform .25s cubic-bezier(.2, .8, .2, 1), opacity .25s;
  will-change: transform;
}
.card.dragging { transition: none; cursor: grabbing; }
.card.out-left { transform: translateX(-130%) rotate(-12deg); opacity: 0; }
.card.out-right { transform: translateX(130%) rotate(12deg); opacity: 0; }
.card.enter { animation: card-in .35s cubic-bezier(.2, .8, .2, 1); }
@keyframes card-in { from { transform: translateY(18px) scale(.97); opacity: 0; } }

.art { position: relative; flex: 1 1 40%; min-height: 110px; display: grid; place-items: center; overflow: hidden; background-size: cover; background-position: center; }
.art::after { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 40%, transparent 30%, rgba(0, 0, 0, .55)); }
.art .mono { position: relative; z-index: 1; font-family: var(--serif); font-size: 84px; font-weight: 600; color: rgba(255, 244, 214, .85); text-shadow: 0 4px 24px rgba(0, 0, 0, .6); }
.art .tag { position: absolute; z-index: 1; left: 10px; bottom: 8px; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 244, 214, .7); }
.art.campesino { background: linear-gradient(160deg, #5c4a26, #2d2615 60%, #1a1a10); }
.art.mariscala { background: linear-gradient(160deg, #4b2a2c, #231418 60%, #12161e); }
.art.constructor { background: linear-gradient(160deg, #4a4538, #262a2a 60%, #14181c); }
.art.clero { background: linear-gradient(160deg, #3d4a60, #1c2535 60%, #10161f); }
.art.noble { background: linear-gradient(160deg, #523b52, #261c30 60%, #12141f); }
.art.pueblo { background: linear-gradient(160deg, #5a3f24, #2c2218 60%, #14161a); }
.art.espia { background: linear-gradient(160deg, #2d4650, #17252c 60%, #0f161b); }
.art.embajador { background: linear-gradient(160deg, #3b4f2e, #1d2a1a 60%, #11171a); }
.art.mercader { background: linear-gradient(160deg, #5a5224, #2a2814 60%, #14161a); }
.art.soldado { background: linear-gradient(160deg, #44464c, #22252c 60%, #12151a); }
.art.nodriza, .art.cronista { background: linear-gradient(160deg, #4a3a52, #231c2c 60%, #12141c); }

/* Con ilustración, la imagen cubre todo el espacio (los degradados de arriba son solo el respaldo). */
.art[style*="background-image"] { background-size: cover; background-repeat: no-repeat; }

.card .body { flex: 1 1 52%; padding: 14px 16px 16px; color: var(--ink); overflow-y: auto; }
.card .who { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); font-weight: 500; }
.card h2 { font-family: var(--serif); font-size: 32px; font-weight: 700; line-height: 1.05; margin: 6px 0 8px; color: #1a140c; }
.card p { font-family: var(--serif); font-size: 19px; line-height: 1.22; font-weight: 500; color: #2c2416; }

/* Opciones */
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.opt {
  text-align: left; padding: 11px 12px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; transition: border-color .15s, background .15s, transform .15s;
  display: flex; flex-direction: column; gap: 4px; min-height: 92px;
}
.opt:hover, .opt.active { border-color: var(--gold); background: var(--panel-2); }
.opt:active { transform: scale(.98); }
.opt .dir { display: flex; justify-content: space-between; align-items: center; color: var(--gold); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.opt .dir .arr { font-size: 16px; line-height: 1; letter-spacing: 0; }
.opt .lab { font-size: 14px; font-weight: 600; color: #f1ead6; line-height: 1.2; }
.opt .fx { font-size: 11px; color: var(--gold-soft); margin-top: auto; }
.hint { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 12px; margin-top: 10px; }

/* ---------- Reino ---------- */
.banner { height: 118px; border-radius: 12px; border: 1px solid var(--line); margin: 6px 0 12px; position: relative; overflow: hidden;
  background: linear-gradient(160deg, #3a4a30, #1d2a2a 55%, #101a20) center / cover; }
.banner span { position: absolute; left: 10px; bottom: 10px; background: rgba(8, 14, 20, .75); padding: 5px 9px; border-radius: 6px; font-size: 12px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 10px; margin-bottom: 14px; }
.stat .k { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); }
.stat .k svg { color: var(--gold); }
.stat .v { font-size: 26px; font-weight: 500; color: #f1ead6; margin-top: 2px; font-variant-numeric: tabular-nums; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; margin-bottom: 14px; }
.panel .row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.panel .row b { color: var(--gold); font-weight: 500; }
.alert { border-left: 2px solid var(--gold); background: var(--panel); border-radius: 4px; padding: 10px 12px; margin-bottom: 14px; }
.alert.bad { border-color: var(--red); }
.alert strong { display: block; font-size: 14px; color: #f1ead6; margin-bottom: 3px; }
.alert span { font-size: 13px; color: var(--muted); line-height: 1.4; }
h3 { font-family: var(--serif); font-size: 24px; font-weight: 600; color: #f1ead6; margin: 4px 0 8px; display: flex; justify-content: space-between; align-items: baseline; }
h3 small { font-family: var(--sans); font-size: 12px; font-weight: 400; color: var(--gold); }
.work { margin-bottom: 10px; }
.work .t { display: flex; justify-content: space-between; font-size: 13px; color: var(--text); margin-bottom: 5px; }
.work .t b { color: var(--gold); font-weight: 400; }
.work .bar { height: 3px; margin-top: 0; }
.muted { font-size: 13px; color: var(--muted); line-height: 1.45; margin-bottom: 14px; }
.btn { display: block; width: 100%; padding: 14px; border-radius: 10px; font-size: 15px; font-weight: 600; text-align: center; margin-top: auto; }
.btn.gold { background: var(--gold); color: #1a1408; }
.btn.gold:hover { background: #d6b36c; }
.btn.line { border: 1px solid var(--gold-soft); color: var(--text); margin-top: 10px; }
.btn.line:hover { border-color: var(--gold); }
.spacer { height: 6px; flex: none; }

/* ---------- Consejo ---------- */
.challenge { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: #8c2f29; font-weight: 600; margin-bottom: 4px; }
.lealtad-head { display: flex; justify-content: space-between; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 6px 0 10px; }
.lealtad-head span:last-child { color: var(--gold); text-transform: none; letter-spacing: 0; font-size: 12px; }
.fac { display: flex; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.fac.high { border-color: var(--gold-soft); }
.fac.low { border-color: #6b3330; background: #1a1d26; }
.fac .avatar { flex: none; width: 56px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.fac .pic { width: 56px; height: 64px; flex: none; min-height: 0; border-radius: 6px; border: 1px solid var(--gold-soft); }
.fac .pic .mono { font-size: 32px; }
.fac .pic::after { display: none; }
.fac .fic { color: var(--gold); }
.fac .finfo { flex: 1; min-width: 0; }
.fac .frow { display: flex; justify-content: space-between; align-items: baseline; }
.fac h4 { font-family: var(--serif); font-size: 26px; font-weight: 600; color: #f1ead6; line-height: 1.05; }
.fac .fval { color: var(--gold); font-size: 17px; font-variant-numeric: tabular-nums; }
.fac.low .fval { color: var(--red); }
.fac .fval small { font-size: 12px; color: var(--muted); }
.fac .fleader { font-size: 11px; color: var(--muted); margin: 1px 0 6px; }
.fac .fdemand { font-size: 13px; font-weight: 600; color: #f1ead6; line-height: 1.3; }
.fac .frisk { font-size: 12px; color: var(--muted); line-height: 1.35; margin-top: 3px; }
.fac .favor { font-size: 11px; color: var(--gold); margin-top: 6px; }

/* ---------- Crónicas ---------- */
.log { list-style: none; border-left: 1px solid var(--line); margin-left: 4px; }
.log li { padding: 0 0 12px 14px; position: relative; font-size: 13px; line-height: 1.4; color: var(--text); }
.log li::before { content: ''; position: absolute; left: -4px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.log li small { display: block; color: var(--muted); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.dyn { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.dyn b { font-family: var(--serif); font-size: 19px; font-weight: 600; color: #f1ead6; }
.dyn span { color: var(--muted); font-size: 12px; }
.dyn em { font-style: normal; color: var(--gold); font-family: var(--serif); font-size: 19px; }
.empty { color: var(--muted); font-size: 13px; padding: 4px 0 14px; }

/* ---------- Caída ---------- */
.fall { padding: 0 0 20px; overflow-y: auto; }
.fall .hero { height: 240px; background: radial-gradient(ellipse at 50% 60%, #1f2e3d, #0a1118 70%) center / cover; position: relative; }
.fall .hero::after { content: ''; position: absolute; inset: 0; background: linear-gradient(transparent 50%, var(--bg)); }
.fall .in { padding: 0 20px; }
.fall .tagline { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: #d98b9a; margin-top: 12px; }
.fall h2 { font-family: var(--serif); font-size: 40px; line-height: 1.02; font-weight: 600; color: #f1ead6; margin: 6px 0 10px; }
.fall .lead { font-size: 14px; color: var(--muted); line-height: 1.5; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.nums { display: grid; grid-template-columns: repeat(3, 1fr); padding: 14px 0; border-bottom: 1px solid var(--line); }
.nums b { display: block; font-family: var(--serif); font-size: 32px; font-weight: 500; color: var(--gold); line-height: 1; }
.nums span { font-size: 11px; color: var(--muted); }
.fall h4 { font-family: var(--serif); font-size: 22px; font-weight: 600; color: #f1ead6; margin: 14px 0 8px; }
.fall .balance { list-style: none; font-size: 13px; color: var(--text); line-height: 1.6; }
.legacy { display: flex; align-items: center; gap: 12px; margin: 14px 0 8px; color: var(--gold); }
.legacy small { display: block; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.legacy b { font-family: var(--serif); font-size: 32px; font-weight: 500; color: var(--gold-soft); }
.works { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 12px; color: var(--text); margin-bottom: 16px; }
.works span::before { content: '✦ '; color: var(--gold); }

/* ---------- Navegación ---------- */
nav { display: flex; border-top: 1px solid var(--line); background: #0a131b; padding: 8px 4px calc(10px + env(safe-area-inset-bottom)); flex: none; }
nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); padding: 4px 0; }
nav button[aria-current="page"] { color: var(--gold); }
nav button:disabled { opacity: .35; cursor: default; }

#toasts { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 30; pointer-events: none; width: min(90vw, 380px); }
.toast { background: #0a131b; border: 1px solid var(--gold-soft); color: var(--text); padding: 9px 14px; border-radius: 10px; font-size: 13px; text-align: center; animation: toast 2.6s forwards; }
@keyframes toast { 0% { opacity: 0; transform: translateY(6px); } 10%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* ---------- Obras ---------- */
.purse { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 12px; }
.purse small { display: block; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.purse b { font-size: 30px; font-weight: 500; color: var(--gold); font-variant-numeric: tabular-nums; }
.mini { font-size: 12px; padding: 6px 10px; border: 1px solid var(--gold-soft); border-radius: 8px; color: var(--gold); white-space: nowrap; }
.mini:hover { border-color: var(--gold); }
.mini.gold { background: var(--gold); color: #1a1408; border-color: var(--gold); font-weight: 600; }
.collect .bar { height: 4px; margin: 8px 0 6px; }
.small { font-size: 12px; margin-bottom: 10px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn.sm { padding: 10px 8px; font-size: 13px; margin-top: 0; }
.btn:disabled { opacity: .4; cursor: default; }
.bld { display: flex; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.bico { flex: none; width: 44px; height: 44px; border: 1px solid var(--gold-soft); border-radius: 8px; display: grid; place-items: center; color: var(--gold); }
.binfo { flex: 1; min-width: 0; }
.btop { display: flex; justify-content: space-between; align-items: center; }
.bld h4 { font-family: var(--serif); font-size: 22px; font-weight: 600; color: #f1ead6; line-height: 1.1; }
.pips { display: flex; gap: 4px; }
.pips i { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--gold-soft); }
.pips i.on { background: var(--gold); border-color: var(--gold); }
.pips i.wip { border-color: var(--gold); animation: pulse-wip 1.2s infinite; }
@keyframes pulse-wip { 50% { background: rgba(201, 163, 90, .4); } }
.bdesc { font-size: 12px; color: var(--muted); margin: 3px 0 6px; line-height: 1.35; }
.bperk { font-size: 12px; color: var(--gold); margin-bottom: 2px; }
.bnext { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.bld .btn { margin-top: 6px; }
.bprog .bar { height: 4px; margin-top: 4px; }
.brow { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: var(--text); margin-top: 6px; }
.brow b { color: var(--gold); font-weight: 500; font-variant-numeric: tabular-nums; }
.why { font-size: 11px; color: var(--muted); margin-top: 5px; }
.why.max { color: var(--gold); font-size: 12px; margin-top: 8px; }
.why.center { text-align: center; margin: 6px 0 2px; }
.gain { font-size: 13px; color: var(--gold); margin-bottom: 12px; }

/* ---------- Ventanas (anuncio de prueba y tienda) ---------- */
.modal { position: fixed; inset: 0; background: rgba(4, 8, 12, .82); display: flex; align-items: flex-end; justify-content: center; z-index: 20; animation: fade-in .2s; }
@keyframes fade-in { from { opacity: 0; } }
.sheet { width: 100%; max-width: 430px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px 18px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); }
.sheet h3 { font-size: 26px; margin: 4px 0 6px; }
.sheet .btn { margin-top: 10px; }
.prod { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left; padding: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; margin-top: 8px; }
.prod:hover:not(:disabled) { border-color: var(--gold); }
.prod:disabled { opacity: .5; cursor: default; }
.prod b { display: block; color: #f1ead6; font-size: 14px; font-weight: 600; }
.prod small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.prod em { font-style: normal; color: var(--gold); font-size: 12px; white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
@media (max-height: 700px) {
  .top h1 { font-size: 24px; }
  .card h2 { font-size: 26px; }
  .card p { font-size: 17px; }
  .art { min-height: 80px; }
  .art .mono { font-size: 60px; }
}
