/* ==========================================================================
   Rin & Tadashi · Japanese N5 Speedrun — sistema de diseño
   Papel washi + tinta sumi + sello hanko + paleta del canal (cel 80s):
   naranja quemado, chocolate, turquesa y rosa chicle. Contorno negro grueso
   y sombra dura desplazada, como los dibujos.
   ========================================================================== */

/* Jost (Google Fonts) coloca mal la macrón de ā ī ū ē ō: esas letras salen de otra fuente.
   unicode-range hace que «RT Macron» solo se use para ellas; el resto sigue en Jost. */
@font-face { font-family: "RT Macron"; font-weight: 100 500; unicode-range: U+0100-017F, U+0300-036F;
  src: local("Avenir Next Medium"), local("AvenirNext-Medium"), local("Futura Medium"), local("Futura-Medium"), local("Segoe UI"), local("Helvetica Neue"), local("Arial"); }
@font-face { font-family: "RT Macron"; font-weight: 501 1000; unicode-range: U+0100-017F, U+0300-036F;
  src: local("Avenir Next Bold"), local("AvenirNext-Bold"), local("Futura Bold"), local("Futura-Bold"), local("Segoe UI Bold"), local("Helvetica Neue Bold"), local("Arial Bold"); }

:root {
  /* papel y tinta */
  --paper: #f3ecdc;
  --paper-2: #ebe1cb;
  --paper-3: #e2d5ba;
  --white: #fffdf7;
  --ink: #161418;
  --ink-2: #3b3638;
  --ink-soft: #625b59; /* 5,65:1 sobre papel (antes #6f6866, 4,20 sobre --paper-3) */
  --seal: #c4201c;
  --seal-dark: #8f1512;

  /* paleta del canal */
  --orange: #e2802f;
  --orange-2: #f2a65a;
  --choc: #6b3a1e;
  --choc-2: #8e5631;
  --teal: #1f9a92;
  --teal-2: #6fd0c6;
  --pink: #f39ab4;
  --pink-2: #ffd0dc;
  --gold: #e0a91c;
  --gold-2: #ffd86a;
  --cream: #fde6c6;
  --indigo: #1d2350;
  --night: #121633;

  /* rangos = líneas del metro del curso */
  --rank-e: #1f6e4a; /* onigiri (alga nori) */
  --rank-d: #ee6a45; /* sushi (salmón) */
  --rank-c: #5f8f2f; /* matcha */
  --rank-b: #d99a12; /* ramen (caldo dorado) */
  --rank-a: #e0608f; /* sakura */
  --rank-s: #2f5fb0; /* Fuji */

  /* rarezas */
  --r-common: #8b8277;
  --r-rare: #c4201c;
  --r-epic: #d4a017;
  --r-legend: #7b4fe0;

  /* tipografía */
  --f-display: "RT Macron", "Jost", "Zen Kaku Gothic New", "Futura", "Avenir Next", system-ui, sans-serif;
  --f-body: "RT Macron", "Jost", "Zen Kaku Gothic New", "Futura", "Avenir Next", system-ui, sans-serif;
  --f-jp: "Zen Kaku Gothic New", "Hiragino Sans", "Noto Sans JP", sans-serif;
  --f-brush: "Yuji Syuku", "Zen Kaku Gothic New", serif;
  --f-round: "Zen Maru Gothic", "Zen Kaku Gothic New", sans-serif;

  /* geometría */
  --line: 3px;
  --line-thick: 4px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow: 4px 4px 0 var(--ink);
  --shadow-lg: 7px 7px 0 var(--ink);
  --shadow-sm: 2px 2px 0 var(--ink);
  --gutter: clamp(16px, 4vw, 40px);
  --maxw: 1180px;
  --nav-h: 68px;
  --tab-h: 70px;

  /* texturas */
  --halftone: radial-gradient(circle at 1px 1px, rgba(22, 20, 24, 0.16) 1.1px, transparent 1.4px);
  --halftone-orange: radial-gradient(circle at 1px 1px, rgba(107, 58, 30, 0.35) 1.2px, transparent 1.5px);
  --paper-noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .42  0 0 0 0 .33  0 0 0 0 .2  0 0 0 .09 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  --fibers: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='400' height='400'><g fill='none' stroke='%238e5631' stroke-opacity='.10' stroke-width='.8'><path d='M20 40c40 10 70-6 110 4'/><path d='M200 90c30-12 60 8 95-2'/><path d='M60 210c25 8 50-4 80 6'/><path d='M260 260c35 6 60-10 100 0'/><path d='M120 330c30-8 55 10 85 0'/><path d='M310 150c20 10 45-2 70 6'/><path d='M30 300c18-6 30 4 50 0'/></g></svg>");

  color-scheme: light;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--f-body);
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--paper);
  background-image: var(--paper-noise), var(--fibers);
  overflow-x: hidden;
  padding-bottom: 0;
}
img, svg, canvas, video { max-width: 100%; display: block; }
img { height: auto; } /* con width y height en el HTML (que reservan el hueco) la imagen conserva su proporción al encogerse */
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #1a837c; outline-offset: 3px; border-radius: 6px; } /* 3,89:1 sobre papel (el turquesa daba 2,93) */
::selection { background: var(--orange-2); color: var(--ink); }
.jp { font-family: var(--f-jp); font-feature-settings: "palt"; }
.brush { font-family: var(--f-brush); }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* «saltar al contenido»: invisible hasta que llega el foco con el teclado */
.skip-link {
  position: fixed; left: 12px; top: 10px; z-index: 200; transform: translateY(-180%);
  padding: 11px 18px; background: var(--ink); color: var(--paper); border-radius: 999px; box-shadow: var(--shadow-sm);
  font: 800 14px/1 var(--f-display); letter-spacing: .08em; text-transform: uppercase; text-decoration: none; transition: transform .2s;
}
.skip-link:focus { transform: none; }
/* al saltar al contenido, el principio de <main> no queda escondido bajo la cabecera fija */
#main { scroll-margin-top: calc(var(--nav-h) + 8px); }
/* hueco de la cabecera mientras app.js no la inserta: sin él, todo bajaba 68 px tras el primer pintado (CLS).
   Sin soporte de :has() la regla entera se ignora y queda como antes */
