/* Crab Realms – interfejs. Wszystkie kolory z palety Endesga 64 (public/js/palette.js → MMO.pal.UI / RARITY), jako zmienne --c-*.
   Okna, sloty i przyciski to 9-slice z ui_*.png (generator: tools/art/ui.js) rysowane w skali ×2 (image-rendering: pixelated).
   Odstępy: 4 / 8 / 12 / 16 px. Przewodnik: public/assets/STYLE.md. */

/* ================================================ czcionki (OFL, public/fonts): pikselowa Jersey 10 i czytelna Rubik (ustawienia: klasa font-clean).
   size-adjust wyrównuje wielkość obu krojów, więc rozmiary w CSS są wspólne. */
@font-face { font-family: 'Jersey 10'; font-style: normal; font-weight: 400; font-display: swap; size-adjust: 125%; src: url(../fonts/jersey10-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Jersey 10'; font-style: normal; font-weight: 400; font-display: swap; size-adjust: 125%; src: url(../fonts/jersey10-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Rubik'; font-style: normal; font-weight: 400 700; font-display: swap; size-adjust: 94%; src: url(../fonts/rubik-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Rubik'; font-style: normal; font-weight: 400 700; font-display: swap; size-adjust: 94%; src: url(../fonts/rubik-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ================================================ kolory (MMO.pal.UI, RARITY, RAMPS.wood) */
:root {
  --c-bg: #0e071b; --c-panel: #1c121c; --c-panel-in: #391f21; --c-edge: #8a4836; --c-light: #bf6f4a; --c-hi: #e69c69; --c-outline: #131313;
  --c-w0: #1c121c; --c-w1: #391f21; --c-w2: #5d2c28; --c-w3: #8a4836; --c-w4: #bf6f4a; --c-w5: #e69c69;
  --c-g2: #272727; --c-g3: #3d3d3d; --c-g4: #5d5d5d;
  --c-text: #f9e6cf; --c-dim: #b4b4b4; --c-mute: #858585; --c-title: #ffc825;
  --c-primary: #ffa214; --c-primary-dark: #ed7614; --c-secondary: #bf6f4a; --c-gold-hi: #ffeb57;
  --c-danger: #c42430; --c-danger-light: #ea323c; --c-good: #5ac54f; --c-lime: #99e65f; --c-info: #00cdf9; --c-info-dark: #0098dc; --c-warn: #ffc825;
  --c-disabled: #3d3d3d; --c-disabled-text: #858585;
  --c-hp: #ea323c; --c-hp-hi: #f5555d; --c-hp-lo: #c42430; --c-hp-back: #571c27;
  --c-mana: #0098dc; --c-mana-hi: #00cdf9; --c-mana-lo: #0069aa;
  --c-xp: #ca52c9; --c-xp-hi: #f389f5; --c-xp-lo: #93388f;
  --c-gold: #ffc825; --c-night: #0e071b; --c-steel: #92a1b9;
  --c-r-common: #b4b4b4; --c-r-rare: #5ac54f; --c-r-unique: #0098dc; --c-r-epic: #db3ffd; --c-r-legendary: #ed7614; --c-r-set: #edab50;
  /* nazwy sprzed przebudowy (używa ich też css/fx.css i okno walki) */
  --bg: var(--c-bg); --panel: var(--c-panel); --line: var(--c-w2); --text: var(--c-text); --muted: var(--c-dim);
  --accent: var(--c-primary); --accent2: var(--c-xp); --good: var(--c-good); --bad: var(--c-danger-light);
  --px-dark: var(--c-outline); --px-hi: var(--c-w4); --px-lo: var(--c-w1); --px-frame: var(--c-w2);
  --ui-font: 'Jersey 10', 'Courier New', monospace;
  --slot: 52px; /* slot: ikona 32 px + ramka 2 × 10 px */
}
html.font-clean { --ui-font: 'Rubik', 'Segoe UI', system-ui, sans-serif; }
.r-common { --rc: var(--c-r-common); } .r-rare { --rc: var(--c-r-rare); } .r-unique { --rc: var(--c-r-unique); }
.r-epic { --rc: var(--c-r-epic); } .r-legendary { --rc: var(--c-r-legendary); } .r-set { --rc: var(--c-r-set); }

/* ================================================ podstawa */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden; background: var(--c-bg); color: var(--c-text);
  font-family: var(--ui-font); font-size: 16px; letter-spacing: 0.2px; line-height: 1.25;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
/* Jersey 10 ma jedną grubość – bez sztucznego pogrubiania, które rozmywa piksele */
html:not(.font-clean) { font-synthesis: none; }
img, canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
img.px { vertical-align: middle; pointer-events: none; }
img.px.ghost { opacity: 0.5; }
#game { position: fixed; inset: 0; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
h4 { color: var(--c-dim); font-size: 14px; text-transform: uppercase; letter-spacing: 1px; margin: 12px 0 8px; font-weight: 400; }
b { font-weight: 400; color: var(--c-text); }
small { font-size: 13px; }
* { scrollbar-width: thin; scrollbar-color: var(--c-w4) var(--c-w0); }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--c-w0); box-shadow: inset 2px 0 0 var(--c-outline); }
::-webkit-scrollbar-thumb { background: var(--c-w4); border: 2px solid var(--c-outline); box-shadow: inset 2px 2px 0 var(--c-w5), inset -2px -2px 0 var(--c-w3); }
::-webkit-scrollbar-thumb:hover { background: var(--c-w5); }
::-webkit-scrollbar-corner { background: var(--c-w0); }

/* ================================================ panele i okna (9-slice ui_panel.png: ramka 16 px, wnętrze ciemny brąz) */
.panel, .window, #combat, .hud-card, .ctx, .invite, body .eui-tip {
  border: 16px solid transparent; padding: 8px; color: var(--c-text);
  border-image: url(../assets/ui_panel.png) 8 fill / 16px stretch;
  background: none; box-shadow: none; filter: drop-shadow(6px 6px 0 rgba(14, 7, 27, 0.55));
}
.hud-card { padding: 0 2px; }
.overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 12px; overflow: auto; z-index: 40;
  background: radial-gradient(ellipse at center, rgba(42, 47, 78, 0.6), rgba(14, 7, 27, 0.92));
}
.overlay.dim { background: rgba(14, 7, 27, 0.65); z-index: 45; }
.panel { width: min(520px, 100%); margin: auto; padding: 12px 16px 8px; text-align: center; }
.panel.narrow { width: min(380px, 100%); }
.panel h2 { color: var(--c-title); margin-bottom: 12px; font-size: 28px; font-weight: 400; letter-spacing: 1px; text-shadow: 2px 2px 0 var(--c-outline); }
.title { font-size: 56px; font-weight: 400; letter-spacing: 2px; color: var(--c-title); text-shadow: 0 4px 0 var(--c-w3), 0 7px 0 var(--c-outline); }
.subtitle { color: var(--c-dim); margin: 8px 0 16px; }
.status { color: var(--c-dim); min-height: 20px; margin: 8px 0 4px; }
.menu-row { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.menu-row .btn { flex: 1; }
.help-body { text-align: left; line-height: 1.35; margin-bottom: 12px; }
.help-body p { margin-bottom: 8px; }
.help-body b { color: var(--c-title); }
.note { color: var(--c-dim); margin: 4px 0 8px; line-height: 1.3; }
.death-title { color: var(--c-danger-light) !important; }

/* pojawianie się okien: krótki wjazd + fade (osobna własność `translate`, nie psuje transform: translateX(-50%)) */
@keyframes win-in { from { opacity: 0; translate: 0 8px; } to { opacity: 1; translate: 0 0; } }
.window, .overlay .panel, .ctx, .invite { animation: win-in 0.14s ease-out; }
@media (prefers-reduced-motion: reduce) { .window, .overlay .panel, .ctx, .invite { animation: none; } }

/* ================================================ przyciski: wzór 9-slice ×2 (rogi 6 px → ramka 12 px)
   normalny / najechany (jaśniejszy, wyżej o 1 px) / wciśnięty (niżej o 1 px) / nieaktywny (szary); złoty = główna akcja, czerwony = niebezpieczna */
.btn, .btn-play, .ab-btn, .tabs button, .btn-icon {
  --bi: url(../assets/ui_button.png);
  border: 12px solid transparent; border-image: var(--bi) 6 fill / 12px stretch; background: none; box-shadow: none;
  color: var(--c-panel); text-shadow: none; padding: 0 4px; line-height: 1.1; transition: transform 0.08s;
}
.btn:hover:not(:disabled), .ab-btn:hover:not(:disabled), .tabs button:hover:not(:disabled), .btn-icon:hover:not(:disabled), .btn-play:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled), .ab-btn:active:not(:disabled), .tabs button:active:not(:disabled), .btn-icon:active:not(:disabled), .btn-play:active:not(:disabled) { transform: translateY(1px); }
.btn:hover:not(:disabled), .ab-btn:hover:not(:disabled), .tabs button:hover:not(:disabled), .btn-icon:hover:not(:disabled) { --bi: url(../assets/ui_button_hover.png); }
.btn:active:not(:disabled), .ab-btn:active:not(:disabled), .tabs button:active:not(:disabled), .btn-icon:active:not(:disabled), .tabs button.sel { --bi: url(../assets/ui_button_down.png); }
.btn:disabled, .btn-play:disabled, .tabs button:disabled { --bi: url(../assets/ui_button_off.png); color: var(--c-disabled-text); cursor: default; transform: none; }
.btn-play { --bi: url(../assets/ui_button_primary.png); font-size: 22px; width: 100%; padding: 4px 8px; }
.btn-play:hover:not(:disabled) { --bi: url(../assets/ui_button_primary_hover.png); }
.btn-play:active:not(:disabled) { --bi: url(../assets/ui_button_primary_down.png); }
.btn-play:disabled { --bi: url(../assets/ui_button_off.png); }
.btn-play.small { width: auto; font-size: 18px; padding: 2px 16px; }
.btn.danger { --bi: url(../assets/ui_button_danger.png); color: var(--c-text); }
.btn.danger:hover:not(:disabled) { --bi: url(../assets/ui_button_danger_hover.png); }
.btn.danger:active:not(:disabled) { --bi: url(../assets/ui_button_danger_down.png); }
.btn { padding: 2px 8px; font-size: 18px; }
.btn.small { font-size: 16px; padding: 0 4px; }
.btn.wide { width: 100%; margin-top: 8px; }
.tabs button.sel { color: var(--c-title); }
.btn-icon { display: flex; flex-direction: column; align-items: center; gap: 0; width: 72px; padding: 0 2px; position: relative; font-size: 22px; }
.btn-icon small { font-size: 13px; color: var(--c-panel); }
.btn-icon img.px { margin: 2px 0; }
.btn-x { background: none; border: none; color: var(--c-dim); font-size: 22px; padding: 0 8px; line-height: 1; transition: transform 0.08s; }
.btn-x:hover { color: var(--c-danger-light); transform: translateY(-1px); }
.btn-x:active { transform: translateY(1px); }
.dot { position: absolute; top: 4px; right: 6px; width: 12px; height: 12px; background: var(--c-warn); border: 2px solid var(--c-outline); }

