/* Dense, dark, idle-game UI after the person's video (BRIEF.md, Style).
   Sizes and timings are presentation; every number about the game comes
   from the core already formatted. */
:root {
  --bg: #151923; --panel: #222838; --panel2: #2b3246; --line: #39415a;
  --fg: #e8ecf5; --muted: #98a2bb; --dim: #677089;
  --gold: #f0a920; --gold-ink: #241a02; --xp: #4f8ef7; --mast: #a56cf0; --hp: #d9534f;
  --good: #46c47a; --chip: #1a1f2c; --pres: #e86fb0; --fire: #f08a2a;
  --r: 8px; --tap: 44px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.35 var(--font); touch-action: manipulation; -webkit-user-select: none; user-select: none; overflow: hidden; -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; }
textarea { -webkit-user-select: text; user-select: text; }
.ic { width: 20px; height: 20px; flex: none; }
.ic.big { width: 36px; height: 36px; }
.app { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; max-width: 1180px; margin: 0 auto; padding: 0 var(--safe-r) 0 var(--safe-l); }

/* top bar */
.top { display: flex; align-items: center; gap: 6px; padding: calc(var(--safe-t) + 6px) 10px 6px; background: #10141c; border-bottom: 1px solid var(--line); }
.pill { display: flex; align-items: center; gap: 5px; background: var(--chip); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 13px; }
.pill .coin { width: 16px; height: 16px; }
.pill.pres { border-color: var(--pres); color: #ffd0ea; }
.sp { flex: 1; }
.btn.icon-btn { min-width: var(--tap); min-height: var(--tap); padding: 0 8px; }
.btn.icon-btn .label { display: none; }
.btn.flag-btn .label { display: inline; font-size: 12px; }

/* screen */
.main { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 10px 10px 16px; display: grid; gap: 10px; align-content: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.head { display: flex; align-items: center; gap: 10px; }
.head .ico { width: 40px; height: 40px; border-radius: 8px; background: var(--panel2); display: grid; place-items: center; }
.head .ico .ic { width: 28px; height: 28px; }
.head h1 { margin: 0; font-size: 18px; letter-spacing: .05em; text-transform: uppercase; flex: 1; }
.tag { font-weight: 800; font-size: 12.5px; padding: 3px 9px; border-radius: 6px; background: var(--panel2); color: #fff; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag.xp { background: var(--xp); } .tag.mast { background: var(--mast); } .tag.hp { background: var(--hp); } .tag.pres { background: var(--pres); }
.tag.lock { background: none; color: var(--muted); font-weight: 600; padding: 0; }
.bar { position: relative; height: 18px; border-radius: 5px; background: var(--chip); overflow: hidden; border: 1px solid var(--line); }
.bar > i { position: absolute; inset: 0 auto 0 0; background: var(--xp); transition: width .35s ease-out; }
.bar.mast > i { background: var(--mast); } .bar.hp > i { background: var(--hp); } .bar.pres > i { background: var(--pres); } .bar.max > i { background: var(--gold); }
.bar > span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 8px; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; text-shadow: 0 1px 1px #000a; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { display: inline-flex; align-items: center; gap: 5px; background: var(--chip); border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px; font-size: 12px; font-variant-numeric: tabular-nums; }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: #cfd6e6; }
.chip.x .dot { background: var(--xp); } .chip.m .dot { background: var(--mast); } .chip.g .dot { background: var(--gold); }
.chip.h .dot { background: var(--hp); } .chip.p .dot { background: var(--pres); } .chip.fire { border-color: var(--fire); } .chip.fire .dot { background: var(--fire); }
.chip.bad { border-color: var(--hp); } .chip.bad .dot { background: var(--hp); }
.flow { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; font-size: 12px; color: var(--muted); }
.btn.link { min-height: 30px; padding: 2px 8px; font-size: 12px; font-weight: 600; background: var(--chip); }
.btn.link .ic { width: 14px; height: 14px; }
.sec-h { margin: 0; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.note { margin: 0; color: var(--muted); font-size: 13px; }
.forecast { padding: 8px 10px; display: grid; gap: 6px; }

/* the scene and the action bar: CSS animation from the core's duration */
.scene { height: 110px; position: relative; overflow: hidden; border-radius: var(--r); background: linear-gradient(#2a3a5c, #1d2a3f 70%, #213322 70%); border: 1px solid var(--line); }
.scene-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.scene .moon { fill: #f5e6a8; opacity: .8; }
.scene .skin { fill: #e0b48a; } .scene .body { stroke: #3a6ad0; stroke-width: 5; stroke-linecap: round; fill: none; }
.scene .arm { stroke: #e0b48a; stroke-width: 4; stroke-linecap: round; } .scene .haft { stroke: #a07040; stroke-width: 3; } .scene .blade { fill: #cfd6e6; }
.scene .swing { transform-origin: 112px 72px; transform: rotate(-70deg); }
.scene.running .swing { animation: swing var(--dur, 3s) linear var(--delay, 0s) infinite; }
@keyframes swing { 0%, 80% { transform: rotate(-70deg); } 90% { transform: rotate(25deg); } 100% { transform: rotate(-70deg); } }
.scene .cap { position: absolute; left: 8px; bottom: 6px; font-size: 11px; color: #c9d3e8; background: #0008; padding: 2px 6px; border-radius: 4px; }
.act-bar { height: 8px; border-radius: 4px; background: var(--chip); overflow: hidden; }
.act-bar.now { height: 10px; }
.act-bar > i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #f5c04b, var(--gold)); transform-origin: left; transform: scaleX(0); animation: fill var(--dur, 3s) linear var(--delay, 0s) infinite; }
@keyframes fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 8px; }
.card { padding: 10px; display: grid; gap: 7px; align-content: start; }
.card.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.card.locked { opacity: .55; }
.card-top { display: flex; gap: 10px; align-items: center; }
.art { width: 46px; height: 46px; flex: none; border-radius: 8px; background: var(--panel2); display: grid; place-items: center; }
.nm { flex: 1; min-width: 0; }
.nm strong { display: block; font-size: 15px; }
.nm small { color: var(--muted); font-size: 12px; }
.checks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.checks div { font-size: 10.5px; text-align: center; padding: 3px 2px; border-radius: 4px; background: var(--chip); color: var(--dim); border: 1px solid var(--line); }
.checks div.on { color: #e9dcff; border-color: var(--mast); background: #2e2346; }
.card-buttons { display: flex; gap: 6px; }
.btn { min-height: var(--tap); padding: 0 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel2); font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.go { flex: 1; }
.btn.small { padding: 0 10px; font-size: 13px; }
.btn.primary { background: #3d5bb8; border-color: #4c6bd0; }
.btn.stop { background: #7a3030; border-color: #94403e; }
.btn.good { background: #2e7d4f; border-color: #3a9761; }
.btn.pres { background: #8a2f63; border-color: var(--pres); }
.btn.plain { background: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }

/* combat */
.styles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.btn.style { display: grid; justify-items: center; align-content: center; min-height: 64px; padding: 6px 4px; gap: 2px; }
.btn.style small { color: var(--muted); font-size: 10.5px; font-weight: 500; text-align: center; }
.fight { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.fighter { display: grid; gap: 4px; min-width: 0; }
.fighter b { font-size: 13px; }
.vs { font-weight: 800; color: var(--dim); }

/* bank, rows, lists */
.bank { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; padding: 8px; }
.slot { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; aspect-ratio: 1; display: grid; place-items: center; position: relative; padding: 4px; cursor: pointer; min-height: var(--tap); }
.slot-ic { width: 58%; height: 58%; }
.slot b { position: absolute; left: 4px; top: 2px; font-size: 11px; color: #ffe38a; text-shadow: 0 1px 1px #000; }
.slot small { position: absolute; bottom: 2px; font-size: 9.5px; color: var(--muted); white-space: nowrap; overflow: hidden; max-width: 95%; }
.group { display: grid; gap: 6px; }
.rows { display: grid; }
.rowi { display: flex; align-items: center; gap: 10px; padding: 10px; border-top: 1px solid var(--line); min-height: var(--tap); flex-wrap: wrap; }
.rowi:first-child { border-top: 0; }
.row-ic { width: 28px; height: 28px; }
.grow { flex: 1; min-width: 150px; }
.grow b { display: block; }
.grow small { color: var(--muted); display: block; }
.row-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; }
.button-row .btn { flex: 1; }
.keep { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px; }
.keep h3 { margin: 0 0 4px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.keep .k h3 { color: var(--good); } .keep .l h3 { color: var(--hp); }
.keep ul { margin: 0; padding-left: 1.1em; display: grid; gap: 3px; font-size: 13px; }
.info { padding: 10px; }
.info h2 { margin: 0 0 4px; font-size: 15px; }
.info p { margin: 0; color: var(--muted); }

/* tabs (P21): on a phone, a strip of the group's tabs under the top bar and
   five groups along the bottom; on a wide screen, every tab in a rail */
.tabs { background: #10141c; border-bottom: 1px solid var(--line); padding: 3px; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs .tab { flex: 1 0 58px; }
.tabs .tab:not(.in), .rail-h { display: none; }
.groups { background: #10141c; border-top: 1px solid var(--line); padding: 3px 3px calc(var(--safe-b) + 3px); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; }
.tab { min-height: 50px; border: 1px solid transparent; border-radius: 8px; background: none; display: grid; justify-items: center; align-content: center; gap: 1px; cursor: pointer; padding: 2px 0; position: relative; min-width: 0; }
.tab .ic { width: 22px; height: 22px; }
.tab-label { font-size: 9.5px; color: var(--muted); white-space: nowrap; overflow: hidden; max-width: 100%; }
.tab .full { display: none; }
.group .tab-label { font-size: 11px; }
.tab[aria-current="page"] { background: var(--panel2); border-color: var(--line); }
.tab[aria-current="page"] .tab-label { color: var(--fg); }
.tab.locked { opacity: .45; }
.tab .run { position: absolute; top: 4px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 6px var(--good); }
.tab .lvl { position: absolute; top: 2px; left: 4px; font-size: 9px; color: var(--dim); font-weight: 700; }
.app { grid-template-rows: auto auto minmax(0, 1fr) auto; }
@media (min-width: 900px) {
  .app { grid-template-columns: 220px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .top { grid-column: 1 / -1; }
  .groups { display: none; }
  .tabs { grid-row: 2; grid-column: 1; display: grid; grid-template-columns: 1fr; align-content: start; border-bottom: 0; border-right: 1px solid var(--line); overflow-y: auto; }
  .tabs .tab:not(.in) { display: grid; }
  .rail-h { display: block; padding: 8px 8px 2px; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); font-weight: 700; }
  .tab { grid-template-columns: 24px 26px 1fr; justify-items: start; align-items: center; padding: 4px 22px 4px 8px; min-height: 38px; }
  .tab-label { font-size: 13px; } .tab .short { display: none; } .tab .full { display: inline; }
  .tab .lvl { position: static; font-size: 11px; }
  .tab .run { right: 8px; top: 50%; }
  .main { grid-row: 2; grid-column: 2; padding: 14px; }
}
.note.wide { flex-basis: 100%; }
@media (max-height: 560px) and (orientation: landscape) { .scene { height: 80px; } }

/* sheets */
.shade { position: fixed; inset: 0; background: #05070cd0; display: grid; place-items: end center; z-index: 20; padding: 12px 12px calc(var(--safe-b) + 12px); }
@media (min-width: 700px) { .shade { place-items: center; } }
.sheet { width: min(540px, 100%); max-height: 88vh; overflow-y: auto; overscroll-behavior: contain; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: grid; gap: 10px; }
.sheet h2 { margin: 0; font-size: 20px; }
.sheet p { margin: 0; color: var(--muted); }
.sheet .eyebrow { font-size: 13px; }
.big { font: 800 32px/1.05 var(--font); font-variant-numeric: tabular-nums; }
.gains { display: grid; gap: 6px; }
.gains .rowi { border: 1px solid var(--line); border-radius: 8px; background: var(--chip); padding: 7px 10px; opacity: 0; transform: translateY(6px); animation: rise .35s ease-out forwards; animation-delay: calc(var(--i, 0) * 80ms); }
.gains .rowi.up { border-color: var(--xp); } .gains .rowi.rare { border-color: var(--gold); background: #2f2510; } .gains .rowi.used { border-style: dashed; color: var(--muted); }
@keyframes rise { to { opacity: 1; transform: none; } }
.ready .rowi { flex-wrap: wrap; }
.capnote { font-size: 12px; border-left: 3px solid var(--gold); padding-left: 8px; }
.choice h3, .input h3 { margin: 0 0 6px; font-size: 14px; }
.btn.pick { flex: 1 1 22%; min-width: 70px; }
.input { display: grid; }
.input textarea { width: 100%; font: 16px var(--font); padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); }
.sheet-buttons .btn { min-height: 48px; }

/* toasts */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--safe-b) + 120px); display: grid; justify-items: center; gap: 6px; pointer-events: none; z-index: 30; }
.toast { background: #0f1320; border: 1px solid var(--gold); padding: 8px 14px; border-radius: 10px; font-weight: 700; opacity: 0; animation: toast 2.6s ease-out forwards; animation-delay: calc(var(--i, 0) * 250ms); }
@keyframes toast { 0% { opacity: 0; transform: translateY(10px); } 10%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }
#message:not(:empty) { position: fixed; top: 40%; left: 16px; right: 16px; text-align: center; color: var(--hp); }
@media (prefers-reduced-motion: reduce) {
  .scene.running .swing, .act-bar > i { animation-duration: 0s; }
  .gains .rowi, .toast { animation: none; opacity: 1; transform: none; }
}
.search { display: grid; gap: 4px; }
.search input { width: 100%; font: 16px var(--font); padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); -webkit-user-select: text; user-select: text; }