body:not([data-bare]):not(:has(> .site-header))::before { content: ""; display: block; height: var(--nav-h); }
/* el pie empieza fuera de la pantalla mientras el JS pinta la página (en /level/ y /course/ subía arriba y bajaba) */
#main { min-height: 100vh; }
/* en fondos de tinta el anillo de foco va en oro (el turquesa casi no se veía) */
.site-footer :focus-visible, .tabbar :focus-visible, .panel--ink :focus-visible { outline-color: var(--gold-2); }

h1, h2, h3, h4 { font-family: var(--f-display); line-height: 1.12; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { line-height: 1.04; } /* titular enorme en mayúsculas: sin descendentes, más apretado se lee mejor */
h1 { font-size: clamp(38px, 6.2vw, 76px); font-weight: 800; text-transform: uppercase; }
h2 { font-size: clamp(28px, 4vw, 44px); font-weight: 800; text-transform: uppercase; }
h3 { font-size: clamp(20px, 2.4vw, 26px); font-weight: 700; }
p { margin: 0 0 1em; }
.lead { font-size: clamp(18px, 2vw, 21px); color: var(--ink-2); max-width: 46ch; }
.eyebrow { font: 700 13px/1 var(--f-display); letter-spacing: .16em; text-transform: uppercase; color: var(--seal); display: inline-flex; gap: .5em; align-items: center; }
.eyebrow::before { content: ""; width: 22px; height: 3px; background: currentColor; border-radius: 3px; }
.muted { color: var(--ink-soft); }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
.section { padding: clamp(48px, 8vw, 104px) 0; position: relative; }
.stack > * + * { margin-top: var(--gap, 16px); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: clamp(14px, 2vw, 24px); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }

/* ---------- botones ---------- */
.btn {
  --bg: var(--white); --fg: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: .55em;
  min-height: 50px; padding: 12px 22px;
  font: 800 16px/1 var(--f-display); letter-spacing: .06em; text-transform: uppercase; text-decoration: none;
  color: var(--fg); background: var(--bg);
  border: var(--line) solid var(--ink); border-radius: 999px;
  box-shadow: var(--shadow);
  cursor: pointer; user-select: none;
  transition: transform .12s ease, box-shadow .12s ease, background-color .2s;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }
.btn--seal { --bg: var(--seal); --fg: var(--white); }
.btn--ink { --bg: var(--ink); --fg: var(--paper); }
.btn--teal { --bg: #1a837c; --fg: var(--white); } /* 4,51:1 con el blanco (var(--teal) daba 3,38) */
.btn--orange { --bg: var(--orange); --fg: var(--ink); }
.btn--gold { --bg: var(--gold-2); --fg: var(--ink); }
.btn--pink { --bg: var(--pink); --fg: var(--ink); }
.btn--big { min-height: 64px; padding: 16px 30px; font-size: 19px; }
.btn--sm { min-height: 38px; padding: 8px 14px; font-size: 13px; box-shadow: var(--shadow-sm); }
.btn--ghost { background: transparent; box-shadow: none; border-color: transparent; text-decoration: underline; text-underline-offset: 4px; }
.btn--ghost:hover { box-shadow: none; transform: none; color: var(--seal); }
.btn-icon { width: 44px; height: 44px; padding: 0; min-height: 0; border-radius: 50%; box-shadow: var(--shadow-sm); }
svg.i { display: inline-block; width: 1.15em; height: 1.15em; vertical-align: -.2em; } /* iconos de ui.js (ICONS) sueltos en el texto */
.btn .i { width: 1.45em; height: 1.45em; flex: none; margin: -.2em 0; } /* iconos de ui.js (ICONS) dentro de botones */

/* ---------- paneles ---------- */
.panel {
  background: var(--white);
  border: var(--line) solid var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: clamp(18px, 3vw, 30px);
  position: relative;
}
.panel--paper { background: var(--paper-2); background-image: var(--paper-noise); }
.panel--ink { background: var(--ink); color: var(--paper); }
.panel--dots { background-image: var(--halftone); background-size: 7px 7px; background-color: var(--white); }
.panel--tilt { transform: rotate(-1deg); }
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border: 2px solid var(--ink); border-radius: 999px;
  font: 700 12px/1.2 var(--f-display); letter-spacing: .08em; text-transform: uppercase;
  background: var(--paper);
}
.tag--seal { background: var(--seal); color: var(--white); }
.tag--teal { background: var(--teal); color: var(--white); }
.tag--gold { background: var(--gold-2); }
.tag--ink { background: var(--ink); color: var(--paper); }

/* sello hanko con la letra del rango */
.hanko {
  --c: var(--seal);
  width: var(--s, 64px); height: var(--s, 64px);
  display: inline-grid; place-items: center;
  background: var(--c); color: var(--paper);
  border-radius: 10px;
  box-shadow: inset 0 0 0 3px var(--c), inset 0 0 0 6px var(--paper);
  font: 800 calc(var(--s, 64px) * .52)/1 var(--f-display);
  position: relative; transform: rotate(-4deg);
  filter: url(#rough);
}
.hanko small { position: absolute; bottom: 9%; font-size: max(11px, calc(var(--s, 64px) * .15)); letter-spacing: .06em; } /* nunca por debajo de 11 px, aunque el sello sea pequeño */
/* pequeños (hasta 69 px, o .hanko--sm a mano): desgaste suave, que si no 済 y 新 no se leen */
.hanko--sm, .hanko[style*="--s:4"], .hanko[style*="--s:5"], .hanko[style*="--s:6"], .hanko[style*="--s: 4"], .hanko[style*="--s: 5"], .hanko[style*="--s: 6"] { filter: url(#rough-sm); }
.hanko--round { border-radius: 50%; }

/* pincelada de tinta detrás de títulos */
/* la pincelada baja más que el texto: el gancho de la J y los pies de las letras no se salen del negro */
.inkstroke { position: relative; display: inline-block; color: var(--paper); padding: .1em .4em .16em; z-index: 0; }
.inkstroke::before {
  content: ""; position: absolute; inset: -8% -5% -16%; z-index: -1;
  background: var(--ink);
  -webkit-mask: url("../img/ui/brush-stroke.svg") center / 100% 100% no-repeat;
          mask: url("../img/ui/brush-stroke.svg") center / 100% 100% no-repeat;
}

/* pegatina: dibujo con borde blanco y sombra de tinta */
.sticker {
  filter:
    drop-shadow(3px 0 0 #fff) drop-shadow(-3px 0 0 #fff) drop-shadow(0 3px 0 #fff) drop-shadow(0 -3px 0 #fff)
    drop-shadow(4px 5px 0 rgba(22, 20, 24, .85));
}
.art-multiply { mix-blend-mode: multiply; }

/* ---------- cabecera ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  background: rgba(243, 236, 220, .88); /* Safari < 16.2 no entiende color-mix: sin esto, la cabecera sin fondo */
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px) saturate(1.2);
  -webkit-backdrop-filter: blur(8px) saturate(1.2);
  border-bottom: var(--line) solid var(--ink);
}
.site-header::after { /* franja del color de tu línea, como la banda de color de los trenes */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: var(--my-line, var(--rank-e)); border-top: 2px solid var(--white); transition: background-color .6s;
}
.site-header .wrap { height: 100%; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; margin-right: auto; min-width: 0; }
.brand-mark { width: 44px; height: 44px; border: var(--line) solid var(--ink); border-radius: 50%; background: var(--orange); overflow: hidden; box-shadow: var(--shadow-sm); flex: none; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-text { display: flex; flex-direction: column; line-height: 1; min-width: 0; }
.brand-text b { font: 800 19px/1 var(--f-display); letter-spacing: .02em; }
.brand-text span { font: 700 11.5px/1.3 var(--f-display); letter-spacing: .16em; color: var(--seal); text-transform: uppercase; }
.nav { display: flex; gap: 4px; }
.nav a {
  position: relative; text-decoration: none;
  font: 800 14px/1 var(--f-display); letter-spacing: .1em; text-transform: uppercase;
  padding: 11px 14px; border-radius: 999px; border: 2px solid transparent;
}
.nav a:hover { border-color: var(--ink); background: var(--white); }
.nav a[aria-current="page"] { background: var(--ink); color: var(--paper); }
.hud { display: flex; align-items: center; gap: 8px; }
.hud-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px 0 8px;
  border: 2px solid var(--ink); border-radius: 999px; background: var(--white);
  font: 800 14px/1 var(--f-display); text-decoration: none; box-shadow: var(--shadow-sm);
}
.hud-pill .ico { font-size: 18px; }
.hud-pill .i { width: 21px; height: 21px; flex: none; }
.hud-pill, .avatar-pill { transition: transform .12s ease, box-shadow .12s ease; }
.hud-pill:hover, .avatar-pill:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.hud-pill--gacha.has-prize .i { animation: capWiggle 2.6s ease-in-out infinite; transform-origin: 50% 80%; }
@keyframes capWiggle { 0%, 70%, 100% { transform: rotate(0); } 76% { transform: rotate(-14deg); } 84% { transform: rotate(11deg); } 92% { transform: rotate(-5deg); } }
.hud-pill--gacha { background: var(--gold-2); position: relative; }
.hud-pill--gacha.has-prize::after {
  content: ""; position: absolute; top: -4px; right: -4px; width: 13px; height: 13px; border-radius: 50%;
  background: var(--seal); border: 2px solid var(--ink); animation: pulse 1.2s ease-in-out infinite;
}
.avatar-pill { width: 44px; height: 44px; border-radius: 50%; border: var(--line) solid var(--ink); overflow: hidden; background: var(--white); box-shadow: var(--shadow-sm); display: grid; place-items: center; text-decoration: none; font-weight: 800; color: var(--ink); }
.avatar-pill img { width: 100%; height: 100%; object-fit: cover; }
.avatar-pill.has-pic { background: var(--teal-2); box-shadow: inset 0 0 0 3px var(--my-line, var(--rank-e)), var(--shadow-sm); }
.avatar-pill.has-pic img { padding: 3px; border-radius: 50%; }
/* numeración de estación (como el metro de Tokio): anillo del color de la línea, letra y número */
.st-badge {
  width: 100%; height: 100%; border-radius: 50%; display: grid; place-content: center; text-align: center; gap: 1px;
  background: var(--white); box-shadow: inset 0 0 0 4.5px var(--my-line, var(--rank-e)); line-height: 1;
}
.st-badge small { font: 800 11px/1 var(--f-display); letter-spacing: .04em; }
.st-badge b { font: 800 14px/.95 var(--f-display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.st-badge.is-dragon { background: #e9b949; box-shadow: inset 0 0 0 3px var(--white); }
.st-badge.is-dragon b { font: 900 20px/1 var(--f-jp); }

/* barra inferior en móvil */
.tabbar { display: none; }
@media (max-width: 820px) {
  .nav { display: none; }
  .hud .hud-pill--streak { display: none; }
  body { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 60;
    height: 62px; background: var(--ink); border-radius: 22px; box-shadow: 0 6px 0 rgba(0,0,0,.25);
    padding: 6px;
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--paper); text-decoration: none; border-radius: 16px;
    font: 700 11.5px/1 var(--f-display); letter-spacing: .05em; text-transform: uppercase;
  }
  .tabbar a .ico { font-size: 21px; line-height: 1; }
  .tabbar a { transition: transform .12s ease, background-color .2s; }
  .tabbar a:active { transform: scale(.92); }
  .tabbar a[aria-current="page"] { background: var(--paper); color: var(--ink); }
  /* Gacha: botón redondo de cápsula que asoma por encima de la barra */
  .tabbar a.tab-gacha { position: relative; color: var(--gold-2); justify-content: flex-end; padding-bottom: 7px; }
  .tabbar a.tab-gacha .ico {
    width: 50px; height: 50px; margin-top: -26px; display: grid; place-items: center; border-radius: 50%;
    background: var(--gold-2); border: 3px solid var(--ink); box-shadow: 0 4px 0 rgba(0, 0, 0, .28);
  }
  .tabbar a.tab-gacha .ico .i { width: 30px; height: 30px; }
  .tabbar a.tab-gacha[aria-current="page"] { background: transparent; color: var(--paper); }
  .tabbar a.tab-gacha[aria-current="page"] .ico { box-shadow: 0 0 0 3px var(--paper), 0 4px 0 rgba(0, 0, 0, .28); }
  .tab-badge {
    position: absolute; top: -30px; left: calc(50% + 12px); min-width: 22px; height: 22px; padding: 0 6px;
    border-radius: 999px; background: var(--seal); color: var(--white); border: 2px solid var(--ink);
    font: 800 12px/18px var(--f-display); letter-spacing: 0; text-align: center; animation: popin .35s ease both;
  }
  .brand-text b { font-size: 17px; }
  .brand-text span { font-size: 11px; line-height: 1.25; letter-spacing: .1em; }
}
/* móviles estrechos (320 px): la marca cede antes que el HUD; el nombre sigue en una línea y el lema se parte en dos */
@media (max-width: 360px) {
  .site-header .wrap { gap: 10px; }
  .brand { gap: 8px; }
  .brand-text b { font-size: 16px; white-space: nowrap; }
  .brand-text span { font-size: 11px; letter-spacing: .06em; white-space: normal; }
}

/* ---------- pie ---------- */
.site-footer { margin-top: 80px; border-top: var(--line) solid var(--ink); background: var(--ink); color: var(--paper); padding: 48px 0 120px; position: relative; overflow: hidden; }
.site-footer a { color: var(--paper); text-decoration: none; opacity: .85; }
.site-footer a:hover { opacity: 1; color: var(--gold-2); }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 28px; }
.footer-grid .foot-h { font-size: 13px; letter-spacing: .16em; color: var(--gold-2); text-transform: uppercase; } /* h2 (antes h4: saltaba niveles de encabezado) */
.footer-grid ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.footer-kanji { position: absolute; right: -20px; bottom: -60px; font: 400 260px/1 var(--f-brush); color: rgba(243, 236, 220, .05); pointer-events: none; }
@media (max-width: 820px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-about { grid-column: 1 / -1; } }
/* franja de las seis líneas en el pie (路線図), con tu tren marcado */
.foot-route { margin-bottom: 40px; }
.fr-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px 16px; flex-wrap: wrap; margin-bottom: 12px; font: 700 12px/1.3 var(--f-display); letter-spacing: .14em; text-transform: uppercase; color: var(--gold-2); }
.fr-head .jp { font: 700 15px/1 var(--f-jp); letter-spacing: .08em; color: var(--paper); margin-right: 8px; }
.site-footer .fr-head a { opacity: 1; letter-spacing: .1em; }
.fr-head a b { color: var(--gold-2); }
.fr-line { position: relative; height: 44px; margin-right: 10px; }
.fr-segs { position: absolute; left: 0; right: 0; top: 8px; height: 12px; display: flex; border-radius: 999px; box-shadow: 0 0 0 2px var(--paper); }
.fr-segs i { position: relative; display: block; height: 100%; }
.fr-segs i:first-child { border-radius: 999px 0 0 999px; }
.fr-segs i:last-child { border-radius: 0 999px 999px 0; }
.fr-segs i span { position: absolute; top: 20px; left: 0; padding: 3px 6px; border-radius: 5px; background: inherit; color: inherit; border: 1.5px solid var(--paper); font: 800 11.5px/1 var(--f-display); letter-spacing: .04em; padding: 4px 7px; }
.fr-line > b { position: absolute; top: 14px; width: 5px; height: 5px; margin: -2.5px 0 0 -2.5px; border-radius: 50%; background: rgba(22, 20, 24, .55); }
.fr-line > b.on-dark { background: rgba(243, 236, 220, .5); }
.fr-line > b.is-done { background: var(--paper); }
.fr-line > b.is-gate { width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px; background: var(--paper); border: 2.5px solid var(--ink); }
.fr-line > b.is-gate.is-done { background: var(--seal); border-color: var(--paper); }
.fr-line > b.is-end { width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 5px; background: var(--paper); border: 2.5px solid var(--ink); display: grid; place-items: center; color: var(--ink); }
.fr-line > b.is-end.is-done { background: #e9b949; }
.fr-line > b.is-end .jp { font: 900 13px/1 var(--f-jp); }
.fr-line > b.is-here { width: 13px; height: 13px; margin: -6.5px 0 0 -6.5px; background: none; border: 0; }
/* la onda que sale de tu estación solo crece y se apaga (transform + opacity): la hace la GPU. Antes se animaba
   el box-shadow y eso repintaba el pie en cada fotograma, en todas las páginas, aunque no se viera.
   ::before = la onda (debajo) · ::after = el punto dorado (encima) */
.fr-line > b.is-here::before, .fr-line > b.is-here::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.fr-line > b.is-here::before { left: -12px; top: -12px; width: 37px; height: 37px; background: rgba(255, 216, 106, .7); transform: scale(.35); opacity: 0; animation: frHere 1.8s ease-out infinite; }
.fr-line > b.is-here::after { inset: 0; background: var(--gold-2); border: 2.5px solid var(--ink); }
@keyframes frHere { 0% { transform: scale(.35); opacity: 1; } 100% { transform: scale(1); opacity: 0; } }

/* halo que late bajo el tren del plano en miniatura (minimap.js) */
.mm-glow { transform-box: fill-box; transform-origin: center; transform: scale(.65); animation: mmGlow 2s ease-in-out infinite; }
@keyframes mmGlow { 50% { transform: scale(1); } }

/* ---------- utilidades de movimiento ---------- */
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.25); } }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes wobble { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
@keyframes popin { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
@keyframes slam { 0% { transform: scale(2.6) rotate(-14deg); opacity: 0; } 60% { transform: scale(.92) rotate(-6deg); opacity: 1; } 100% { transform: scale(1) rotate(-6deg); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
.floaty { animation: floaty 4s ease-in-out infinite; }
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .7s ease, transform .7s cubic-bezier(.2, .8, .2, 1); }
.reveal.is-in { opacity: 1; transform: none; }
/* Movimiento reducido: todas las animaciones saltan a su último fotograma.
   Ojo con los avisos que entran, se quedan y salen en una sola animación (acaban en opacity:0): así se
   quedarían invisibles desde el principio. Para esos, la clase .rm-static quita la animación y deja el
   estilo base (visible); el que lo oculte después lo hace con hidden o quitándolo, como siempre. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
  .rm-static, .rm-static::before, .rm-static::after { animation: none !important; }
}

/* ---------- toasts (sellos, premios) ---------- */
/* panel LED «próxima estación» */
.announce { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 95; width: min(560px, calc(100% - 24px)); display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: #141214; color: #ffb43a; border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 0 0 3px #3b3638, 6px 8px 0 rgba(22,20,24,.35); transform: translateX(-50%); animation: anIn .45s cubic-bezier(.3,1.4,.5,1); font-family: 'DotGothic16', ui-monospace, monospace; }
.announce.is-out { animation: anOut .4s ease-in forwards; }
@keyframes anIn { from { transform: translate(-50%, 140%); } }
@keyframes anOut { to { transform: translate(-50%, 140%); opacity: 0; } }
.an-k { flex: none; font-size: 18px; line-height: 1; text-align: center; color: #ffb43a; }
.an-k small { display: block; font-size: 11px; letter-spacing: .12em; color: #8fe08a; margin-top: 4px; }
.an-code { flex: none; padding: 5px 8px; border-radius: 7px; font: 700 15px/1 var(--f-display); letter-spacing: .04em; }
.an-led { flex: 1; overflow: hidden; white-space: nowrap; font-size: 17px; background-image: radial-gradient(rgba(255,180,58,.08) 1px, transparent 1.2px); background-size: 4px 4px; }
.an-run { display: inline-block; padding-left: 35%; animation: anRun 9s linear infinite; text-shadow: 0 0 6px rgba(255,180,58,.6); } /* empieza ya asomando: antes salía medio panel vacío */
@keyframes anRun { to { transform: translateX(-100%); } }
/* transbordo: letrero amarillo «のりかえ» como los del metro */
.announce.is-transfer { box-shadow: 0 0 0 3px #ffd200, 6px 8px 0 rgba(22,20,24,.35); }
.an-xfer { flex: none; display: grid; place-items: center; padding: 6px 9px 5px; border-radius: 7px; background: #ffd200; color: var(--ink); line-height: 1; animation: xferBlink 1s steps(2, jump-none) 3; }
.an-xfer b { font: 900 13px/1 var(--f-jp); letter-spacing: .02em; }
.an-xfer small { font: 800 11px/1 var(--f-display); letter-spacing: .06em; margin-top: 4px; }
@keyframes xferBlink { 50% { background: #fff3a8; } }
@media (max-width: 820px) { .announce { bottom: calc(92px + env(safe-area-inset-bottom)); } }
@media (max-width: 420px) { .an-led { font-size: 15px; } .an-k { font-size: 16px; } }
@media (prefers-reduced-motion: reduce) { .an-run { animation: none; padding-left: 0; } }

/* avisos (sellos, premios): en cola; se cierran al tocarlos */
.toasts { position: fixed; top: calc(var(--nav-h) + 12px); right: 14px; z-index: 90; display: grid; gap: 10px; justify-items: end; pointer-events: none; }
/* en escritorio, abajo a la izquierda: arriba a la derecha tapaban botones de la página (ajustes del repaso, sello del récord); abajo a la derecha está Mikan */
@media (min-width: 821px) {
  .toasts { top: auto; bottom: 18px; left: 18px; right: auto; justify-items: start; }
  .toast { animation-name: toastInUp; }
}
@keyframes toastInUp { from { transform: translateY(24px) scale(.94); opacity: 0; } }
.toasts:not([data-more=""])[data-more]::after {
  content: attr(data-more); font: 800 11px/1 var(--f-display); letter-spacing: .12em; text-transform: uppercase;
  padding: 6px 10px; border-radius: 999px; background: var(--ink); color: var(--paper); box-shadow: var(--shadow-sm); animation: popin .3s ease both;
}
.toast {
  pointer-events: auto; cursor: pointer; display: flex; gap: 12px; align-items: center; width: 340px; max-width: calc(100vw - 28px);
  background: var(--white); border: var(--line) solid var(--ink); border-radius: 16px; box-shadow: var(--shadow);
  padding: 12px 16px 12px 12px; animation: toastIn .4s cubic-bezier(.3,1.35,.5,1) both;
}
@keyframes toastIn { from { transform: translateX(40px) scale(.9); opacity: 0; } }
.toast .toast-ico { width: 52px; height: 52px; flex: none; display: grid; place-items: center; }
.toast .toast-glyph { font: 800 30px/1 var(--f-display); }
.toast .toast-glyph.jp { font-family: var(--f-jp); font-weight: 900; }
.toast .toast-glyph .i { width: 40px; height: 40px; }
.toast-txt { min-width: 0; }
.toast b { display: block; font: 800 15px/1.2 var(--f-display); }
.toast small { display: block; color: var(--ink-soft); font-size: 13.5px; line-height: 1.4; margin-top: 5px; }
.toast--stamps small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.toast-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 7px; }
.toast-foot:empty { display: none; }
.toast-prize { font: 800 11px/1.2 var(--f-display); letter-spacing: .06em; text-transform: uppercase; padding: 4px 9px; /* si se parte en dos líneas, que no se toquen */ border-radius: 999px; background: var(--gold-2); border: 2px solid var(--ink); }
.toast-link { font: 800 11px/1 var(--f-display); letter-spacing: .1em; text-transform: uppercase; color: var(--seal); text-decoration: none; }
.toast-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.toast .toast-fan { position: relative; width: calc(50px + (var(--n) - 1) * 25px); height: 58px; }
.toast-fan > span { position: absolute; left: calc(var(--i) * 25px); top: 4px; }
.toast-fan .stamp { animation-delay: calc(var(--i) * .17s); }
.toast.is-out { transition: opacity .3s, transform .3s; opacity: 0; transform: translateX(30px); }
@media (max-width: 820px) {
  .toasts { top: calc(var(--nav-h) + 8px); left: 10px; right: 10px; justify-items: stretch; }
  .toasts:not([data-more=""])[data-more]::after { justify-self: end; margin-top: -4px; }
  .toast { width: auto; max-width: none; gap: 10px; padding: 8px 12px 8px 8px; animation-name: toastDrop; }
  .toast .toast-ico { width: 44px; height: 44px; }
  .toast .stamp { --s: 44px !important; }
  .toast .toast-fan { width: calc(44px + (var(--n) - 1) * 19px); height: 48px; }
  .toast-fan > span { left: calc(var(--i) * 19px); top: 2px; }
  .toast b { font-size: 14px; }
  .toast small { font-size: 12.5px; }
  .toast.is-out { transform: translateY(-14px); }
}
@keyframes toastDrop { from { transform: translateY(-22px); opacity: 0; } }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(22, 20, 24, .55); backdrop-filter: blur(3px); animation: popin .2s ease both; }
.modal[hidden] { display: none; }
.modal-box { width: min(560px, 100%); max-height: 90vh; overflow: auto; }
.modal-box:focus { outline: none; }

/* ---------- barras de progreso ---------- */
.bar { height: 16px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper-2); overflow: hidden; position: relative; }
.bar > i { position: absolute; inset: 0 auto 0 0; width: var(--v, 0%); background: var(--c, var(--teal)); background-image: linear-gradient(90deg, transparent 0 60%, rgba(255,255,255,.35) 60% 70%, transparent 70%); border-right: 2px solid var(--ink); transition: width 1s cubic-bezier(.2, .8, .2, 1); }
.bar-row { display: grid; grid-template-columns: 112px 1fr 48px; gap: 10px; align-items: center; font: 800 13px/1 var(--f-display); letter-spacing: .1em; }
.bar-row .bar-val { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- formularios ---------- */
.input {
  width: 100%; min-height: 52px; padding: 12px 16px;
  font: 600 18px/1.2 var(--f-body); color: var(--ink);
  background: var(--white); border: var(--line) solid var(--ink); border-radius: 14px; box-shadow: inset 3px 3px 0 rgba(22,20,24,.08);
}
.input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 4px rgba(31, 154, 146, .25); }

/* ---------- burbuja de diálogo (Rin, Tadashi, guardianes) ---------- */
.speech {
  position: relative; background: var(--white); border: var(--line) solid var(--ink); border-radius: 20px;
  padding: 14px 18px; box-shadow: var(--shadow); font-weight: 600;
}
.speech::after {
  content: ""; position: absolute; left: var(--tail-x, 36px); bottom: -15px; width: 22px; height: 22px;
  background: var(--white); border-right: var(--line) solid var(--ink); border-bottom: var(--line) solid var(--ink);
  transform: rotate(45deg) skew(10deg, 10deg);
}
.speech b.who { display: block; font: 800 12px/1 var(--f-display); letter-spacing: .14em; text-transform: uppercase; color: var(--seal); margin-bottom: 6px; }

/* ---------- confeti ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 120; }

/* avisos en escritorio (abajo a la izquierda): salen hacia abajo */
@media (min-width: 821px) { .toast.is-out { transform: translateY(14px); } }

/* ── redes de Rin & Tadashi: a un toque desde cualquier página ── */
.soc--yt { color: #e8312a; } .soc--tt { color: #161418; } .soc--ig { color: #c13584; } .soc--anki { color: #2f6fb0; }
.socials { display: flex; align-items: center; gap: 6px; }
.soc {
  width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 50%;
  border: 2px solid var(--ink); background: var(--white); box-shadow: var(--shadow-sm); text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease;
}
.soc .i { width: 19px; height: 19px; }
a.soc:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.soc-menu { display: none; position: relative; }
.soc-menu > summary { list-style: none; cursor: pointer; color: var(--ink); padding: 0 13px 0 10px; }
.soc-menu > summary::-webkit-details-marker { display: none; }
.soc-menu > summary span { color: var(--ink); }
.soc-menu[open] > summary { background: var(--ink); color: var(--paper); }
.soc-menu[open] > summary span { color: var(--paper); }
.soc-pop {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 70; width: min(270px, calc(100vw - 32px));
  display: grid; gap: 6px; padding: 10px; background: var(--white); border: 2px solid var(--ink);
  border-radius: 18px; box-shadow: 4px 4px 0 var(--ink); animation: popin .18s ease both;
}
.soc-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 12px; text-decoration: none; }
.soc-row:hover, .soc-row:focus-visible { background: var(--paper); }
.soc-row b { display: block; font: 800 15px/1.2 var(--f-display); color: var(--ink); }
.soc-row small { display: block; font: 600 13px/1.3 var(--f-body); color: var(--ink-2, #514a4f); }
.foot-soc a { display: inline-flex; align-items: center; gap: 8px; }
.foot-soc .i { width: 18px; height: 18px; flex: none; }
.site-footer .foot-soc a.soc--tt { color: var(--paper); }
@media (max-width: 1100px) { .socials { gap: 4px; } .soc { width: 32px; height: 32px; } .soc .i { width: 17px; height: 17px; } }
@media (max-width: 960px) { .socials { display: none; } .soc-menu { display: block; } }
/* móvil: la cápsula de Gacha ya está grande en la barra inferior → fuera de la cabecera, y el sitio es para «Follow» */
@media (max-width: 820px) {
  .hud .hud-pill--gacha { display: none; }
  .site-header .wrap { gap: 10px; }
  .brand-text b { white-space: nowrap; }
  .soc-menu > summary { padding: 0 10px 0 8px; gap: 4px; }
  .soc-menu { position: static; }
  .soc-pop { position: absolute; top: calc(100% + 8px); right: 12px; } /* la cabecera (sticky, con desenfoque) es su referencia */
}
@media (max-width: 340px) { .soc-menu > summary span { display: none; } .soc-menu > summary { padding: 0 9px; } }
.site-footer .foot-soc .soc--yt .i { color: #ff5a4f; } .site-footer .foot-soc .soc--ig .i { color: #ff7ab8; } .site-footer .foot-soc .soc--anki .i { color: #7fb6ff; }