/* pola formularza: płaskie, wklęsłe */
input, select {
  background: var(--c-w0); color: var(--c-text); border: 2px solid var(--c-outline); box-shadow: inset 2px 2px 0 var(--c-night), inset -2px -2px 0 var(--c-w1);
  padding: 4px 8px; border-radius: 0; font-size: 16px;
}
input:focus, select:focus { outline: 2px solid var(--c-primary); outline-offset: 0; }
#nameInput { width: 100%; padding: 8px 12px; margin-bottom: 8px; font-size: 20px; text-align: center; }
#setBox { text-align: left; margin-bottom: 8px; }
.check { display: flex; gap: 8px; align-items: center; color: var(--c-dim); margin: 8px 0; cursor: pointer; }

/* ================================================ karty (płaskie ramki: obrys + wklęsłe światło) */
.class-card, .char-card, .class-info, .loot-row, .auc-row, .rank-row, .tal-node, .tal-ms, .death-stats div, .chip, .acc-strip, .pf {
  background: var(--c-w0); border: 2px solid var(--c-outline); border-radius: 0;
  box-shadow: inset 2px 2px 0 var(--c-night), inset -2px -2px 0 var(--c-w1);
}
.class-pick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 8px; }
.class-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 2px; color: var(--c-text); transition: transform 0.08s; }
.class-card:hover { transform: translateY(-1px); border-color: var(--c-w4); }
.class-card:active { transform: translateY(1px); }
.class-card.sel { border-color: var(--c-primary); background: var(--c-w1); box-shadow: inset 2px 2px 0 var(--c-w2), inset -2px -2px 0 var(--c-w0); }
.class-icon { height: 44px; display: flex; align-items: center; justify-content: center; }
.class-card small { color: var(--c-dim); line-height: 1.3; }
.class-dot { width: 14px; height: 14px; grid-row: span 2; margin-top: 3px; }
.class-info { text-align: left; padding: 8px 12px; margin-bottom: 12px; }
.class-info p { color: var(--c-dim); margin-bottom: 8px; line-height: 1.3; }
.class-stat { display: flex; gap: 8px; padding: 2px 0; color: var(--c-dim); }
.class-stat b { min-width: 96px; color: var(--c-text); }
.class-stat.main b { color: var(--c-title); }
.char-card { display: flex; flex-direction: column; gap: 4px; padding: 12px; margin-bottom: 12px; }
.char-card b { font-size: 24px; color: var(--c-title); }
.char-card span, .char-card small { color: var(--c-dim); }
.acc-strip { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; padding: 4px 8px; color: var(--c-dim); margin: 0 0 12px; }
.acc-strip b { color: var(--c-text); }
.fallen { text-align: left; margin-top: 12px; }
.fallen h4 { margin-top: 0; }
.fallen-row { display: flex; justify-content: space-between; padding: 2px 0; color: var(--c-dim); }
.fallen-row small { color: var(--c-mute); }
.death-stats { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.death-stats div { padding: 8px 12px; display: flex; flex-direction: column; min-width: 80px; }
.death-stats span { font-size: 26px; color: var(--c-text); }
.death-stats small { color: var(--c-dim); }

/* ================================================ HUD */
#hud { position: fixed; left: 10px; top: 10px; z-index: 10; pointer-events: none; }
.hud-card { width: 240px; }
.hud-name { margin-bottom: 4px; color: var(--c-text); }
.hud-name small { color: var(--c-dim); }
.hud-row { display: flex; justify-content: space-between; margin-top: 4px; color: var(--c-gold); }
.bar { position: relative; height: 18px; background: var(--c-hp-back); border: 2px solid var(--c-outline); border-radius: 0; overflow: hidden; }
.bar.small { height: 16px; margin-top: 4px; }
.bar > div { height: 100%; background: var(--c-hp); box-shadow: inset 0 2px 0 var(--c-hp-hi), inset 0 -2px 0 var(--c-hp-lo); transition: width 0.2s steps(6); }
.bar.xp { background: var(--c-night); }
.bar.xp > div { background: var(--c-xp); box-shadow: inset 0 2px 0 var(--c-xp-hi), inset 0 -2px 0 var(--c-xp-lo); }
.bar.xp.locked > div { background: var(--c-g4); box-shadow: inset 0 2px 0 var(--c-mute), inset 0 -2px 0 var(--c-g3); }
.bar.res { background: var(--c-night); }
.bar.res > div { background: var(--c-mana); box-shadow: inset 0 2px 0 var(--c-mana-hi), inset 0 -2px 0 var(--c-mana-lo); }
.bar.shielded { box-shadow: 0 0 0 2px var(--c-steel); }
.bar span { position: absolute; inset: 0; font-size: 13px; line-height: 14px; text-align: center; color: var(--c-text); text-shadow: 1px 1px 0 var(--c-outline), -1px 0 0 var(--c-outline), 0 1px 0 var(--c-outline); }
.bar.small span { font-size: 12px; line-height: 12px; }
#hudButtons { position: fixed; right: 10px; top: 10px; z-index: 10; display: flex; gap: 8px; }
#zoneBanner {
  position: fixed; left: 50%; top: 22%; transform: translateX(-50%); z-index: 9; pointer-events: none;
  font-size: 40px; color: var(--c-text); text-shadow: 3px 3px 0 var(--c-outline); letter-spacing: 2px; transition: opacity 1s;
}
#zoneBanner.fade { opacity: 0; }
#partyFrames { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; pointer-events: auto; }
.pf { width: 180px; padding: 4px 8px; box-shadow: inset 2px 2px 0 var(--c-night), inset -2px -2px 0 var(--c-w1); }
.pf.combat { border-color: var(--c-primary-dark); }
.pf.off { opacity: 0.5; }
.pf-name { display: flex; justify-content: space-between; }
.pf-name small { color: var(--c-dim); }
#invites { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(400px, calc(100vw - 20px)); }
.invite { text-align: center; }
.invite.duel { border-image-source: url(../assets/ui_panel.png); }
.invite p { margin-bottom: 8px; }
.ctx { position: fixed; z-index: 60; display: flex; flex-direction: column; gap: 4px; min-width: 200px; }
.ctx button { text-align: left; background: var(--c-w0); border: 2px solid var(--c-outline); padding: 4px 8px; color: var(--c-text); }
.ctx button:hover { border-color: var(--c-primary); background: var(--c-w1); }
.ctx-title { padding: 4px 8px; color: var(--c-title); }

