/* REAL GRIND — interface design system */
:root {
  --gold: #f2c46b; --gold2: #ffe3a3; --gold-d: #9a7430;
  --cyan: #5ad8ff; --violet: #a86bff; --void: #7a3aff; --ember: #ff7a3a; --earth: #45e08a; --water: #3aa8ff; --wind: #d8f0ff;
  --danger: #ff4a5a; --ok: #47f0a0; --warn: #ffb347;
  --ink: #efe9ff; --ink2: #b9b0d6; --ink3: #7c7398;
  --glass: rgba(14, 10, 28, 0.78); --glass2: rgba(22, 16, 42, 0.86); --line: rgba(242, 196, 107, 0.28); --line2: rgba(168, 107, 255, 0.35);
  --f-ui: 'Rajdhani', 'Segoe UI', sans-serif; --f-title: 'Cinzel', Georgia, serif; --f-body: 'Exo 2', 'Segoe UI', sans-serif;
  --ui-scale: 1; --text-scale: 1;
  --r: 10px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
  --r-common: #9aa4b8; --r-uncommon: #47e08a; --r-rare: #4ab8ff; --r-epic: #b46bff; --r-legendary: #ffb03a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #05030b; color: var(--ink); font-family: var(--f-body); font-size: calc(16px * var(--ui-scale) * var(--text-scale)); user-select: none; -webkit-user-select: none; }
#game { position: fixed; inset: 0; }
#game canvas { display: block; width: 100%; height: 100%; outline: none; }
#ui, #overlay { position: fixed; inset: 0; pointer-events: none; }
#ui > *, #overlay > * { pointer-events: auto; }
#ui .passthrough, #overlay .passthrough { pointer-events: none; }
#dmg-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity 0.35s ease; z-index: 90; }
#fade.on { opacity: 1; pointer-events: auto; }
/* loading screen over the fade (RG-004): appears after 250 ms so quick transitions never flash text */
.loading-screen { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 55%, rgba(26, 15, 54, 0.92) 0%, #000 72%); opacity: 0; pointer-events: none; transition: opacity 0.25s ease; }
.loading-screen.on { opacity: 1; pointer-events: auto; transition: opacity 0.35s ease 0.25s; }
.ld-inner { display: flex; flex-direction: column; align-items: center; gap: 0.7rem; min-width: min(30rem, 80vw); }
.ld-emblem { position: relative; width: 4.2rem; height: 4.2rem; margin-bottom: 0.4rem; }
.ld-emblem i, .ld-emblem b { position: absolute; inset: 0; border-radius: 50%; border: 2px solid transparent; }
.ld-emblem i { border-top-color: var(--gold); border-right-color: rgba(242, 196, 107, 0.35); animation: ldSpin 1.1s linear infinite; }
.ld-emblem b { inset: 0.9rem; border-bottom-color: var(--violet); border-left-color: rgba(180, 107, 255, 0.35); animation: ldSpin 1.6s linear infinite reverse; }
@keyframes ldSpin { to { transform: rotate(360deg); } }
.ld-title { font-family: var(--f-title); font-weight: 800; font-size: 1.9rem; letter-spacing: 0.22em; color: var(--gold2); text-shadow: 0 0 24px rgba(242, 196, 107, 0.35); text-align: center; }
.ld-sub { font-family: var(--f-ui); font-size: max(10px, 0.95rem); letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink2); text-align: center; }
.ld-bar { width: 100%; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.1); overflow: hidden; margin-top: 0.6rem; }
.ld-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--violet), var(--gold)); transition: width 0.2s ease; box-shadow: 0 0 10px var(--gold); }
.ld-phase { font-family: var(--f-ui); font-size: max(10px, 0.78rem); letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink3); }
/* reduced motion: loading spinners turn slowly (the blanket rule below made them jump every frame) */
body.reduced-motion .ld-emblem i, body.reduced-motion .ld-emblem b, body.reduced-motion .gfx-spin { animation-duration: 4s !important; animation-iteration-count: infinite !important; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* boot */
#boot { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 60%, #1a0f36 0%, #05030b 70%); transition: opacity 0.8s ease; }
#boot.gone { opacity: 0; pointer-events: none; }
.boot-inner { text-align: center; width: min(520px, 80vw); }
.boot-logo { font-family: var(--f-title); font-weight: 800; font-size: 4.2rem; letter-spacing: 0.18em; color: var(--ink); text-shadow: 0 0 30px rgba(168, 107, 255, 0.6); }
.boot-logo span { color: var(--gold); text-shadow: 0 0 30px rgba(242, 196, 107, 0.6); }
.boot-sub { font-family: var(--f-ui); letter-spacing: 0.5em; color: var(--ink2); margin-top: 0.3rem; font-size: max(10px, 0.95rem); }
.boot-bar { height: 3px; background: rgba(255, 255, 255, 0.08); margin: 2.2rem 0 0.8rem; border-radius: 2px; overflow: hidden; }
#boot-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--violet), var(--gold)); transition: width 0.25s ease; box-shadow: 0 0 12px var(--gold); }
#boot-msg { font-family: var(--f-ui); color: var(--ink3); letter-spacing: 0.15em; font-size: max(10px, 0.85rem); text-transform: uppercase; }

/* typography */
.title { font-family: var(--f-title); font-weight: 800; letter-spacing: 0.12em; }
.label { font-family: var(--f-ui); font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; font-size: max(10px, 0.78rem); color: var(--ink2); }
.gold { color: var(--gold); } .cyan { color: var(--cyan); } .violet { color: var(--violet); } .dim { color: var(--ink3); } .danger { color: var(--danger); } .ok { color: var(--ok); }

/* panels */
.panel { background: linear-gradient(180deg, var(--glass2), var(--glass)); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.05); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.panel.violet { border-color: var(--line2); }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.3rem 0.6rem; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.panel-head h2 { margin: 0; font-family: var(--f-title); font-weight: 800; font-size: 1.35rem; letter-spacing: 0.1em; color: var(--gold2); }
.panel-body { padding: 1rem 1.3rem; }
.divider { height: 1px; background: linear-gradient(90deg, transparent, var(--line), transparent); margin: 0.8rem 0; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5em; padding: 0.62em 1.3em; border-radius: 8px; border: 1px solid rgba(242, 196, 107, 0.5); background: linear-gradient(180deg, rgba(242, 196, 107, 0.18), rgba(242, 196, 107, 0.06)); color: var(--gold2); font-family: var(--f-ui); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; font-size: max(10px, 0.95rem); cursor: pointer; transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s; position: relative; }
.btn:hover { background: linear-gradient(180deg, rgba(242, 196, 107, 0.32), rgba(242, 196, 107, 0.12)); box-shadow: 0 0 18px rgba(242, 196, 107, 0.25); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, #f6d27e, #c9953f); color: #1b1206; border-color: #ffe3a3; text-shadow: none; }
.btn.primary:hover { box-shadow: 0 0 26px rgba(242, 196, 107, 0.55); }
.btn.ghost { background: transparent; border-color: rgba(255, 255, 255, 0.15); color: var(--ink2); }
.btn.violet { border-color: rgba(168, 107, 255, 0.6); color: #dcc6ff; background: linear-gradient(180deg, rgba(168, 107, 255, 0.22), rgba(168, 107, 255, 0.06)); }
.btn.danger { border-color: rgba(255, 74, 90, 0.6); color: #ffc0c6; background: linear-gradient(180deg, rgba(255, 74, 90, 0.2), rgba(255, 74, 90, 0.06)); }
.btn.small { padding: 0.35em 0.8em; font-size: max(10px, 0.8rem); }
.btn.big { padding: 0.9em 2em; font-size: 1.15rem; }
.btn[disabled], .btn.disabled { opacity: 0.4; pointer-events: none; }
.btn .key { font-size: max(10px, 0.72em); padding: 0.1em 0.45em; border-radius: 4px; background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(255, 255, 255, 0.15); color: var(--ink2); }
.iconbtn { width: 2.4rem; height: 2.4rem; border-radius: 8px; display: grid; place-items: center; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.12); cursor: pointer; color: var(--ink2); }
.iconbtn:hover { color: var(--gold2); border-color: var(--line); }

/* tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 0.3rem; } /* wraps at large interface scales (RG-025) */
.tab { padding: 0.5em 1em; font-family: var(--f-ui); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; font-size: max(10px, 0.85rem); color: var(--ink3); border-bottom: 2px solid transparent; cursor: pointer; background: none; border-top: 0; border-left: 0; border-right: 0; }
.tab:hover { color: var(--ink); }
.tab.on { color: var(--gold2); border-bottom-color: var(--gold); }

/* bars */
.bar { position: relative; height: 10px; background: rgba(0, 0, 0, 0.5); border-radius: 5px; overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.08); }
.bar > i { position: absolute; inset: 0 auto 0 0; width: 50%; background: linear-gradient(90deg, #2ee88a, #8affc0); transition: width 0.15s ease; }
.bar > b { position: absolute; inset: 0 auto 0 0; width: 50%; background: rgba(255, 255, 255, 0.35); transition: width 0.6s ease 0.25s; }
.bar.hp > i { background: linear-gradient(90deg, #d8283a, #ff6a5a); }
.bar.xp > i { background: linear-gradient(90deg, #7a3aff, #c8a0ff); }
.bar.gold > i { background: linear-gradient(90deg, #c9953f, #ffe3a3); }
.bar.shield > i { background: linear-gradient(90deg, #3aa8ff, #aee4ff); }

/* chips / badges */
.chip { display: inline-flex; align-items: center; gap: 0.35em; padding: 0.15em 0.6em; border-radius: 999px; font-family: var(--f-ui); font-weight: 700; font-size: max(10px, 0.75rem); letter-spacing: 0.1em; text-transform: uppercase; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.12); color: var(--ink2); }
.chip.gold { color: var(--gold2); border-color: var(--line); }
.chip.violet { color: #dcc6ff; border-color: var(--line2); }
.chip.ok { color: var(--ok); border-color: rgba(71, 240, 160, 0.35); }
.chip.danger { color: #ffb0b8; border-color: rgba(255, 74, 90, 0.4); }
.chip.sim { color: #ffd0a0; border-color: rgba(255, 176, 58, 0.45); background: rgba(255, 176, 58, 0.1); }

/* damage numbers */
.dmg { position: absolute; left: 0; top: 0; font-family: var(--f-ui); font-weight: 700; font-size: 1.25rem; color: #fff; text-shadow: 0 2px 0 #000, 0 0 10px rgba(0, 0, 0, 0.8); white-space: nowrap; will-change: transform; display: none; }
.dmg.crit { color: #ffd24a; font-size: 1.75rem; text-shadow: 0 2px 0 #3a1a00, 0 0 16px rgba(255, 160, 40, 0.8); }
.dmg.heal { color: #6affb0; }

/* toasts */
#toasts { position: fixed; top: 6.4rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 0.5rem; align-items: center; z-index: 60; pointer-events: none; }
.toast { background: linear-gradient(180deg, rgba(26, 18, 48, 0.95), rgba(14, 10, 28, 0.92)); border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem 1.2rem; min-width: 280px; box-shadow: var(--shadow); display: flex; gap: 0.8rem; align-items: center; animation: toastIn 0.35s cubic-bezier(.2, 1.4, .4, 1); }
.toast.out { animation: toastOut 0.3s ease forwards; }
.toast .t-ico { width: 2.2rem; height: 2.2rem; border-radius: 8px; display: grid; place-items: center; background: rgba(242, 196, 107, 0.15); color: var(--gold); font-size: 1.2rem; flex: none; }
.toast .t-title { font-family: var(--f-ui); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold2); font-size: max(10px, 0.9rem); }
.toast .t-body { color: var(--ink2); font-size: max(10px, 0.85rem); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(0.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

/* subtitles */
#subtitles { position: fixed; left: 50%; bottom: 8%; transform: translateX(-50%); max-width: min(900px, 90vw); text-align: center; z-index: 55; pointer-events: none; }
#subtitles .sub { display: inline-block; background: rgba(0, 0, 0, 0.62); padding: 0.45rem 1rem; border-radius: 6px; font-size: 1.15rem; line-height: 1.4; color: #fff; }
#subtitles .sub b { color: var(--gold2); font-family: var(--f-ui); letter-spacing: 0.08em; margin-right: 0.4em; }

/* tooltips */
.tip { position: fixed; z-index: 80; max-width: 320px; padding: 0.7rem 0.9rem; pointer-events: none; font-size: max(10px, 0.88rem); line-height: 1.35; }
.tip h4 { margin: 0 0 0.3rem; font-family: var(--f-ui); letter-spacing: 0.08em; color: var(--gold2); }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(3, 1, 8, 0.66); display: grid; place-items: center; z-index: 70; animation: fadeIn 0.2s ease; }
.gfx-back, .fault-back { z-index: 96; }
.frame-stats { position: fixed; right: 0.6rem; bottom: 0.5rem; z-index: 97; display: none; padding: 0.2rem 0.55rem; border-radius: 4px; background: rgba(0, 0, 0, 0.6); color: #cfe8ff; font: 600 max(10px, 0.8rem)/1.3 var(--f-ui); letter-spacing: 0.04em; pointer-events: none; }
/* visible focus for keyboard and controller navigation (RG-015) */
:where(button, .btn, [role="button"], select, input, a, .tab, .nav-item, .opt, .upg):focus-visible { outline: 2px solid var(--gold2); outline-offset: 2px; box-shadow: 0 0 0 4px rgba(242, 196, 107, 0.25); }
.gfx-status { display: flex; align-items: center; gap: 0.7rem; font-family: var(--f-ui); letter-spacing: 0.1em; color: var(--gold2); }
.gfx-spin { width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 2px solid rgba(242, 196, 107, 0.25); border-top-color: var(--gold); animation: ldSpin 0.9s linear infinite; }
.modal { width: min(560px, 92vw); max-height: 88vh; overflow: auto; animation: popIn 0.28s cubic-bezier(.2, 1.3, .4, 1); }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.94) translateY(8px); } }

/* scrollbars */
.scroll { overflow: auto; }
.scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll::-webkit-scrollbar-thumb { background: rgba(242, 196, 107, 0.25); border-radius: 4px; }
.scroll::-webkit-scrollbar-track { background: transparent; }

/* grid helpers */
.row { display: flex; gap: 0.8rem; align-items: center; }
.col { display: flex; flex-direction: column; gap: 0.6rem; }
.grow { flex: 1; }
.center { display: grid; place-items: center; }
.hidden { display: none !important; }

/* collectible card frame */
.rgcard { --rc: var(--r-common); position: relative; width: 11.5rem; aspect-ratio: 5 / 7; border-radius: 12px; overflow: hidden; background: #0b0816; border: 2px solid var(--rc); box-shadow: 0 8px 26px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 0, 0, 0.6) inset; cursor: pointer; transition: transform 0.18s ease, box-shadow 0.18s ease; font-family: var(--f-ui); }
.rgcard:hover { transform: translateY(-4px) scale(1.02); box-shadow: 0 14px 34px rgba(0, 0, 0, 0.7), 0 0 22px color-mix(in srgb, var(--rc) 45%, transparent); }
.rgcard.r-uncommon { --rc: var(--r-uncommon); } .rgcard.r-rare { --rc: var(--r-rare); } .rgcard.r-epic { --rc: var(--r-epic); } .rgcard.r-legendary { --rc: var(--r-legendary); }
.rgcard .art { position: absolute; inset: 0 0 38% 0; background-size: cover; background-position: center; }
.rgcard .art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, #0b0816 100%); }
.rgcard .cost { position: absolute; top: 6px; left: 6px; width: 1.9rem; height: 1.9rem; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 35% 30%, #8ad8ff, #1a5aa8); border: 2px solid #cfeeff; font-weight: 800; font-size: 1.05rem; color: #fff; text-shadow: 0 1px 2px #000; z-index: 2; }
.rgcard .kind { position: absolute; top: 8px; right: 8px; z-index: 2; }
.rgcard .name { position: absolute; left: 0; right: 0; top: 60%; text-align: center; font-weight: 700; font-size: max(10px, 0.95rem); letter-spacing: 0.06em; color: #fff; text-shadow: 0 1px 3px #000; padding: 0 0.4rem; }
.rgcard .text { position: absolute; left: 0.5rem; right: 0.5rem; top: 70%; bottom: 1.8rem; font-family: var(--f-body); font-size: max(10px, 0.68rem); line-height: 1.25; color: var(--ink2); text-align: center; overflow: hidden; }
.rgcard .stats { position: absolute; bottom: 5px; left: 6px; right: 6px; display: flex; justify-content: space-between; font-weight: 800; font-size: 1.05rem; }
.rgcard .stats .atk { color: #ffd24a; } .rgcard .stats .hp { color: #ff6a6a; }
.rgcard .edition { position: absolute; bottom: 6px; left: 0; right: 0; text-align: center; font-size: max(10px, 0.6rem); letter-spacing: 0.15em; color: var(--ink3); }
.rgcard.foil::before { content: ''; position: absolute; inset: 0; z-index: 3; pointer-events: none; background: linear-gradient(115deg, transparent 20%, rgba(255, 230, 160, 0.35) 38%, rgba(160, 220, 255, 0.3) 46%, transparent 60%); background-size: 250% 250%; mix-blend-mode: screen; animation: foil 3.2s linear infinite; }
.rgcard.prismatic::before { content: ''; position: absolute; inset: 0; z-index: 3; pointer-events: none; background: conic-gradient(from 0deg, rgba(255, 80, 200, 0.25), rgba(80, 200, 255, 0.25), rgba(120, 255, 160, 0.25), rgba(255, 220, 80, 0.25), rgba(255, 80, 200, 0.25)); mix-blend-mode: color-dodge; animation: prism 5s linear infinite; }
@keyframes foil { from { background-position: 200% 0; } to { background-position: -50% 0; } }
@keyframes prism { to { filter: hue-rotate(360deg); } }
.rgcard .state { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; background: rgba(5, 3, 11, 0.55); font-weight: 800; letter-spacing: 0.2em; color: var(--ink2); font-size: max(10px, 0.8rem); }
.rgcard.unowned { filter: grayscale(0.9) brightness(0.5); }

/* accessibility */
body.high-contrast { --glass: rgba(0, 0, 0, 0.95); --glass2: rgba(0, 0, 0, 0.95); --ink2: #ffffff; --ink3: #d0d0d0; --line: #ffd24a; }
body.reduced-motion *, body.reduced-motion *::before, body.reduced-motion *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; transition-duration: 0.001s !important; }

/* RG-025: under a station panel or a menu the world's labels and the hub bar hide instead of showing through */
body.menu-open .nameplate, body.menu-open .hub-hint, body.menu-open .hub-topbar, body.menu-open .hub-prompt { visibility: hidden; }
