/* Ubi Sunt — estética de atlas antiguo: papel, tinta sepia y cinabrio. */
:root {
  --paper: #efe4cb; --paper-hi: #f8f1df; --paper-lo: #e2d3b0;
  --ink: #2b2118; --muted: #7b6748; --rule: #c9b58a; --rule-soft: #dccba3;
  --accent: #9c3a22; --on-accent: #fbf3e2; --gold: #a9812f; --ok: #3d7558;
  --sea: #e3e7d6; --land: #e6d5ac; --shape: #37281b;
  --shadow: 60 40 15;
  --display: "Cinzel", "Trajan Pro", "Times New Roman", serif;
  --body: "EB Garamond", "Iowan Old Style", Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16130e; --paper-hi: #211c14; --paper-lo: #0f0d09;
    --ink: #eaddbf; --muted: #a18d68; --rule: #4d412c; --rule-soft: #362e20;
    --accent: #dd7a58; --on-accent: #1a130c; --gold: #d0aa57; --ok: #74c198;
    --sea: #151c1f; --land: #3b3222; --shape: #ead9ad;
    --shadow: 0 0 0;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--paper-lo); }
body {
  margin: 0; color: var(--ink); font: 18px/1.4 var(--body);
  min-height: 100vh; display: flex; justify-content: center;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .1 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(120% 90% at 50% 0%, var(--paper-hi), var(--paper) 55%, var(--paper-lo));
  background-attachment: fixed;
}
.page { width: 100%; max-width: 600px; padding: 0 18px; display: flex; flex-direction: column; min-height: 100vh; }

/* ---------- cabecera ---------- */
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 0 14px; position: relative; }
header::after { /* filete doble con rombo central */
  content: "◆"; position: absolute; left: 0; right: 0; bottom: -7px; height: 14px; line-height: 14px; text-align: center;
  font-size: 9px; color: var(--accent);
  background:
    linear-gradient(var(--rule), var(--rule)) left 5px / calc(50% - 14px) 1px no-repeat,
    linear-gradient(var(--rule), var(--rule)) right 5px / calc(50% - 14px) 1px no-repeat,
    linear-gradient(var(--rule), var(--rule)) left 8px / calc(50% - 14px) 1px no-repeat,
    linear-gradient(var(--rule), var(--rule)) right 8px / calc(50% - 14px) 1px no-repeat;
}
.brand { text-align: center; }
.side { flex: 1 1 0; display: flex; gap: 8px; }
.side.end { justify-content: flex-end; }
button.icon.lang { font-size: .68rem; letter-spacing: .08em; font-weight: 700; }
h1 { margin: 0; font: 700 clamp(1.7rem, 7vw, 2.4rem)/1 var(--display); letter-spacing: .26em; margin-right: -.26em; text-transform: uppercase; }
h1::first-letter { color: var(--accent); }
.tagline { margin: 6px 0 0; font-style: italic; font-size: .92rem; color: var(--muted); }