/* ================================================ okna: postać, schowek, talenty, aukcje, handlarze */
.window {
  position: fixed; z-index: 30; right: 10px; top: 74px; width: min(768px, calc(100vw - 20px)); max-height: calc(100vh - 90px);
  overflow-y: auto; overflow-x: hidden;
}
.window.small { width: min(340px, calc(100vw - 20px)); right: auto; left: 50%; transform: translateX(-50%); top: 18%; }
.window.left { right: auto; left: 10px; width: min(428px, calc(100vw - 20px)); }
.window.wide { width: min(780px, calc(100vw - 20px)); left: 50%; right: auto; transform: translateX(-50%); }
#rankingPanel, #lootPanel { width: min(440px, calc(100vw - 20px)); }
.win-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.win-head h3 { color: var(--c-title); font-size: 26px; font-weight: 400; letter-spacing: 1px; text-shadow: 2px 2px 0 var(--c-outline); }
.char-body { display: flex; gap: 16px; flex-wrap: wrap; }
.char-left { flex: 1 1 320px; min-width: 0; }
.char-right { flex: 0 1 auto; min-width: 0; margin: 0 auto; }
.char-title { margin: 0 0 8px; color: var(--c-title); }
.char-title span { color: var(--c-dim); }
.char-doll-row { display: flex; gap: 12px; align-items: flex-start; margin-top: 8px; }
.paperdoll { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(4, auto); gap: 4px; flex: 0 0 auto; justify-items: center; align-items: start; }
.paperdoll .eq-weapon { grid-column: 1; grid-row: 1; }
.paperdoll .eq-gloves { grid-column: 1; grid-row: 2; }
.paperdoll .eq-helmet { grid-column: 2; grid-row: 1; }
.paperdoll .eq-figure { grid-column: 2; grid-row: 2; display: flex; align-items: center; justify-content: center; min-height: 64px; }
.paperdoll .eq-armor { grid-column: 2; grid-row: 3; }
.paperdoll .eq-boots { grid-column: 2; grid-row: 4; }
.paperdoll .eq-offhand { grid-column: 3; grid-row: 1; }
.paperdoll .eq-accessory { grid-column: 3; grid-row: 2; }
.eq-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.eq-cell small { font-size: 12px; color: var(--c-dim); text-align: center; line-height: 1; }
.char-stats { flex: 1 1 150px; min-width: 140px; }
.char-stats .stat-head { margin: 8px 0 4px; font-size: 13px; letter-spacing: 1px; color: var(--c-dim); font-weight: 400; }
.char-stats .stat-head:first-child { margin-top: 0; }
.stat-list > div { display: flex; justify-content: space-between; gap: 8px; padding: 2px 6px; }
.char-stats .stat-list > div:nth-of-type(odd) { background: rgba(255, 255, 255, 0.05); }
.char-stats .stat-list > div span { color: var(--c-dim); }
.char-stats .stat-list b { text-align: right; color: var(--c-text); }
.set-info { margin: 0 0 8px; }
.passive-list { margin-top: 8px; }
.char-gold { margin-top: 12px; color: var(--c-gold); }
.char-gold small { color: var(--c-dim); }

