/* 1.0.100: existing UI layout and shared brown/gold controls. No new art. */
:root { --nx200-slot-radius: 7px; --nx200-control-radius: 8px; }

/* MAP4 labels hug their text; keep the existing position and house colours. */
#game .map4-service-prompt {
  min-width: 0;
  width: max-content;
  max-width: min(92vw, 420px);
  padding: 8px 10px;
  gap: 6px;
}
#game .map4-service-prompt > button { padding: 6px 12px; min-height: 34px; }
#game #nx200ForgeServices[hidden] { display: none !important; }
#game #nx200ForgeServices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
#game #nx200ForgeServices button { min-width: 0; min-height: 36px; padding: 5px 8px; white-space: nowrap; }
#game #sitButton { color: #fff; }
#game #sitButton .nx200-sit-icon { width: 100%; height: 100%; fill: none; filter: none; }

/* The same rounded square for bags, worn equipment and placement slots. */
.nx108-root :is(.nx108-inventory-cell, .nx108-equip-slot, .nx108-forge-slot, .nx108-trade-slot, .nx108-item-icon-frame, .nx108-skill-shortcut-slots > button),
#nexoriaCharacterPanel :is(.nx108-inventory-cell, .nx108-equip-slot) {
  border-radius: var(--nx200-slot-radius);
  overflow: hidden;
}
#nexoriaCharacterPanel .nx108-equip-slot {
  border: 1px solid color-mix(in srgb, var(--rarity, #cfb174) 56%, #66461f);
  background-image: linear-gradient(145deg, rgba(62, 41, 20, .92), rgba(18, 12, 6, .98));
}
.nx108-root .nx108-forge-slot { background: rgba(38, 24, 14, .96); box-shadow: inset 0 0 16px rgba(150, 89, 174, .13); }
.nx108-root .nx196-inherit-selected { width: 100px; height: auto; aspect-ratio: 1; display: flex; flex-direction: column; justify-content: center; gap: 3px; }
.nx108-root .nx196-inherit-selected img { width: 60%; height: 60%; object-fit: contain; }
.nx108-root .nx196-inherit-selected span { font-size: .6rem; }
.nx108-root :is(.nx108-primary, .nx108-tabs button, .nx108-forge-tabs button, .nx108-pagination button, .nx108-confirm-card button, .nx108-forge-item-menu button, .nx196-inherit-actions button, .nx108-item-actions button, .nx108-create-actions button) {
  border: 1px solid rgba(239, 201, 128, .5);
  border-radius: var(--nx200-control-radius);
  color: #fff2d5;
  background: linear-gradient(180deg, rgba(148, 94, 37, .94), rgba(67, 40, 16, .98));
  box-shadow: inset 0 1px rgba(255, 255, 255, .1);
}
.nx108-root :is(.nx108-forge-item-menu, .nx108-confirm-card) { border-radius: 12px; }
.nx108-root :is(.nx108-confirm-card, .nx108-item-card)::before { border-radius: 8px; }
.nx108-root .nx108-tabs button.is-active { border-color: #ffd777; color: #fff8e8; background: linear-gradient(#a56d2f, #604017); }
.nx108-root button:disabled { filter: none; }
#nexoriaBlacksmithPanel .nx108-forge-heading { flex: 1 1 0; min-width: 0; }
#nexoriaBlacksmithPanel .nx108-forge-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; width: 100%; }
#nexoriaBlacksmithPanel .nx108-forge-tabs button { width: 100%; min-width: 0; min-height: 36px; padding: 5px 8px; }
#nexoriaBlacksmithPanel .nx108-forge-tabs button.is-active { border-color: #ffd777; background: linear-gradient(#a56d2f, #604017); }

/* A viewport-sized workspace: headers/footers stay put, content scrolls inside. */
#nexoriaCharacterPanel {
  padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
#nexoriaCharacterPanel .nx108-character-workspace {
  position: relative;
  display: flex;
  width: min(1220px, 100%);
  height: min(710px, calc(100dvh - max(6px, env(safe-area-inset-top)) - max(6px, env(safe-area-inset-bottom))));
  max-height: 100%;
  min-height: 0;
  gap: 10px;
  overflow: hidden;
  align-items: stretch;
}
#nexoriaCharacterPanel :is(.nx108-profile-panel, .nx108-bag-pane, .nx108-trade-pane) {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
#nexoriaCharacterPanel .nx108-profile-panel > .nx108-panel-header { flex: 0 0 auto; }
#nexoriaCharacterPanel .nx108-profile-body { flex: 1 1 auto; height: auto; min-height: 0; grid-template-rows: minmax(0, 1fr) auto; }
#nexoriaCharacterPanel .nx108-paperdoll { container-type: size; min-height: 0; }
#nexoriaCharacterPanel .nx108-equip-slot {
  width: clamp(24px, min(18cqh, 22cqw), 58px);
  height: clamp(24px, min(18cqh, 22cqw), 58px);
  min-height: 0 !important;
  padding: 3px;
  aspect-ratio: 1;
}
#nexoriaCharacterPanel .nx108-profile-footer { grid-template-columns: minmax(0, 1fr) 82px; gap: 6px; margin-top: 6px; }
#nexoriaCharacterPanel .nx108-profile-progress { padding: 5px 8px; gap: 3px; }
#nexoriaCharacterPanel .nx108-profile-actions { gap: 5px; }
#nexoriaCharacterPanel .nx108-profile-actions button { grid-template-columns: 16px minmax(0, 1fr); min-width: 0; min-height: 30px; padding: 4px 6px; font-size: .67rem; }
#nexoriaCharacterPanel .nx108-profile-actions button i { font-size: .8rem; }
#nexoriaCharacterPanel .nx108-profile-lower-row { grid-template-columns: minmax(0, 1fr) auto; }
#nexoriaCharacterPanel .nx108-profile-mapct1 { min-height: 30px; padding: 4px 6px; }
#nexoriaCharacterPanel .nx108-profile-mapct1 span { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; font-size: .68rem; }
#nexoriaCharacterPanel .nx108-profile-mapct1 b { overflow: hidden; text-overflow: ellipsis; }
#nexoriaCharacterPanel .nx108-profile-appearance { min-height: 30px; padding: 3px 5px; font-size: .6rem; gap: 4px; }
#nexoriaCharacterPanel .nx108-profile-appearance b { width: 18px; height: 18px; }
#nexoriaCharacterPanel .nx108-bag-pane { padding: 10px; }
#nexoriaCharacterPanel .nx108-bag-heading { flex: 0 0 auto; gap: 6px; }
#nexoriaCharacterPanel .nx108-inventory-gold { font-size: .65rem; overflow-wrap: anywhere; }
#nexoriaCharacterPanel #nx108InventoryGrid { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
#nexoriaCharacterPanel .nx108-tabs { flex: 0 0 auto; }
#nexoriaCharacterPanel .nx108-page-bank { min-width: 0; }

