/* Shared parchment windows and a compact fantasy HUD; loaded after every legacy skin.
   Layout overrides exclude moved controls so the player's saved arrangement still wins. */
:root {
  --parchment: #FFF4D8;
  --surface-highlight: #FFFBEF;
  --ink: #60432D;
  --muted-ink: #8A735B;
  --gold: #D8AC57;
  --gold-highlight: #F4D68A;
  --forest: #47735A;
  --forest-hover: #568B6B;
  --hp: #CE6558;
  --mp: #5A9FD6;
  --qi: #5A9FD6;
  --xp: #B184D5;
  --rarity-common: #B8B0A2;
  --rarity-uncommon: #63A579;
  --rarity-rare: #609BD8;
  --rarity-epic: #A77BD7;
  --rarity-legendary: #D9AD54;
  --paper: var(--parchment);
  --paper-2: #F3E6C8;
  --paper-3: #E2CD9E;
  --ink-soft: var(--muted-ink);
  --wood: #AB864D;
  --wood-dark: var(--ink);
  --gold-dark: #A67B35;
  --green: var(--forest-hover);
  --green-dark: var(--forest);
  --green-light: #D9E9CE;
  --blue: var(--qi);
  --red: var(--hp);
  --red-dark: #923E33;
  --hud-ink: #FFF4D8;
  --hud-muted: #DDCBA9;
  --hud-plate: linear-gradient(145deg, #49372BEF, #241D19DE);
  --frame: 2px solid var(--gold);
  --inner-line: inset 0 0 0 1px #F4D68A88;
  --soft-shadow: 0 12px 40px #261A1938, 0 3px 8px #261A1926;
  --radius: 14px;
  --gap: 14px;
  --pvp-gold: var(--gold);
  --pvp-gold-dark: var(--gold-dark);
  --pvp-ink: #2E241F;
}

/* Every ordinary window shares this frame, including the existing inventory shell. */
#modal { padding: 28px; background: #241C1666; }
#modal .panel, .bigmap, #title .sheet, #offline .sheet,
.job-sheet-card, .sb .sb-sheet-card, .pvp-res, .ffa-res,
.flag-defeat-card, .ffa-ko-card, .hudbar {
  position: relative;
  border: var(--frame);
  border-radius: var(--radius);
  background: radial-gradient(ellipse at 50% 0, var(--surface-highlight), transparent 65%), var(--parchment);
  color: var(--ink);
  box-shadow: var(--inner-line), var(--soft-shadow);
}
#modal .panel { width: min(920px, 100%); max-height: min(850px, calc(100dvh - 56px)); }
#modal .panel.narrow { width: min(520px, 100%); }
#modal .panel::before, #modal .panel::after, #title .sheet::before, #offline .sheet::before {
  content: ''; position: absolute; z-index: 4; pointer-events: none;
  width: 108px; height: 88px; background: url('../assets/ui/floral-corner.svg') top left / contain no-repeat;
}
#modal .panel::before, #title .sheet::before, #offline .sheet::before { top: 0; left: 0; }
#modal .panel::after { bottom: 0; right: 0; transform: rotate(180deg); opacity: .7; }
#modal .panel > header, #modal .inventory-v2 .top, .bigmap > header {
  position: relative; flex: none; display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px 12px; min-height: 96px; padding: 22px 64px 14px 38px;
  border: 0; border-bottom: 1px solid var(--gold); background: transparent; color: var(--ink);
}
#modal .panel > header::before {
  content: ''; position: absolute; width: 120px; height: 30px; top: -2px; left: calc(50% - 60px);
  background: url('../assets/ui/star-crest.svg') center / contain no-repeat; pointer-events: none;
}
#modal .inventory-v2 .top::after { display: none; }
#modal .panel h1, #modal .panel h2, .bigmap header b {
  font-family: 'Mitr', var(--font); font-size: 23px; line-height: 1.4; text-shadow: none; color: var(--ink);
}
#modal .panel-heading { flex: 1; min-width: 0; }
#modal .panel-heading h2 { margin: 0; }
#modal .panel-subtitle { display: block; font-size: 12px; color: var(--muted-ink); margin-top: 4px; }
#modal .panel > header .purse, #modal .inventory-v2 .money {
  background: #E9D7AE66; color: var(--ink); border: 1px solid var(--gold); border-radius: 999px;
}
#modal .panel .close, #modal .inventory-v2 .x, .bigmap .close {
  position: absolute; top: 14px; right: 14px; width: 44px; height: 44px;
  display: grid; place-items: center; flex: none; padding: 0;
  border: 2px solid var(--gold); border-radius: 50%; background: #3B2C24;
  box-shadow: inset 0 0 0 2px #211A15, 0 2px 6px #3D291B38; color: var(--gold-highlight); font-size: 22px;
}
#modal .panel .close:hover, #modal .inventory-v2 .x:hover { background: var(--ink); }
#modal .panel .body { min-height: 0; padding: 20px 24px; scrollbar-color: var(--gold) var(--paper-2); scrollbar-width: thin; }
#modal .panel > footer, #modal .ui7-footer { flex: none; padding: 10px 112px 10px 24px; border-top: 1px solid var(--gold); background: #F0DFB766; font-size: 12px; color: var(--muted-ink); }
#modal .panel .tabs, #modal .inventory-v2 .top .tabs {
  flex: none; display: flex; flex-wrap: nowrap; gap: 6px; width: 100%; margin: 0;
  padding: 8px 16px; border: 0; border-bottom: 1px solid var(--gold); background: #EBDAB355;
  overflow-x: auto; scrollbar-width: thin; touch-action: pan-x;
}
#modal .inventory-v2 .top .tabs { order: 5; margin: 6px -20px -14px; width: calc(100% + 40px); }
#modal .panel .tabs button, #modal .inventory-v2 .tab {
  flex: 1 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 6px 14px; margin: 0; border: 1px solid #C9AD77; border-radius: 12px;
  background: var(--surface-highlight); color: var(--ink); font-size: 14px; opacity: 1; box-shadow: none;
}
#modal .panel .tabs .on, #modal .inventory-v2 .tab.on {
  border-color: var(--gold-dark); background: linear-gradient(#F4D68A, #DDB56B); box-shadow: inset 0 0 0 1px #FFF4D8;
}
#modal .panel .tabs .icon { width: 24px; height: 24px; }
#modal .panel .btn, #modal .inventory-v2 button.btn, .pet-v2-controls .btn, #title .btn {
  min-height: 44px; padding: 8px 16px; border: 1px solid var(--gold-dark); border-radius: 12px;
  background: linear-gradient(var(--surface-highlight), #EEDDB8);
  color: var(--ink); box-shadow: inset 0 0 0 1px #FFFBEF88, 0 2px 4px #60432D20;
  font-weight: 700; text-shadow: none;
}
#modal .panel .btn.green, #modal .inventory-v2 button.btn.green, #title .btn.green {
  background: linear-gradient(var(--forest-hover), var(--forest)); color: var(--surface-highlight); border-color: var(--gold);
}
#modal .panel .btn.gold, #modal .inventory-v2 button.btn.gold { background: linear-gradient(var(--gold-highlight), var(--gold)); }
#modal .panel .btn:hover:not(:disabled), #title .btn:hover:not(:disabled) { filter: brightness(1.07); }
#modal button:active:not(:disabled), #hud button:active:not(:disabled) { filter: brightness(.92); }
#modal button:disabled, #hud button:disabled { opacity: .55; filter: saturate(.35); cursor: not-allowed; }
button:focus-visible, [role='button']:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--gold-highlight); outline-offset: 3px;
}
#modal :is(input, select, textarea), #title input {
  min-height: 44px; border: 1px solid #BC9E66; border-radius: 10px;
  background: var(--surface-highlight); color: var(--ink); font: inherit; max-width: 100%;
}
#modal :is(.item, .cell, .surface, .skill-book-card, .job-node, .profession-card, .wm-info, .questrow),
#modal .sb :is(.sb-loadout, .sb-card, .sb-slot, .sb-facts), #modal .pets3 :is(.pets3-detail, .pets3-box, .pets3-skill) {
  border-radius: 12px; background-color: var(--surface-highlight); box-shadow: 0 2px 6px #60432D12;
}
#modal .hint, #modal .sub { color: var(--muted-ink); }
#modal .panel small { font-size: 12px; }
#modal .inventory-v2 :is(.ibtn, .close-popover) { min-width: 44px; min-height: 44px; }
#modal :is(.error, .bad, .short, [role='alert']) { color: var(--red-dark); }
#modal :is(.empty, .unknown) { border-style: dashed; color: var(--muted-ink); }
#modal [aria-busy='true'] { cursor: progress; opacity: .7; }