/* sloty: ikona 32 px w ramce ui_slot*.png (9-slice ×2: rogi 5 px → 10 px); rzadkość = kształt ramki */
.slot {
  position: relative; width: var(--slot); height: var(--slot); flex: 0 0 auto; display: flex; align-items: center; justify-content: center; touch-action: none;
  border: 10px solid transparent; border-image: url(../assets/ui_slot.png) 5 fill / 10px stretch; background: none; box-shadow: none; overflow: hidden;
}
.slot img, .slot canvas { display: block; width: 32px; height: 32px; }
.slot.full { cursor: grab; }
.slot.full:hover { filter: brightness(1.2); }
.slot .count { position: absolute; right: -4px; bottom: -6px; font-size: 14px; line-height: 1; color: var(--c-text); text-shadow: 1px 0 0 var(--c-outline), -1px 0 0 var(--c-outline), 0 1px 0 var(--c-outline), 0 -1px 0 var(--c-outline); pointer-events: none; }
.slot .badge { position: absolute; left: -4px; top: -4px; font-size: 14px; color: var(--c-title); }
.slot.locked img { opacity: 0.45; }
.slot.auction { opacity: 0.75; }
.slot.sel { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.slot.mini { cursor: default; }
.slot.mini:hover { filter: none; }
.eui-ghost.slot { overflow: visible; }
.slot.r-common, .eui-toast.r-common { border-image-source: url(../assets/ui_slot_common.png); }
.slot.r-rare, .eui-toast.r-rare { border-image-source: url(../assets/ui_slot_rare.png); }
.slot.r-unique, .eui-toast.r-unique { border-image-source: url(../assets/ui_slot_unique.png); }
.slot.r-epic, .eui-toast.r-epic { border-image-source: url(../assets/ui_slot_epic.png); }
.slot.r-legendary, .eui-toast.r-legendary { border-image-source: url(../assets/ui_slot_legendary.png); }
.slot.r-set, .eui-toast.r-set { border-image-source: url(../assets/ui_slot_set.png); border-image-repeat: round; }
/* legendarny: rzadki, krótki, schodkowy połysk przelatujący po ikonie */
.slot.r-legendary::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(110deg, transparent 42%, rgba(255, 235, 87, 0.6) 50%, transparent 58%) 0 0 / 300% 100% no-repeat;
  background-position: 150% 0; animation: slot-shine 4s steps(12) infinite;
}
@keyframes slot-shine { 0%, 70% { background-position: 150% 0; } 100% { background-position: -50% 0; } }
@media (prefers-reduced-motion: reduce) { .slot.r-legendary::after { animation: none; } }

