:root {
  --blue: #1b6fd6; --blue2: #0e4fa5; --panel: rgba(250, 252, 255, 0.94); --ink: #1d2b3a; --muted: #5d6b7a;
  --green: #4fd04a; --line: #d5dde8; --shadow: 0 6px 22px rgba(10, 30, 60, 0.28);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; font-family: "Segoe UI", system-ui, sans-serif; color: var(--ink); background: #9cc7ee; user-select: none; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#labels { position: fixed; inset: 0; pointer-events: none; }
.label { position: absolute; transform: translate(-50%, -50%); background: #fff; border: 2px solid var(--blue); border-radius: 10px; padding: 1px 8px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.label.dim { border-color: #f0a020; }
.hidden { display: none !important; }
.panel { background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); backdrop-filter: blur(6px); }

#topbar { position: fixed; top: 10px; left: 10px; right: 10px; display: flex; gap: 10px; flex-wrap: wrap; pointer-events: none; }
#topbar .group { pointer-events: auto; display: flex; align-items: center; gap: 4px; padding: 5px 8px; background: var(--panel); border-radius: 22px; box-shadow: var(--shadow); }
#topbar .brand { gap: 8px; padding: 5px 14px 5px 10px; }
#money { color: #1a7a2e; font-weight: 700; font-variant-numeric: tabular-nums; }
#filebtns { margin-left: auto; }
.plumbob { width: 14px; height: 20px; display: inline-block; background: linear-gradient(160deg, #b6ff9a, #2fc22a 55%, #158a1a); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.plumbob.big { width: 44px; height: 64px; animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-10px); } }

button.tb { border: 0; background: transparent; border-radius: 16px; min-width: 34px; height: 34px; padding: 0 9px; font-size: 16px; cursor: pointer; color: var(--ink); display: flex; align-items: center; gap: 5px; }
button.tb small { font-size: 12px; font-weight: 600; }
button.tb:hover { background: #dcebff; }
button.tb.on { background: var(--blue); color: #fff; }
button.tb:disabled { opacity: 0.35; cursor: default; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 3px; }

#info { position: fixed; left: 10px; bottom: 208px; width: 270px; padding: 12px 14px; font-size: 13px; }
#info h3 { margin: 0 0 2px; font-size: 15px; }
#info .muted { color: var(--muted); }
#info .row { display: flex; gap: 6px; margin-top: 9px; flex-wrap: wrap; }
#info a { color: var(--blue); }
button.pill { border: 0; background: var(--blue); color: #fff; border-radius: 14px; padding: 5px 11px; font-size: 12px; font-weight: 600; cursor: pointer; }
button.pill.alt { background: #e3ebf5; color: var(--ink); }
button.pill.danger { background: #d9463c; }
button.pill:hover { filter: brightness(1.08); }

#hint { position: fixed; right: 10px; bottom: 208px; padding: 7px 12px; font-size: 12px; color: var(--muted); max-width: 420px; }
#hint b { color: var(--ink); }
kbd { background: #fff; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; font: 600 11px "Segoe UI", sans-serif; color: var(--ink); }

#catalog { position: fixed; left: 10px; right: 10px; bottom: 10px; height: 188px; display: flex; flex-direction: column; }
#tabs { display: flex; gap: 4px; padding-left: 14px; }
#tabs button { border: 0; background: var(--blue2); color: #dbe9ff; border-radius: 12px 12px 0 0; padding: 6px 12px 5px; font-size: 13px; font-weight: 600; cursor: pointer; display: flex; gap: 5px; align-items: center; }
#tabs button.on { background: var(--panel); color: var(--ink); }
#tabs button:hover:not(.on) { background: var(--blue); }
#catbody { flex: 1; min-height: 0; background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; padding: 7px 10px 8px; }
#subs { display: flex; gap: 5px; align-items: center; margin-bottom: 6px; overflow-x: auto; scrollbar-width: none; }
#subs button { border: 0; background: #e3ebf5; border-radius: 12px; padding: 3px 10px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; color: var(--ink); }
#subs button.on { background: var(--blue); color: #fff; }
#subs input { border: 1px solid var(--line); border-radius: 12px; padding: 3px 10px; font-size: 12px; width: 150px; margin-left: auto; flex: none; }
#subs select { border: 1px solid var(--line); border-radius: 12px; padding: 2px 6px; font-size: 12px; background: #fff; }
#subs label { font-size: 12px; color: var(--muted); white-space: nowrap; }
#items { flex: 1; min-height: 0; display: grid; grid-auto-flow: column; grid-template-rows: 1fr; grid-auto-columns: 104px; gap: 7px; overflow-x: auto; overflow-y: hidden; padding-bottom: 4px; }
.card { background: #fff; border: 2px solid transparent; border-radius: 10px; cursor: pointer; display: flex; flex-direction: column; align-items: center; padding: 4px 4px 3px; min-height: 0; position: relative; }
.card:hover { border-color: #9cc3f5; }
.card.on { border-color: var(--green); box-shadow: 0 0 0 2px rgba(79, 208, 74, 0.35); }
.card img { width: 84px; height: 72px; object-fit: contain; pointer-events: none; flex: none; }
.card .nm { font-size: 10.5px; line-height: 1.15; text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; margin-top: 1px; }
.card .pr { position: absolute; top: 3px; right: 5px; font-size: 10px; font-weight: 700; color: #1a7a2e; }
.card .ik { position: absolute; top: 3px; left: 4px; font-size: 8px; font-weight: 800; background: #ffda1a; color: #0058a3; border-radius: 4px; padding: 0 3px; }

#modal { position: fixed; inset: 0; background: rgba(10, 25, 50, 0.45); display: flex; align-items: center; justify-content: center; z-index: 20; }
#modalbox { width: min(760px, 92vw); max-height: 84vh; overflow: auto; padding: 18px 22px; font-size: 14px; }
#modalbox h2 { margin: 0 0 10px; }
#modalbox table { width: 100%; border-collapse: collapse; font-size: 13px; }
#modalbox th, #modalbox td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
#modalbox td.n, #modalbox th.n { text-align: right; font-variant-numeric: tabular-nums; }
#modalbox .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
#modalbox .keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center; }
#modalbox .swatches { display: flex; flex-wrap: wrap; gap: 7px; margin: 6px 0 14px; }
#modalbox .sw { border: 2px solid var(--line); border-radius: 10px; padding: 4px 9px 4px 5px; cursor: pointer; display: flex; align-items: center; gap: 7px; background: #fff; font-size: 12px; }
#modalbox .sw.on { border-color: var(--green); box-shadow: 0 0 0 2px rgba(79, 208, 74, 0.35); }
#modalbox .sw i { width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(0, 0, 0, 0.2); display: inline-block; }

#loading { position: fixed; inset: 0; background: linear-gradient(#2a7de1, #0c3f8a); display: flex; align-items: center; justify-content: center; color: #fff; text-align: center; z-index: 50; font-size: 15px; }

#savestate { font-size: 12px; min-width: 62px; }
.muted { color: var(--muted); }
#modalbox code { background: #e9eef5; border-radius: 5px; padding: 0 4px; }