/* The existing three-column bag, doll, sheets and gestures retain their layout. */
#modal .inventory-v2 {
  --ink: #60432D; --ink-2: #8A735B; --ink-3: #A38C71; --gold: #D8AC57;
  --forest: #47735A; --forest-2: #568B6B; --cream: #FFFBEF; --cream-2: #FFF4D8;
  --bg: var(--parchment); --panel: var(--surface-highlight); --line: var(--paper-3);
  --text: var(--ink); --muted: var(--muted-ink); --accent: var(--forest); --f-ui: var(--font);
}
#modal .inventory-v2.win { position: relative; inset: auto; display: flex; flex-direction: column; width: min(1480px, 100%); height: min(900px, calc(100dvh - 56px)); }
#modal .inventory-v2 .back { min-width: 44px; min-height: 44px; color: var(--ink); }
#modal .inventory-v2 .brand { flex: 1; }
#modal .inventory-v2 .brand-ic { background: #F0D9A1; box-shadow: none; border: 1px solid var(--gold); }
#modal .inventory-v2 .top { padding-left: 32px; }
#modal .inventory-v2 :is(.chip, .sort, .spin, .view-toggle, .sb-chip, .sb-x) { min-height: 44px; min-width: 44px; }
#modal .inventory-v2 .chip.on, #modal .inventory-v2 .sb-chip.on { background: var(--forest); color: var(--surface-highlight); }
#modal .inventory-v2 .card { border-radius: 12px; }
#modal .inventory-v2 .card.selected, #modal .inventory-v2 .card.on { outline-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-highlight); }
#modal .inventory-v2 .detail { background: var(--surface-highlight); }
#modal :is(.r0, .rarity-art.r0) { --rarity: var(--rarity-common); border-color: var(--rarity-common); }
#modal :is(.r1, .rarity-art.r1) { --rarity: var(--rarity-uncommon); border-color: var(--rarity-uncommon); }
#modal :is(.r2, .rarity-art.r2) { --rarity: var(--rarity-rare); border-color: var(--rarity-rare); }
#modal :is(.r3, .rarity-art.r3) { --rarity: var(--rarity-epic); border-color: var(--rarity-epic); }
#modal :is(.r4, .rarity-art.r4) { --rarity: var(--rarity-legendary); border-color: var(--rarity-legendary); }
#modal .pets3 :is(.pets3-chip, .pets3-food, .pets3-help-btn) { min-height: 44px; }