.bag-grid { display: grid; grid-template-columns: repeat(6, var(--slot)); gap: 4px; justify-content: center; }
.bag-grid.stash { grid-template-columns: repeat(6, var(--slot)); }
#aucSellGrid { grid-template-columns: repeat(auto-fill, var(--slot)); justify-content: start; max-height: 34vh; overflow-y: auto; overflow-x: hidden; padding: 4px; }
.slot.trash { width: 100%; height: auto; min-height: var(--slot); margin-top: 8px; gap: 8px; color: var(--c-dim); }
.slot.trash img { width: 24px; height: 24px; opacity: 0.6; }
.stash-gold { display: flex; gap: 8px; align-items: center; margin: 12px 0 8px; flex-wrap: wrap; color: var(--c-gold); }
.stash-gold { gap: 6px; }
.stash-gold input { width: 72px; }
.loot-list { display: flex; flex-direction: column; gap: 4px; margin: 8px 0 12px; }
.loot-row { display: flex; gap: 8px; align-items: center; padding: 4px 8px; text-align: left; color: var(--c-text); width: 100%; }
.loot-row:hover { background: var(--c-w1); border-color: var(--c-w4); }
#lootAll { width: 100%; }

/* dymki przedmiotów */
body .eui-tip { max-width: 320px; font-size: 16px; line-height: 1.3; z-index: 70; }
.tip-name { font-size: 18px; }
.tip-sub { color: var(--c-dim); margin-bottom: 4px; }
.tip-affix { color: var(--c-info); }
.tip-fx { color: var(--c-primary); }
.tip-good { color: var(--c-lime); }
.tip-bad { color: var(--c-danger-light); }
.tip-hint { color: var(--c-mute); margin-top: 4px; }
.tip-sep { margin-top: 8px; border-top: 2px solid var(--c-w2); padding-top: 4px; }
.tip-set { color: var(--c-r-set); }
.tip-set-piece, .tip-set-bonus { color: var(--c-mute); }
.tip-set-piece.on { color: var(--c-lime); }
.tip-set-bonus.on { color: var(--c-good); }
.tip-price { color: var(--c-gold); margin-top: 4px; }
.tip-title { display: flex; align-items: center; gap: 4px; }