/* Independent siblings, with a clear gap and their own complete frames. */
#nexoriaCharacterPanel .nx200-profile-details {
  flex: 0 1 340px;
  min-width: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #b98f4d #24180e;
  background: transparent;
}
#nexoriaCharacterPanel .nx200-character-stat-panel { flex: 0 0 auto; min-width: 0; }
#nexoriaCharacterPanel .nx200-pet-stat-panel { flex: 0 0 auto; min-width: 0; }
#nexoriaCharacterPanel .nx200-pet-stat-panel .nx198-pet-stats { margin: 0; border: 1px solid rgba(242, 202, 124, .5); border-radius: 12px; padding: 12px; background: linear-gradient(180deg, #392915, #1b120a); }
#nexoriaCharacterPanel .nx200-profile-details h3 { letter-spacing: 0; font-size: .83rem; }
#nexoriaCharacterPanel .nx200-profile-details .nx108-character-stats { padding: 5px 10px 10px; }
#nexoriaCharacterPanel .nx200-profile-details .nx108-character-stats p { padding: 6px 2px; font-size: .72rem; }

/* One Roman-tab row and independent square storage cells; only the grid scrolls. */
.nx108-root .nx108-page-buttons { display: flex; gap: 5px; flex-wrap: nowrap; min-width: 0; overflow-x: auto; scrollbar-width: thin; overscroll-behavior-x: contain; }
.nx108-root .nx108-page-buttons > button { flex: 0 0 42px; min-width: 42px; white-space: nowrap; }
.nx108-adventure-chest-panel .nx108-adventure-chest-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.nx108-adventure-chest-panel .nx108-adventure-chest-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); grid-auto-rows: max-content; align-items: start; gap: 7px; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.nx108-adventure-chest-grid > .nx108-inventory-cell { display: grid; place-items: center; position: relative; width: 100%; height: auto; min-width: 0; aspect-ratio: 1; padding: 4px; }
.nx108-adventure-chest-grid > .nx108-inventory-cell > img { position: absolute; inset: 6%; width: 88%; height: 88%; object-fit: contain; }
.nx108-adventure-chest-layer { padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
.nx108-adventure-chest-panel { height: min(570px, calc(100dvh - max(6px, env(safe-area-inset-top)) - max(6px, env(safe-area-inset-bottom)))); max-height: 100%; max-width: 100%; }
.nx108-adventure-chest-header h2 { font-size: clamp(.85rem, 2vw, 1.3rem); }

@media (max-width: 1050px), (max-height: 620px) {
  #nexoriaCharacterPanel .nx108-character-workspace { gap: 7px; }
  #nexoriaCharacterPanel .nx108-profile-panel > .nx108-panel-header { min-height: 48px; padding: 5px 8px; }
  #nexoriaCharacterPanel .nx108-profile-body { padding: 7px; }
  #nexoriaCharacterPanel .nx108-profile-progress { font-size: .69rem; }
  #nexoriaCharacterPanel .nx108-profile-name-line { height: 25px; }
  #nexoriaCharacterPanel .nx108-profile-name-line #nx108ProfileMapct1Badge { height: 25px; }
  #nexoriaCharacterPanel .nx108-profile-footer { grid-template-columns: minmax(0, 1fr) 70px; gap: 5px; }
  #nexoriaCharacterPanel .nx108-profile-actions button { grid-template-columns: minmax(0, 1fr); padding: 3px; font-size: .64rem; }
  #nexoriaCharacterPanel .nx108-profile-actions button i { display: none; }
  #nexoriaCharacterPanel .nx108-bag-pane { padding: 7px; }
  #nexoriaCharacterPanel .nx108-page-bank { margin-bottom: 6px; }
  #nexoriaCharacterPanel .nx200-profile-details { position: absolute; z-index: 6; top: 0; right: 0; bottom: 0; width: calc(50% - 3px); padding: 0 0 1px 5px; background: #20170ff5; border-radius: 12px; }
  .nx108-adventure-chest-panel .nx108-adventure-chest-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (orientation: portrait) and (max-width: 680px) {
  #nexoriaCharacterPanel .nx108-character-workspace { flex-wrap: nowrap; overflow: hidden; }
  #nexoriaCharacterPanel .nx108-profile-footer { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'progress' 'achievement' 'actions'; }
  #nexoriaCharacterPanel .nx108-profile-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto; }
  #nexoriaCharacterPanel .nx108-profile-lower-row { grid-template-columns: minmax(0, 1fr); }
  #nexoriaCharacterPanel .nx108-profile-appearance { justify-content: space-between; }
  #nexoriaCharacterPanel #nx108InventoryGrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #nexoriaCharacterPanel .nx108-profile-header-actions { gap: 2px; }
  #nexoriaCharacterPanel .nx108-profile-artwork-button { display: none; }
  #nexoriaCharacterPanel .nx200-profile-details { width: 100%; padding-left: 0; }
}
.nx200-adventure-menu .nx108-confirm-card { width: min(440px, 94vw); padding: 14px; }
.nx200-adventure-menu .nx108-detail-header { background: transparent; border: 0; padding: 0 0 10px; }
.nx200-adventure-menu nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.nx200-adventure-menu nav button { min-height: 46px; }
.nx108-root :is(.nx108-jewelry-product, .nx108-gem-combine-product, .nx108-spell-shop-product, .nx108-guild-shop, .nx108-item-card) { border-radius: 10px; }
#nexoriaCharacterPanel .nx108-character-workspace.is-profile-only:not(.has-detail) { width: min(480px, 100%); }
#nexoriaCharacterPanel .nx108-character-workspace.is-profile-only.has-detail { width: min(860px, 100%); }