/* Class art comes from real professions; missing crops use the shipped portraits. */
#modal .panel:has(.profession-book) { width: min(1120px, 100%); }
.profession-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.profession-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px;
  border: 2px solid #C7A267; background: linear-gradient(var(--surface-highlight), #F4E7C9);
  box-shadow: inset 0 0 0 1px var(--gold-highlight), 0 4px 12px #60432D18;
}
.profession-card h4 { width: 100%; padding: 8px; margin: 0; border-bottom: 1px solid var(--gold); font: 500 19px 'Mitr', var(--font); }
.profession-card .profession-portrait { width: 100%; height: 230px; object-fit: contain; image-rendering: auto; }
.profession-card .hero-fallback { image-rendering: pixelated; }
.profession-card small { font-size: 12px; }
.profession-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; font-size: 12px; }
.profession-stats span { padding: 3px 7px; border: 1px solid var(--paper-3); border-radius: 999px; background: var(--parchment); }
.profession-weapon { display: grid; justify-items: center; gap: 4px; width: 100%; padding: 10px; border: 1px solid var(--gold); border-radius: 12px; background: #FFF4D8; font-size: 13px; }
.profession-weapon i { width: 48px; height: 48px; background-position: center; background-size: contain; background-repeat: no-repeat; image-rendering: pixelated; }
.profession-card p { margin: 0; min-height: 2.8em; }
.profession-card .btn { margin-top: auto; min-height: 46px; background: linear-gradient(var(--forest-hover), var(--forest)) !important; color: var(--surface-highlight) !important; }
.profession-card[data-current='true'] { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold-highlight), 0 0 0 2px var(--gold), 0 0 18px #D8AC5760; }
.hero-art { object-fit: contain; image-rendering: auto; }
.job-portrait.hero-art { width: 100%; max-width: 100px; height: 130px; }
#modal .list:has(.class-choice) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
#modal .class-choice { display: flex; flex-direction: column; align-items: center; padding: 14px; border: var(--frame); text-align: center; }
#modal .class-choice-art { height: 210px; max-width: 100%; }
#modal .class-choice .sub { justify-content: center; }
#modal .class-choice.here { box-shadow: 0 0 0 2px var(--gold-highlight), 0 0 14px #D8AC5766; }

/* Dark, translucent HUD plates let the village show through. */
#hud :is(.card.me, .quest, .place, .clock, .target, .party, .homebar, .flag-board),
#hud .hotbar, #hud .pet-status, #hud .chat form button, #hud .hero-menu button, #hud-toggle {
  border: 1px solid #D8AC57BB; border-radius: 12px; background: var(--hud-plate);
  color: var(--hud-ink); box-shadow: inset 0 0 0 1px #F4D68A20, 0 4px 14px #1F140F30;
}
#hud #me-card { width: 300px; max-width: none; min-width: 0; padding: 10px 12px 8px 88px; display: block; }
#hud #me-face {
  position: absolute; left: 10px; top: 12px; width: 68px; height: 68px; border-radius: 50%;
  border: 3px solid var(--gold); outline: 1px solid #F4D68A; background: radial-gradient(circle, #A4BBA1, #354941);
  box-shadow: inset 0 0 0 2px #453124, 0 3px 8px #0005; overflow: hidden; padding: 0;
}
#me-face .hero-art { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 20%; }
#me-face .hero-fallback { object-fit: contain; image-rendering: pixelated; }
#hud #me-level { position: absolute; left: 5px; top: 63px; min-width: 30px; height: 28px; border: 2px solid var(--gold); border-radius: 50%; background: #3B2C24; color: var(--gold-highlight); font-size: 12px; }
#hud .class-emblem { position: absolute; left: 55px; top: 63px; width: 44px; height: 44px; border: 2px solid var(--gold); border-radius: 50%; background: #3B2C24; padding: 0; }
#hud .who { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
#hud .who .row { order: 0; min-height: 23px; padding: 1px 8px; background: #201A16AA; border-radius: 7px; }
#hud .who .name { font-size: 15px; }
#hud .who .hp { order: 1; }
#hud .who .wuxia-qi-bar { order: 2; }
#hud .who .farm { order: 3; }
#hud .who .adv { order: 4; }
#hud .who :is(.sick, .vigor) { order: 5; }
#hud .coins { margin-top: 4px; color: var(--gold-highlight); font-size: 14px; justify-content: flex-end; }
.bar, #hud .wuxia-qi-bar { border: 1px solid #1D1713; border-radius: 999px; background: #231D19; box-shadow: 0 0 0 1px #BD995755, inset 0 2px 4px #0007; }
#hud .me .bar { margin: 1px 0; height: 15px; }
.bar i { background: linear-gradient(#B1C68D, var(--forest-hover)); }
.bar.adv i { background: linear-gradient(#D6B7ED, var(--xp)); }
.bar.hp i, .bossbar .bar i { background: linear-gradient(#EB9B86, var(--hp)); }
#hud .me .hp { height: 20px; }
#hud .me .bar span { font-size: 12px; line-height: 1; }
#hud .wuxia-qi-bar { display: block; position: relative; height: 20px; overflow: hidden; margin: 1px 0; }
#hud .wuxia-qi-bar i { display: block; width: calc(var(--qi, 1) * 100%); height: 100%; background: linear-gradient(#9ACAEA, var(--mp)); }
#hud .qi-text { position: absolute; inset: 0; display: grid; place-items: center; color: #FFFBEF; font-size: 12px; text-shadow: 0 1px 2px #10212C; }
#hud #quest { width: 300px; max-width: 300px; padding: 46px 12px 10px; border-left: 3px solid var(--gold); }
#hud #quest small { color: var(--hud-muted); font-size: 12px; }
#hud #quest .reward { color: var(--gold-highlight); font-size: 12px; }
.quest-toggle { position: absolute; top: 0; left: 0; right: 0; width: 100%; min-height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 4px 14px; border: 0; border-bottom: 1px solid #D8AC5766; color: var(--gold-highlight); background: transparent; font-weight: 700; }
.quest-toggle i { width: 8px; height: 8px; border-right: 2px solid var(--gold); border-bottom: 2px solid var(--gold); transform: rotate(45deg); }
#hud #quest.folded { height: 44px; min-height: 44px; padding: 0; }
#quest.folded > :not(.quest-toggle) { display: none; }
#quest.folded .quest-toggle { border: 0; }
#quest.folded .quest-toggle i { transform: rotate(-45deg); }
#hud #place { max-width: 260px; overflow: hidden; text-overflow: ellipsis; padding: 5px 18px; font-size: 13px; }
#hud #clock { top: calc(var(--safe-t) + 96px); font-size: 12px; padding: 4px 12px; }
#hud #menu { gap: 8px; }
#hud #menu button {
  width: 60px; min-height: 68px; padding: 6px 0; border: 0; border-radius: 0;
  background: transparent; box-shadow: none; color: #FFFBEF; font-size: 12px; text-shadow: 0 1px 3px #1F1711, 1px 1px 2px #1F1711;
}
#hud #menu button > .icon { width: 40px; height: 40px; padding: 4px; border: 2px solid var(--gold); border-radius: 50% 50% 40% 40%; background: radial-gradient(circle at 40% 30%, #93734A, #35281E); box-shadow: 0 2px 0 #1F1711, inset 0 0 0 1px #F4D68A88; }
#hud .badge { border: 1px solid var(--gold); top: 0; right: 0; }
#hud .hero-menu { right: calc(var(--gap) + var(--safe-r)); top: calc(var(--safe-t) + 136px); display: flex; gap: 8px; }
#hud .hero-menu button { min-width: 60px; min-height: 44px; display: flex; align-items: center; gap: 4px; padding: 4px 8px; font-size: 12px; }
#hud-toggle { top: calc(var(--safe-t) + 92px); right: calc(var(--safe-r) + 170px); width: 44px; height: 44px; padding: 0; }
/* (the fold button: a gold chevron, pointing down once the HUD is folded; not a second settings gear) */
#hud-toggle .fold-glyph { display: block; font-size: 24px; line-height: 1; color: var(--gold-highlight); transition: transform .15s; }
#hud-toggle[aria-expanded="false"] .fold-glyph { transform: rotate(180deg); }

/* The real skill buttons form a centred row. All cooldown/gauge markup stays intact. */
body #hud #skills {
  --orb: 58px; left: 0; right: 0; margin-inline: auto; bottom: calc(var(--safe-b) + 88px); transform: none;
  width: max-content; max-width: calc(100vw - 36px); height: auto; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
  padding: 10px 16px 16px; border: 1px solid #D8AC5788; border-radius: 40% 40% 18px 18px;
  background: var(--hud-plate); box-shadow: 0 6px 18px #1F140F40; pointer-events: none;
}
body #hud #skills button:not([data-moved]) { position: relative; inset: auto; flex: none; width: var(--orb); height: var(--orb); margin: 0; }
body #hud #skills button { border: 2px solid var(--gold); border-radius: 50%; background: radial-gradient(circle at 40% 30%, #6D655D, #2A282A 70%); box-shadow: inset 0 0 0 2px #F4D68A55, 0 3px 6px #0005; }
body #hud #skills .attack { background: radial-gradient(circle at 40% 30%, #B18A51, #513529 70%); }
body #hud #skills .skill.ult::before, body #hud #skills .skill.ult.ready::after { display: none; }
body #hud #skills .skill.ult.ready { border-color: var(--gold-highlight); box-shadow: 0 0 15px #F4D68A99, inset 0 0 0 2px #F4D68A55; }
body #hud #skills .skill.locked, body #hud #skills .no-qi { border-color: var(--rarity-common); filter: saturate(.3); }
body #hud #skills .skill .cd { inset: 4px; background: conic-gradient(#160F0DD9 calc(var(--cd, 0) * 360deg), transparent 0); }
body #hud #skills .skill small, body #hud #skills .skill .k { bottom: -8px; min-width: 24px; min-height: 18px; border: 1px solid var(--gold); border-radius: 999px; background: #2D231E; color: var(--gold-highlight); font-size: 12px; line-height: 18px; }
/* (roll, bash and guard carry a name as well as a key: the key rides the top edge, the name the bottom one;
   pvp.css pins their key to the top, so a bottom pin alone stretched it into a tall dark bar over the picture) */
body #hud #skills .pvp-move .k, body #hud #skills .wuxia-guard .k {
  position: absolute; z-index: 5; top: -9px; bottom: auto; left: 50%; right: auto; transform: translateX(-50%);
  height: 18px; min-height: 0; padding: 0 6px; font: 700 11px/16px var(--font); white-space: nowrap; }
body #hud #skills .pvp-move small, body #hud #skills .wuxia-guard small {
  position: absolute; z-index: 5; bottom: -9px; left: 50%; right: auto; transform: translateX(-50%); padding: 0 7px; white-space: nowrap; }
#hud #hotbar:not([data-moved]) { bottom: calc(var(--safe-b) + 14px); max-width: min(560px, 45vw); }
#hud #hotbar[data-moved] { transform: none; }
#hud .slot { width: 48px; height: 48px; border: 1px solid #C7A267; background: radial-gradient(circle, #6C614D, #332A23); box-shadow: inset 0 0 0 1px #F4D68A44; }
#hud .slot.on { border-color: var(--gold-highlight); box-shadow: 0 0 0 2px var(--gold), inset 0 0 8px #F4D68A66; }
#hud .slot :is(.n, .key) { font-size: 12px; }
#hud #chat { width: min(290px, 23vw); }
#hud #chat .log { max-height: 120px; font-size: 12px; }
#hud #chat form button { width: 44px; height: 44px; }
#hud #chat.open { z-index: 8; }
#hud #chat.open .log { overflow-y: auto; pointer-events: auto; mask-image: none; }
#hud #chat.open input { min-height: 44px; border: 1px solid var(--gold); background: var(--parchment); color: var(--ink); }
#hud #chat:not(.open) .log { visibility: hidden; }
#hud #chat.open { width: min(360px, calc(100vw - 28px)); }

/* Keep the full rectangular map inside the compass: no map positions get clipped. */
#hud #minimap:not([data-moved]) { top: auto; bottom: calc(var(--safe-b) + 66px); right: calc(var(--safe-r) + 24px); width: 168px; height: 168px; }
#hud #minimap { width: 168px; height: 168px; padding: 22px; border: 4px solid var(--gold); border-radius: 50%; background: radial-gradient(circle, #3A4834 50%, #31261D 51%); overflow: visible; box-shadow: inset 0 0 0 2px var(--gold-highlight), 0 0 0 2px #493222, 0 5px 14px #0005; }
#hud #minimap::before { content: 'N'; position: absolute; top: 1px; left: calc(50% - 6px); color: var(--gold-highlight); font: 600 14px 'Mitr', var(--font); pointer-events: none; }
#hud #minimap canvas { width: 100%; height: 100%; border-radius: 8px; border: 1px solid #D8AC5788; }
#hud #minimap .mm-close { top: -6px; right: -10px; width: 44px; height: 44px; border: 1px solid var(--gold); background: #35281E; color: var(--gold-highlight); }
.minimap-plate { position: absolute; left: -20px; right: -20px; top: calc(100% + 8px); display: grid; justify-items: center; gap: 2px; padding: 5px 8px; border: 1px solid var(--gold); border-radius: 10px; background: var(--hud-plate); color: var(--hud-ink); font-size: 12px; pointer-events: none; }
.minimap-plate small { color: var(--hud-muted); font-size: 12px; }
body #hud .pet-v2-controls { right: calc(var(--safe-r) + 14px); left: auto; bottom: calc(var(--safe-b) + 258px); max-width: 210px; gap: 6px; }
#hud .pet-status { display: grid; grid-template-columns: 38px 1fr; align-items: center; gap: 6px; padding: 6px; text-align: left; width: 100%; min-height: 56px; font-size: 12px; }
.pet-status > div { display: grid; gap: 3px; min-width: 0; }
.pet-status b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pet-status small { color: var(--hud-muted); font-size: 12px; }
#hud .pet-v2-controls .btn { padding: 5px 8px; background: var(--hud-plate); color: var(--hud-ink); font-size: 12px; }
#hud .pet-v2-controls .pet-v2-active small { font-size: 12px; }
#hud .worldboss { border: 1px solid var(--gold); border-radius: 12px; }
#hud .target { color: var(--hud-ink); }
#hud .target .finds, #hud .target em { color: var(--gold-highlight); }
#hud.compact :is(#quest, #menu, #clock, .hero-menu, #place) { display: none; }
#hud.compact #me-card .who > :not(.row):not(.hp):not(.wuxia-qi-bar) { display: none; }

#title { background: radial-gradient(ellipse at 50% 30%, #B9C6A055, #253C2AC9); }
#title .sheet { padding: 36px; }
#title h1 { color: var(--forest); text-shadow: 0 2px 0 #FFFBEF; }
#title h1 em { color: var(--gold-dark); }
.toast { border: 1px solid var(--gold); box-shadow: var(--soft-shadow); border-radius: 12px; }
.pvp-res :is(.res-why, .res-stats, .res-ask), .ffa-res :is(.ffa-res-title, small), .flag-defeat-card :is(span, small) { color: var(--ink); }
.pvp-res .btn, .ffa-res .btn, .flag-defeat-card .btn { min-height: 44px; border: 1px solid var(--gold); border-radius: 12px; }
.pvp-res .btn.green, .ffa-res .btn.green { background: var(--forest); color: var(--surface-highlight); }
.ui7-tooltip { position: fixed; z-index: 100; max-width: min(300px, calc(100vw - 16px)); display: grid; gap: 5px; padding: 10px 14px; border: 1px solid var(--gold); border-radius: 12px; background: #30251FF5; color: var(--hud-ink); font-size: 12px; line-height: 1.6; box-shadow: var(--soft-shadow); pointer-events: none; }
.ui7-tooltip b { color: var(--gold-highlight); }

@media (max-width: 1100px) {
  #hud #menu { gap: 2px; }
  #hud #menu button { width: 52px; }
  #hud #place { top: calc(var(--safe-t) + 112px); max-width: 230px; }
  body #hud #skills { --orb: 50px; gap: 7px; }
  #hud #chat { width: 210px; }
}
@media (max-width: 700px) {
  :root { --gap: 8px; }
  #modal { padding: 0; }
  #modal .panel, #modal .panel.narrow, #modal .inventory-v2.win { position: relative; inset: auto; width: 100%; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  #modal .panel > header, #modal .inventory-v2 .top { min-height: 92px; padding: calc(20px + var(--safe-t)) 60px 10px 20px; }
  #modal .panel h1, #modal .panel h2 { font-size: 20px; }
  #modal .panel .body { padding: 12px; }
  #modal .panel::before, #modal .panel::after { width: 70px; height: 58px; opacity: .55; }
  #modal .panel > footer { padding-bottom: calc(10px + var(--safe-b)); }
  #modal .inventory-v2 .brand-ic, #modal .inventory-v2 .back { display: none; }
  #modal .panel .tabs button { flex: none; padding-inline: 12px; }
  #modal .inventory-v2 .top .tabs { margin-inline: -12px; width: calc(100% + 24px); }
  #modal .inventory-v2 .money { font-size: 12px; }
  #modal .list:has(.class-choice) { grid-template-columns: minmax(0, 1fr); }
  #hud #me-card { top: calc(var(--safe-t) + 8px); left: calc(var(--safe-l) + 8px); width: 228px; padding: 6px 8px 6px 64px; }
  #hud #me-face { width: 48px; height: 48px; top: 10px; left: 8px; }
  #hud #me-level { left: 2px; top: 49px; font-size: 12px; height: 24px; }
  #hud .class-emblem { left: 30px; top: 54px; }
  #hud .who .name { font-size: 13px; }
  #hud #quest { width: 228px; max-width: 228px; font-size: 12px; }
  #hud #quest > .icon, #hud #quest .reward { display: none; }
  #hud #menu { top: calc(var(--safe-t) + 8px); right: calc(var(--safe-r) + 8px); display: grid; grid-template-columns: repeat(2, 48px); gap: 2px; }
  #hud #menu button { width: 48px; min-height: 54px; font-size: 12px; padding: 0; }
  #hud #menu button > .icon { width: 32px; height: 32px; padding: 2px; }
  #hud #clock { top: calc(var(--safe-t) + 238px); right: calc(var(--safe-r) + 8px); padding: 4px; }
  #hud #clock .sky { display: none; }
  #hud-toggle { top: calc(var(--safe-t) + 238px); right: calc(var(--safe-r) + 100px); }
  #hud .hero-menu { top: calc(var(--safe-t) + 288px); right: calc(var(--safe-r) + 8px); gap: 4px; }
  #hud .hero-menu button { min-width: 44px; padding: 4px; }
  #hud .hero-menu span { display: none; }
  #hud #place { top: calc(var(--safe-t) + var(--me-h, 140px) + var(--quest-h, 80px) + 24px); left: calc(var(--safe-l) + 8px); max-width: 210px; transform: none; font-size: 12px; }
  body #hud #skills { --orb: 46px; width: calc(100% - 24px); max-width: 420px; gap: 8px; padding: 8px 8px 15px; bottom: calc(var(--safe-b) + 14px); border-radius: 16px; }
  body #hud #skills button:not([data-moved]) { width: var(--orb); height: var(--orb); }
  #hud #hotbar:not([data-moved]) { bottom: calc(var(--safe-b) + 14px); max-width: calc(100vw - 130px); }
  body.fighting #hud #hotbar:not([data-moved]) { bottom: calc(var(--safe-b) + 142px); left: auto; right: calc(var(--safe-r) + 8px); transform: none; max-width: calc(100vw - 140px); }
  body #hud #minimap:not([data-moved]) { width: 108px; height: 108px; bottom: calc(var(--safe-b) + 368px); right: calc(var(--safe-r) + 12px); }
  #hud #minimap { width: 108px; height: 108px; padding: 16px; }
  #hud #minimap .mm-close { right: -8px; top: -14px; }
  .minimap-plate { left: -12px; right: -12px; padding: 4px; }
  body #hud .pet-v2-controls { top: auto; right: auto; left: calc(var(--safe-l) + 8px); bottom: calc(var(--safe-b) + 354px); width: 174px; max-width: 174px; flex-direction: column; }
  #hud #joystick:not([data-moved]) { bottom: calc(var(--safe-b) + 100px); width: 108px; height: 108px; }
  body.fighting #hud #joystick:not([data-moved]) { bottom: calc(var(--safe-b) + 226px); }
  #hud .pet-status { grid-template-columns: 28px 1fr; gap: 3px; padding: 4px; }
  #hud .pet-status img { width: 28px; height: 28px; }
  #hud .pet-v2-controls .pet-v2-active small { display: none; }
  body #hud #target { top: auto; bottom: calc(var(--safe-b) + 266px); left: auto; right: 8px; width: calc(100vw - 140px); transform: none; }
  body #hud #bossbar { top: auto; bottom: calc(var(--safe-b) + 210px); left: auto; right: 8px; width: calc(100vw - 140px); transform: none; }
  #hud #chat { bottom: calc(var(--safe-b) + 226px); width: 44px; }
  body.fighting #hud #chat { bottom: calc(var(--safe-b) + 142px); }
  #hud #chat.open { width: calc(100vw - 16px); }
  body.stick-right #hud #target, body.stick-right #hud #bossbar { left: 8px; right: auto; }
  body.stick-right.fighting #hud #hotbar:not([data-moved]) { left: 8px; right: auto; }
  body.stick-right #hud #chat { left: auto; right: 8px; }
  #hud #chat .log { max-height: 90px; }
  .profession-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .profession-card { padding: 8px; }
  .profession-card .profession-portrait { height: 170px; }
  .profession-card h4 { font-size: 16px; }
  .profession-card small { font-size: 12px; }
  #title .sheet { padding: 24px; }
}
/* Short landscape reserves both ends for the existing thumb stick and minimap. */
@media (max-height: 520px) and (orientation: landscape) {
  :root { --gap: 8px; }
  #modal { padding: 0; }
  #modal .panel, #modal .panel.narrow, #modal .inventory-v2.win { width: 100%; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  #modal .panel > header, #modal .inventory-v2 .top { min-height: 72px; padding-block: 14px 8px; }
  #modal .panel-subtitle { display: none; }
  #hud #me-card { width: 184px; padding: 6px 8px 6px 62px; }
  #hud #me-face { width: 46px; height: 46px; left: 8px; top: 10px; }
  #hud #me-level { top: 48px; left: 2px; }
  #hud .class-emblem { left: 28px; top: 54px; }
  #hud #menu { gap: 0; }
  #hud #menu { display: flex; }
  #hud #menu button { width: 48px; min-height: 56px; }
  #hud #menu button > .icon { width: 32px; height: 32px; }
  #hud #quest { max-width: 184px; width: 184px; }
  #hud #place { top: calc(var(--safe-t) + 8px); max-width: 180px; }
  #hud #clock { top: calc(var(--safe-t) + 70px); }
  #hud .hero-menu { top: calc(var(--safe-t) + 108px); }
  #hud-toggle { top: calc(var(--safe-t) + 70px); }
  body #hud #skills { --orb: 44px; gap: 6px; max-width: calc(100vw - 320px); bottom: calc(var(--safe-b) + 8px); padding: 6px 8px 14px; border-radius: 16px; }
  #hud #hotbar:not([data-moved]), body.fighting #hud #hotbar:not([data-moved]) { bottom: calc(var(--safe-b) + 146px); max-width: 300px; }
  body #hud #minimap:not([data-moved]) { width: 108px; height: 108px; bottom: auto; top: calc(var(--safe-t) + 8px); }
  #hud #minimap { width: 108px; height: 108px; padding: 16px; }
  body #hud .pet-v2-controls:not([data-moved]) { bottom: auto; top: calc(var(--safe-t) + 8px); right: auto; left: calc(50% - 120px); width: 240px; max-width: 240px; flex-direction: row; }
  #hud .pet-v2-controls .pet-status { display: none; }
  #hud .pet-v2-controls .pet-v2-guard { position: absolute; top: 100%; width: 100%; }
  #hud .pet-v2-controls .pet-v2-active small { display: none; }
  #hud #chat { bottom: calc(var(--safe-b) + 180px); width: 44px; }
  #hud #chat.open { width: 300px; }
  body #hud #joystick:not([data-moved]) { bottom: calc(var(--safe-b) + 8px); width: 108px; height: 108px; }
  body.fighting #hud #target, body.fighting #hud #bossbar { left: 50%; right: auto; width: min(330px, 42vw); transform: translateX(-50%); }
  body.fighting #hud #target { bottom: calc(var(--safe-b) + 210px); }
  body.fighting #hud #bossbar { bottom: calc(var(--safe-b) + 266px); }
}
@media (prefers-reduced-motion: reduce) {
  #hud *, #hud *::before, #hud *::after, #modal *, #modal *::before, #modal *::after,
  #title *, #offline *, #bigmap *, .job-sheet *, .sb-sheet *, .ui7-tooltip, .toast {
    animation: none !important; transition: none !important; scroll-behavior: auto !important;
  }
  .pvp-result *, .ffa-end *, .flag-defeat *, .ffa-ko *, .hudedit * { animation: none !important; transition: none !important; }
}