/* komunikaty (toasty): ciemna ramka slotu; łup z przedmiotem ma ramkę rzadkości i ikonę */
body .eui-toast {
  display: flex; align-items: center; gap: 8px; border: 10px solid transparent; border-image: url(../assets/ui_slot.png) 5 fill / 10px stretch;
  background: none; box-shadow: none; padding: 0 4px; border-radius: 0; font-size: 18px; filter: drop-shadow(3px 3px 0 rgba(14, 7, 27, 0.55));
}
body .eui-toast.loot { padding: 0 4px 0 0; }
body .eui-toast img { flex: 0 0 auto; width: 32px; height: 32px; }

/* ================================================ talenty */
.tal-head { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 12px; }
.tal-milestones { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.tal-ms { display: flex; gap: 8px; align-items: center; padding: 8px; opacity: 0.5; }
.tal-ms.on { opacity: 1; border-color: var(--c-warn); }
.tal-ms small { display: block; color: var(--c-dim); }
.tal-icon { display: flex; justify-content: center; }
.tal-row { display: flex; gap: 12px; align-items: stretch; margin-bottom: 8px; }
.tal-row.locked { opacity: 0.55; }
.tal-tier { width: 96px; display: flex; flex-direction: column; justify-content: center; }
.tal-tier small { color: var(--c-dim); }
.tal-nodes { flex: 1; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.tal-node { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; text-align: center; color: var(--c-text); }
.tal-node small { color: var(--c-dim); }
.tal-node.can { border-color: var(--c-primary-dark); cursor: pointer; }
.tal-node.can:hover { background: var(--c-w1); transform: translateY(-1px); }
.tal-node.part { border-color: var(--c-w3); }
.tal-node.on { border-color: var(--c-good); background: var(--c-w1); }
.tal-node.off:not(.on) { opacity: 0.6; cursor: default; }
.tal-node:disabled { color: inherit; }
.tal-node:disabled.on, .tal-node:disabled.part { opacity: 1; }
.tal-pips { display: flex; gap: 2px; }
.tal-pips i { width: 8px; height: 8px; background: var(--c-g3); border: 2px solid var(--c-outline); }
.tal-pips i.f { background: var(--c-warn); }

/* ================================================ dom aukcyjny, handlarze, ranking */
.tabs { display: flex; gap: 8px; margin: 8px 0 12px; }
.tabs button { flex: 1; font-size: 18px; }
.auc-filters { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.auc-filters input { flex: 1; min-width: 140px; }
.auc-list, .glory-list { display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow-y: auto; overflow-x: hidden; padding-right: 4px; }
.auc-row { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-left: 6px solid var(--rc, var(--c-outline)); }
.auc-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.auc-req { color: var(--c-dim); white-space: nowrap; }
.auc-right { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.auc-right b { display: flex; align-items: center; gap: 4px; color: var(--c-gold); white-space: nowrap; }
.auc-seller { color: var(--c-dim); }
.auc-sell-row { display: flex; gap: 8px; align-items: center; margin: 12px 0 4px; flex-wrap: wrap; }
.auc-sell-row input { width: 112px; }
.auc-foot, .glory-have { margin-top: 8px; color: var(--c-gold); }
.glory-have { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rank-me { margin: 4px 0 8px; color: var(--c-title); }
.rank-list { display: flex; flex-direction: column; gap: 4px; max-height: 55vh; overflow-y: auto; overflow-x: hidden; padding-right: 4px; }
.rank-row { display: grid; grid-template-columns: 40px 1fr auto auto; gap: 8px; padding: 4px 8px; }
.rank-row.me { border-color: var(--c-primary); }
.rank-row small { color: var(--c-dim); }

/* ================================================ telefon trzymany pionowo – prośba o obrócenie */
#rotate {
  position: fixed; inset: 0; z-index: 60; background: var(--c-night); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; color: var(--c-title); font-size: 22px; text-align: center; padding: 16px;
}
#rotate div { font-size: 64px; animation: rot-spin 2s linear infinite; }
@keyframes rot-spin { to { transform: rotate(360deg); } }

/* ================================================ małe ekrany */
@media (max-width: 640px) {
  .title { font-size: 40px; }
  .hud-card { width: 190px; }
  .btn-icon { width: 60px; font-size: 18px; }
  .window { top: 64px; }
  .tal-nodes { grid-template-columns: repeat(3, 1fr); }
  .tal-milestones { grid-template-columns: 1fr; }
  .bag-grid, .bag-grid.stash { grid-template-columns: repeat(auto-fill, var(--slot)); }
  .pf { width: 150px; }
  .class-pick { grid-template-columns: repeat(3, 1fr); }
  .auc-row { flex-wrap: wrap; }
}
@media (max-height: 460px), (max-width: 520px) {
  .char-doll-row { flex-wrap: wrap; gap: 8px; }
  .paperdoll .eq-cell small { display: none; }
  .char-stats { min-width: 120px; }
}

/* ================================================ walka (okno walki: układ i kolory – agent walki; ramki okna i przycisków jak wyżej) */
#combat {
  position: fixed; left: 50%; bottom: 8px; transform: translateX(-50%); z-index: 20; width: min(860px, calc(100vw - 16px));
  padding: 10px 12px 12px;
}
.cb-top { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
#cbRound { color: var(--muted); font-size: 12px; white-space: nowrap; }
#cbTurn { font-weight: 700; white-space: nowrap; }
#cbTurn.mine { color: var(--accent); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.6; } }
.cb-timer { flex: 1; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
#cbTimer { height: 100%; background: var(--accent); transition: width .1s linear; }
#cbTimer.low { background: var(--bad); }
.cb-sides { display: flex; gap: 10px; align-items: center; }
.cb-side { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; }
#cbEnemies { justify-content: flex-end; }
.cb-vs { color: #5d5d5d; font-size: 18px; }
.cb-card {
  position: relative; flex: 0 1 170px; min-width: 120px; padding: 6px 8px; border-radius: 9px; background: #1a1932; border: 2px solid #3d3d3d;
  transition: border-color .15s, transform .15s;
}
#cbEnemies .cb-card { cursor: pointer; }
.cb-card.active { border-color: #f6ca9f; transform: translateY(-2px); }
.cb-card.target { box-shadow: 0 0 0 2px var(--bad) inset; }
.cb-card.me .cb-name span { color: #f9e6cf; }
.cb-card.out { opacity: 0.35; filter: grayscale(1); cursor: default; }
.cb-name { display: flex; justify-content: space-between; gap: 6px; font-size: 13px; font-weight: 600; }
.cb-name small { color: var(--muted); font-weight: 400; }
.cb-status { display: flex; gap: 4px; margin-top: 4px; font-size: 12px; }
.cb-status span { background: rgba(14, 7, 27, 0.4); border-radius: 4px; padding: 0 4px; }
.float { position: absolute; right: 8px; top: -6px; font-weight: 800; font-size: 18px; pointer-events: none; animation: floatUp 1s forwards; text-shadow: 0 2px 3px #0e071b; }
.float.dmg { color: #f5555d; }
.float.heal { color: var(--good); }
@keyframes floatUp { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-26px); opacity: 0; } }
.cb-order { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; min-height: 20px; margin: 8px 0 6px; font-size: 11px; }
.cb-order small { color: var(--muted); margin-right: 2px; }
.chip { padding: 1px 7px; border-radius: 10px; background: #272727; }
.chip.ally { color: #c7cfdd; }
.chip.foe { color: #f6ca9f; }
.cb-bottom { display: flex; gap: 10px; align-items: stretch; }
.cb-actions { display: flex; gap: 6px; flex-wrap: wrap; flex: 0 1 auto; }
.ab-btn {
  position: relative; width: 74px; padding: 6px 2px 4px; display: flex; flex-direction: column; align-items: center; gap: 1px;

}

.ab-btn:disabled { opacity: 0.4; cursor: default; }
.ab-btn.flee { border-color: #5d5d5d; }
.ab-icon { font-size: 22px; line-height: 1.1; }
.ab-name { font-size: 11px; line-height: 1.15; text-align: center; }
.ab-key { position: absolute; left: 5px; top: 3px; font-size: 10px; color: var(--muted); }
.ab-cost { font-size: 10px; color: #e69c69; }
.ab-cd { position: absolute; inset: 0; border-radius: 9px; background: rgba(14, 7, 27, 0.6); display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800; }
.cb-log { flex: 1; min-width: 180px; height: 92px; overflow-y: auto; font-size: 12px; line-height: 1.4; padding: 4px 8px; background: rgba(14, 7, 27, 0.3); border-radius: 8px; user-select: text; }
.cb-log .round { color: #858585; text-align: center; }
.cb-log .mine { color: #f6ca9f; }
.cb-log .bad { color: #f68187; }
.cb-log .good { color: var(--good); }
.cb-log .die { color: #c7cfdd; font-weight: 600; }
#cbBanner {
  position: fixed; left: 50%; top: 30%; transform: translate(-50%, -50%) scale(0.8); z-index: 25; pointer-events: none;
  font-size: 40px; font-weight: 800; text-shadow: 0 3px 12px #0e071b; opacity: 0; transition: opacity .3s, transform .3s;
}
#cbBanner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#cbBanner.win { color: #ffeb57; }
#cbBanner.fled { color: #c7cfdd; }
#cbBanner.dead, #cbBanner.lose { color: #f5555d; }
.cb-card.k-elite { border-color: #bf6f4a; }
.cb-card.k-boss, .cb-card.k-secret { border-color: #bf6f4a; }
.cb-card.k-titan { border-color: #ea323c; box-shadow: 0 0 12px rgba(234, 50, 60, 0.4); }
.cb-card.m { flex-basis: 120px; min-width: 96px; opacity: 0.92; }
.cb-card.ally-sel { box-shadow: 0 0 0 2px var(--good) inset; }
.cb-card.down { opacity: 0.6; filter: grayscale(0.7); cursor: pointer; }
.cb-card.down .cb-name small { color: var(--bad); }
.cb-status span.bad { background: rgba(142, 37, 29, 0.5); }
.cb-status span.good { background: rgba(19, 76, 76, 0.5); }
.ab-btn.ms { border-color: #ffc825; }
.ab-btn.auto { border-color: #657392; }
.ab-btn.auto.on { border-color: #92a1b9; background: #0c2e44; }
.ab-btn.ms { box-shadow: inset 2px 2px 0 rgba(255, 235, 87, 0.25), inset -2px -2px 0 rgba(14, 7, 27, 0.4), 0 0 0 2px #ffc825; }
.ab-btn .ab-icon { height: 26px; display: flex; align-items: center; }
.ab-btn.auto.on { background: #0c2e44; box-shadow: inset 2px 2px 0 rgba(0, 205, 249, 0.33), inset -2px -2px 0 rgba(14, 7, 27, 0.4), 0 0 0 2px #92a1b9; }
.cb-card { border: 2px solid var(--px-dark); background: #1a1932; box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.08), inset -2px -2px 0 rgba(14, 7, 27, 0.35); }
.cb-card.active { box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.08), inset -2px -2px 0 rgba(14, 7, 27, 0.35), 0 0 0 2px #f6ca9f; }
.cb-card.target { box-shadow: inset 0 0 0 2px var(--bad), 0 0 0 2px var(--px-dark); }
.cb-card.ally-sel { box-shadow: inset 0 0 0 2px var(--good), 0 0 0 2px var(--px-dark); }
.cb-status span { display: inline-flex; align-items: center; gap: 2px; padding: 1px 3px; }
.cb-timer { height: 8px; border: 2px solid var(--px-dark); }
.cb-log { border: 2px solid var(--px-dark); box-shadow: inset 2px 2px 0 rgba(14, 7, 27, 0.5); }
.chip { border: 2px solid var(--px-dark); }
.float { font-family: var(--ui-font); font-size: 20px; }

/* ================================================ autopilot w dungeonie */
#pilotBox {
  position: fixed; left: 50%; top: 10px; transform: translateX(-50%); z-index: 9; display: flex; align-items: center; gap: 14px;
  padding: 4px 12px; background: var(--c-w0); border: 2px solid var(--c-outline); color: var(--c-text);
}
#pilotBox b { color: var(--c-title); }
#pilotBox button { padding: 2px 10px; margin: 0; }
#pilotBox button:disabled { opacity: 0.5; }

/* ================================================ umiejętności walki (kolejka auto-walki) */
.lo-help { margin: 0 0 8px; color: var(--c-dim); }
.lo-retreat { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.lo-cols { display: flex; gap: 12px; flex-wrap: wrap; }
.lo-col { flex: 1 1 320px; min-width: 0; }
.lo-col h4 { margin: 0 0 6px; color: var(--c-title); font-weight: 400; }
.lo-list { display: flex; flex-direction: column; gap: 4px; }
.lo-row { display: flex; gap: 8px; align-items: center; padding: 4px 6px; border: 2px solid var(--c-outline); background: var(--c-w0); }
.lo-row.ms { border-color: var(--c-warn); }
.lo-icon { display: flex; flex: 0 0 auto; }
.lo-text { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.lo-text small { color: var(--c-dim); }
.lo-n { color: var(--c-title); min-width: 1.2em; text-align: center; }
.lo-btn { min-width: 30px; padding: 2px 6px; }
.lo-empty { color: var(--c-dim); }