button { font: inherit; color: inherit; cursor: pointer; border: 1px solid var(--rule); background: var(--paper-hi); border-radius: 3px; padding: 8px 16px; transition: border-color .15s, background .15s, transform .08s; }
button:hover { border-color: var(--ink); }
button:active { transform: translateY(1px); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.icon { width: 38px; height: 38px; padding: 0; border-radius: 50%; display: grid; place-items: center; font: 500 1rem var(--display); background: transparent; flex: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font: 700 .82rem var(--display); letter-spacing: .16em; text-transform: uppercase; box-shadow: inset 0 0 0 2px var(--accent), inset 0 0 0 3px rgb(255 255 255 / .28); }
button.primary:hover { filter: brightness(1.08); border-color: var(--accent); }

/* ---------- modos ---------- */
.modes { display: flex; gap: 26px; justify-content: center; margin: 24px 0 14px; }
.modes button { border: 0; background: none; padding: 2px 0 5px; border-radius: 0; font: 500 .74rem var(--display); letter-spacing: .2em; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid transparent; }
.modes button:hover { color: var(--ink); }
.modes button.active { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- lámina ---------- */
.plate { margin: 0 auto; width: min(100%, 340px); }
.frame {
  position: relative; aspect-ratio: 1; padding: 14px;
  border: 1px solid var(--ink); outline: 1px solid var(--rule); outline-offset: 4px;
  background:
    repeating-linear-gradient(0deg, transparent 0 calc(25% - 1px), var(--rule-soft) calc(25% - 1px) 25%),
    repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), var(--rule-soft) calc(25% - 1px) 25%),
    var(--paper-hi);
  box-shadow: 0 10px 28px -14px rgb(var(--shadow) / .55), inset 0 0 40px rgb(var(--shadow) / .07);
  transition: background-color .4s;
}
.frame::before { /* marco interior fino */ content: ""; position: absolute; inset: 5px; border: 1px solid var(--rule); pointer-events: none; }
.frame.ctx { background-color: var(--sea); padding: 6px; }
#shape { display: block; width: 100%; height: 100%; position: relative; z-index: 1; }
#shape-path { fill: var(--shape); transition: fill .5s; filter: drop-shadow(0 2px 3px rgb(var(--shadow) / .3)); }
#ctx-path { fill: var(--land); stroke: var(--muted); stroke-opacity: .55; stroke-width: .7; vector-effect: non-scaling-stroke; }
.frame.ctx #shape-path { fill: var(--accent); fill-opacity: .78; stroke: var(--accent); stroke-width: 1.2; vector-effect: non-scaling-stroke; filter: none; }
#shape.won #shape-path, .frame.ctx #shape.won #shape-path { fill: var(--ok); stroke: var(--ok); }
.rose { position: absolute; top: 12px; right: 12px; width: 54px; height: 54px; opacity: .5; pointer-events: none; }
.rose circle { fill: none; stroke: var(--muted); stroke-width: 1; }
.rose .minor { fill: var(--rule); }
.rose .major { fill: var(--muted); }
.rose .north { fill: var(--accent); }
.frame.ctx .rose { display: none; }

figcaption { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; font-size: .84rem; font-style: italic; color: var(--muted); }
.scale { display: flex; align-items: center; gap: 7px; flex: 1; justify-content: flex-end; font-style: normal; font-variant-numeric: tabular-nums; }
.scale i { display: block; height: 5px; border: 1px solid var(--ink); background: linear-gradient(90deg, var(--ink) 50%, transparent 50%); transition: width .4s; }

/* ---------- intentos ---------- */
.legend, .row { display: grid; grid-template-columns: minmax(0, 1fr) 84px 44px 132px 58px; gap: 0; }
.legend { margin-top: 20px; font: 500 .6rem var(--display); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); padding: 0 0 5px; border-bottom: 1px solid var(--ink); }
.legend span { text-align: center; }
.legend span:first-child { text-align: left; padding-left: 10px; }
.rows { display: grid; }
.row { min-height: 44px; border-bottom: 1px solid var(--rule); align-items: stretch; position: relative; }
.row > div { display: flex; align-items: center; justify-content: center; padding: 4px 6px; font-size: .95rem; text-align: center; font-variant-numeric: tabular-nums lining-nums; border-left: 1px solid var(--rule-soft); }
.row .name { justify-content: flex-start; text-align: left; font-weight: 700; padding-left: 10px; border-left: 0; overflow: hidden; }
.row .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .when { font-size: .88rem; font-style: italic; line-height: 1.1; }
.row .pct { font-weight: 700; background: linear-gradient(90deg, color-mix(in srgb, var(--gold) 34%, transparent) var(--p), transparent var(--p)); }
.row.hit { background: color-mix(in srgb, var(--ok) 14%, transparent); }
.row.hit .name, .row.hit .dir { color: var(--ok); }
.row.hit .pct { background: none; color: var(--ok); }
.row.empty { color: var(--rule); font: 500 .8rem var(--display); align-items: center; padding-left: 10px; }
.row.empty.next { color: var(--accent); }
.row.empty.next::after { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 2px; background: var(--accent); }
.needle { width: 28px; height: 28px; }
.needle .ring { fill: none; stroke: var(--rule); stroke-width: 1; }
.needle .tip { fill: var(--accent); }
.needle .tail { fill: var(--muted); }

.row.fresh > div { animation: ink .5s both; }
.row.fresh > div:nth-child(2) { animation-delay: .12s; }
.row.fresh > div:nth-child(3) { animation-delay: .24s; }
.row.fresh > div:nth-child(4) { animation-delay: .36s; }
.row.fresh > div:nth-child(5) { animation-delay: .48s; }
@keyframes ink { from { opacity: 0; transform: translateY(5px); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media (max-width: 470px) {
  body { font-size: 17px; }
  .legend, .row { grid-template-columns: minmax(0, 1fr) 68px 36px 92px 48px; }
  .row > div { font-size: .82rem; padding: 3px; }
  .row .when { font-size: .76rem; }
  .needle { width: 24px; height: 24px; }
  .legend { font-size: .5rem; letter-spacing: .08em; }
  /* «Ubi Sunt» en una sola línea: menos tracking y los laterales justos para los botones */
  header { gap: 6px; }
  header .side { flex: 0 0 84px; }
  header h1 { font-size: clamp(1.25rem, 6.6vw, 1.7rem); letter-spacing: .14em; margin-right: -.14em; white-space: nowrap; }
}

/* ---------- pistas (notas al margen) ---------- */
.hints:empty, .msg:empty { display: none; }
.hints { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; }
.hints li { padding: 4px 0 4px 14px; border-left: 2px solid var(--gold); font-style: italic; font-size: .98rem; animation: ink .5s both; }
.hints li b { font: 700 .66rem var(--display); letter-spacing: .16em; text-transform: uppercase; font-style: normal; color: var(--gold); margin-right: 8px; }

/* ---------- entrada ---------- */
#guess-form { display: flex; gap: 10px; margin-top: 18px; }
.combo { position: relative; flex: 1; }
#guess { width: 100%; height: 100%; font: inherit; color: inherit; background: var(--paper-hi); border: 1px solid var(--ink); border-radius: 3px; padding: 10px 14px; }
#guess::placeholder { color: var(--muted); font-style: italic; }
#suggestions { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); margin: 0; padding: 4px; list-style: none; background: var(--paper-hi); border: 1px solid var(--ink); border-radius: 3px; max-height: 280px; overflow-y: auto; z-index: 5; box-shadow: 0 14px 30px -10px rgb(var(--shadow) / .5); }
#suggestions li { padding: 6px 10px; cursor: pointer; border-radius: 2px; }
#suggestions li small { color: var(--muted); font-style: italic; }
#suggestions li.sel, #suggestions li:hover { background: var(--accent); color: var(--on-accent); }
#suggestions li.sel small, #suggestions li:hover small { color: inherit; opacity: .85; }
#suggestions li.used { opacity: .45; text-decoration: line-through; }
.msg { min-height: 1.4em; text-align: center; color: var(--accent); margin: 8px 0 0; font-style: italic; }

/* ---------- resultado ---------- */
.card, .bonus { background: var(--paper-hi); border: 1px solid var(--rule); padding: 18px 20px; margin-top: 14px; position: relative; box-shadow: 0 8px 22px -16px rgb(var(--shadow) / .6); animation: ink .5s both; }
.card { border-color: var(--ink); text-align: center; }
.card::before { content: ""; position: absolute; inset: 4px; border: 1px solid var(--rule); pointer-events: none; }
.card h2 { margin: 0; font: 700 1.25rem/1.25 var(--display); letter-spacing: .06em; text-wrap: balance; }
.card .verdict { margin: 6px 0 12px; color: var(--muted); font-style: italic; }
.card dl { margin: 0 auto; display: grid; grid-template-columns: auto auto; justify-content: center; gap: 4px 14px; text-align: left; font-size: .98rem; max-width: 100%; }
.card dt { font: 500 .62rem/1.9 var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); text-align: right; }
.card dd { margin: 0; }

.bonus h3 { margin: 0 0 12px; font: inherit; font-weight: 700; font-size: 1.05rem; }
.bonus h3 small { display: block; font: 500 .62rem var(--display); letter-spacing: .16em; text-transform: uppercase; color: var(--gold); margin-bottom: 3px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choices button { text-align: center; padding: 9px 8px; background: transparent; }
.choices button:disabled { cursor: default; opacity: .55; transform: none; border-color: var(--rule); }
.choices button.right { background: var(--ok); border-color: var(--ok); color: var(--on-accent); opacity: 1; font-weight: 700; }
.choices button.wrong { background: var(--accent); border-color: var(--accent); color: var(--on-accent); opacity: 1; text-decoration: line-through; }
.actions { display: flex; gap: 10px; justify-content: center; margin: 20px 0 6px; flex-wrap: wrap; }
.actions button { padding: 11px 20px; }

/* hueco del anuncio: altura reservada para que la página no salte al cargar */
.ad-slot { margin: 34px 0 0; min-height: 120px; padding-top: 10px; border-top: 1px solid var(--rule-soft); text-align: center; }
.ad-label { display: block; font: 500 .56rem var(--display); letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.links { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 18px; margin-bottom: 10px; font-style: normal; }
.links a { font: 500 .66rem var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--rule); }
.links a:hover { border-bottom-color: var(--accent); }
footer { margin-top: auto; padding: 30px 0 22px; font-size: .8rem; font-style: italic; color: var(--muted); text-align: center; text-wrap: balance; }
footer .orn { display: block; font-style: normal; font-size: 1.1rem; color: var(--rule); margin-bottom: 6px; }
a { color: var(--accent); }

/* ---------- diálogos ---------- */
dialog { background: var(--paper-hi); color: var(--ink); border: 1px solid var(--ink); outline: 1px solid var(--rule); outline-offset: -6px; border-radius: 0; max-width: min(500px, 92vw); padding: 26px 28px 22px; box-shadow: 0 30px 60px -20px rgb(0 0 0 / .6); }
dialog::backdrop { background: rgb(20 14 8 / .6); backdrop-filter: blur(2px); }
dialog h2 { margin: 0 0 12px; font: 700 1.1rem var(--display); letter-spacing: .16em; text-transform: uppercase; text-align: center; }
dialog p { margin: 0 0 10px; }
dialog ul { padding-left: 1.1em; margin: 0 0 10px; }
dialog li { margin-bottom: 4px; }
dialog li::marker { color: var(--accent); }
dialog form { text-align: center; margin-top: 16px; }
.statgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; margin-bottom: 18px; }
.statgrid b { display: block; font: 700 1.6rem var(--display); }
.statgrid span { font: 500 .56rem var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.bar { display: grid; grid-template-columns: 1.2em 1fr; gap: 8px; align-items: center; margin: 4px 0; font: 500 .8rem var(--display); }
.bar i { display: block; background: var(--accent); color: var(--on-accent); font-style: normal; text-align: right; padding: 1px 7px; min-width: 1.8em; }

/* ---------- páginas de texto (Acerca de, Privacidad) ---------- */
h1 a { color: inherit; text-decoration: none; }
a.icon { width: 38px; height: 38px; border: 1px solid var(--rule); border-radius: 50%; display: grid; place-items: center; color: var(--ink); text-decoration: none; font-family: var(--display); }
a.icon:hover { border-color: var(--ink); }
.prose { padding: 26px 0 10px; max-width: 62ch; margin: 0 auto; }
.prose h2 { font: 700 1.2rem var(--display); letter-spacing: .12em; text-transform: uppercase; text-align: center; margin: 10px 0 18px; }
.prose h2 + .updated { text-align: center; margin-top: -10px; }
.prose h3 { font: 700 .78rem var(--display); letter-spacing: .16em; text-transform: uppercase; color: var(--accent); margin: 26px 0 6px; }
.prose p { margin: 0 0 12px; text-wrap: pretty; }
.prose article h2:not(:first-child) { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--rule); }
.updated { color: var(--muted); font-style: italic; font-size: .9rem; }
mark.todo { background: #ffe066; color: #3b2a00; padding: 0 3px; border-radius: 2px; font-style: normal; }
.state-list { columns: 2 15em; column-gap: 28px; padding-left: 1.1em; margin: 0; font-size: .92rem; }
.state-list li { break-inside: avoid; margin-bottom: 2px; }
.state-list li::marker { color: var(--rule); }
