:root{
--bg:#181818;
--panel:#1f1f1f;
--muted:#a0a0a0;
--text:#e0e0e0;
--accent:#4dabf7;
--accent-2:#40c4c4;
--slot-size:96px;
--modal-backdrop: rgba(16,16,16,0.75);
--modal-shadow: 0 10px 40px rgba(0,0,0,0.6);
--badge-bg: rgba(0,0,0,0.55);
}

*{box-sizing:border-box}
body{margin:0;font-family:Inter,system-ui,Segoe UI,Roboto,Arial;background:var(--bg);color:var(--text)}
header{display:flex;align-items:center;padding:14px 20px;background:linear-gradient(180deg,#222,#1f1f1f)}
h1{font-size:1rem;margin:0;flex:1;}
.header-logo{width:32px;height:32px;margin-right:10px;image-rendering:pixelated;filter:drop-shadow(0 2px 4px rgba(0,0,0,0.3))}
.header-author{font-size:.75rem;color:#888;font-weight:400;margin-left:8px;opacity:.7}
.controls{display:flex;gap:.5rem;flex:1;justify-content:flex-end;}

.btn{background:var(--accent);color:#121212;border:0;padding:.45rem .7rem;border-radius:8px;cursor:pointer;font-weight:600;transition:background .18s}

.btn:hover{background:#5eb8ff}
.btn.ghost{background:transparent;color:var(--text);border:1px solid rgba(255,255,255,0.06)}
.btn.small{padding:.25rem .5rem;font-size:.85rem;border-radius:6px}

main{padding:18px;max-width:1100px;margin:0 auto}
.muted{color:var(--muted);margin:6px 0}

.grid{display:grid;grid-template-columns:repeat(9,var(--slot-size));gap:10px;justify-content:center;padding:18px 0}
.slot{width:var(--slot-size);height:var(--slot-size);background:linear-gradient(180deg,#1a1a1a,#121212);border-radius:10px;border:1px solid rgba(255,255,255,0.05);display:flex;flex-direction:column;align-items:center;justify-content:center;position:relative;cursor:grab;transition:transform .1s ease,opacity .1s ease}
.slot.dragging{opacity:.6;transform:scale(.97)}
.slot img{width:48px;height:48px;image-rendering:pixelated}

.count{
position:absolute;
right:8px;
bottom:8px;
background:rgba(0,0,0,0.5);
padding:.12rem .35rem;
border-radius:6px;
font-size:.8rem;
color:var(--text);
z-index:3;
}

.label{position:absolute;left:8px;top:8px;font-size:.72rem;color:var(--muted)}

.container-badge{
position:absolute;
left:8px;
bottom:8px;
background:var(--accent-2);
color:#0a1f20;
border-radius:6px;
padding:.08rem .3rem;
font-size:.65rem;
z-index:3;
}

.count-badge-inline{
display:inline-flex;
align-items:center;
justify-content:center;
min-width:40px;
padding:4px 8px;
border-radius:6px;
background:var(--badge-bg);
color:var(--text);
margin-left:6px;
font-size:.9rem;
}

.count-badge {
position:absolute;
right:6px;
bottom:6px;
background:var(--badge-bg);
padding:2px 6px;
border-radius:6px;
font-size:.8rem;
color:var(--text);
}

footer{padding:24px;text-align:center;color:var(--muted);font-size:.9rem}

.modal-backdrop{
position:fixed;
inset:0;
background:var(--modal-backdrop);
display:none;
align-items:center;
justify-content:center;
z-index:100;
}

#slotModal{z-index:300}
#containerModal{z-index:200}
#bookModal{z-index:400}
#bookModal .modal{z-index:401}

#offhandModal{z-index:500}
#offhandModal .modal{z-index:501}
#offhandPickerModal{z-index:600}
#offhandPickerModal .modal{z-index:601}

#githubBtn { transition: transform .28s cubic-bezier(.2,.9,.3,1); }
#githubBtn:hover{opacity:.8}
#githubBtn.git-anim { animation: gitpop .6s ease; }

@keyframes gitpop {
0%   { transform: scale(1) rotate(0deg); }
30%  { transform: scale(1.18) rotate(10deg); }
60%  { transform: scale(0.95) rotate(-6deg); }
100% { transform: scale(1) rotate(0deg); }
}

.separator {
width: 1px;
height: 28px;
background-color: #777; 
border-radius: 2px;
}

.gray-btn {
background-color: #555;  
color: #ddd;             
border: 1px solid #666;
border-radius: 4px;
padding: 4px 10px;
font-size: 0.9rem;
transition: background-color 0.18s;
}

#githubBtn {
display:block;
margin:0;
}


.gray-btn:hover {
background-color: #666;
}


#slotModal .modal{
min-width:560px;
max-width:1100px;
}

#containerGrid{
display:grid;
grid-template-columns:repeat(auto-fit,64px);
gap:8px;
justify-content:center;
}

.modal{
background:linear-gradient(180deg,var(--panel), #171717);
padding:16px;
border-radius:10px;
min-width:320px;
max-width:920px;
color:var(--text);
box-shadow:var(--modal-shadow);
border:1px solid rgba(255,255,255,0.02);
box-sizing:border-box;
}
.modal.show{display:flex}
.modal .title{font-weight:700;margin-bottom:8px}

.picker-list{max-height:360px;overflow:auto;padding:6px;background:transparent;display:flex;flex-direction:column;gap:6px}
.picker-item{display:flex;gap:8px;align-items:center;padding:6px;border-radius:8px;cursor:pointer;transition:background .15s ease}
.picker-item:hover{background:rgba(77,171,247,0.04)}
.picker-item img{width:28px;height:28px;image-rendering:pixelated;border-radius:4px}
.picker-item .name{color:var(--text);font-size:.92rem}

.nonselectable {
pointer-events: none;
user-select: none;
caret-color: transparent;
color: var(--muted);
background: #101010;
}

input[type="text"],input[type="number"],select{background:#101010;color:var(--text);border:1px solid rgba(255,255,255,0.06);padding:.5rem;border-radius:8px;width:100%}
label.small{font-size:.85rem;color:var(--muted)}
.actions{display:flex;gap:.5rem;margin-top:10px;justify-content:flex-end}
.spoiler{font-size:.85rem;color:var(--muted)}
.kbd{background:#141414;padding:.12rem .4rem;border-radius:6px;font-weight:700}
.inline{display:inline-flex;gap:.5rem;align-items:center}
.hide{display:none}

.container-cell{cursor:grab; position: relative; transition: transform .12s ease, opacity .12s ease; will-change: transform, opacity; }
.container-cell .count {
position: absolute;
right: 6px;
bottom: 6px;
background: var(--badge-bg);
padding: 2px 6px;
border-radius: 6px;
font-size: .8rem;
color: var(--text);
z-index: 3;
}
.container-cell.dragging, .slot.dragging{opacity:.6;transform:scale(.97)}
.container-cell img{ 
    width:36px; 
    height:36px; 
    image-rendering:pixelated; 
    transition: transform .12s ease, opacity 0.3s ease; 
    position: absolute;
}

.container-cell .loading-spinner {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 2;
}


#containerModal .modal .title {
font-size: 1rem;
font-weight: 700;
margin-bottom: 8px;
display: inline-block;
padding: 0 6px;
border-radius: 4px;
background: rgba(0,0,0,0.03);
}

.container-cell .container-badge {
font-size: .58rem;
padding: .04rem .25rem;
left: 6px;
bottom: 6px;
line-height: 1;
border-radius: 5px;
}
#containerModal .modal .spoiler {
margin-top: 0;
}
#bookModal .modal {
width: 680px;
max-width: calc(100% - 40px);
box-sizing: border-box;
min-width: 420px;
}

#bookModal .modal textarea,
#bookModal .modal input,
#bookModal .modal .picker-list,
#bookModal .modal .title,
#bookModal .modal .spoiler {
white-space: pre-wrap;
overflow-wrap: anywhere;
word-break: break-word;
max-width: 100%;
}

#bookPagesContainer { min-width: 0; }
.btn:disabled {
opacity: 0.5;
cursor: not-allowed;
background: rgba(255,255,255,0.04) !important;
color: var(--muted) !important;
border: 1px solid rgba(255,255,255,0.02);
}

.btn.ghost {
transition: background-color 0.18s;
}

.btn.ghost:hover {
background-color: rgba(255,255,255,0.08);
}
.drag-overlay {
position: fixed;
inset: 0;
background: rgba(24, 24, 24, 0.95);
display: none;
align-items: center;
justify-content: center;
z-index: 9999;
pointer-events: none;
}

.drag-overlay.active {
display: flex;
}

.drag-overlay-content {
text-align: center;
padding: 3rem;
border: 3px dashed #888;
border-radius: 16px;
background: rgba(136, 136, 136, 0.08);
}

.drag-overlay-content .icon {
font-size: 4rem;
margin-bottom: 1rem;
opacity: 0.9;
}

.drag-overlay-content .text {
font-size: 1.5rem;
font-weight: 600;
color: #d0d0d0;
margin-bottom: 0.5rem;
}

.drag-overlay-content .subtext {
font-size: 1rem;
color: var(--muted);
}

@media (max-width:640px){
:root{--slot-size:72px}
#slotModal .modal{min-width:92%; max-width:92%;}
}
@media (prefers-reduced-motion: no-preference) {
@keyframes btn-pop {
0%   { transform: scale(1); filter: drop-shadow(0 0 0 rgba(0,0,0,0)); }
40%  { transform: scale(1.09); filter: drop-shadow(0 6px 20px rgba(77,171,247,0.12)); }
100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(0,0,0,0)); }
}

.btn.active {
animation: btn-pop 260ms cubic-bezier(.2,.9,.3,1);
}
}

@media (prefers-reduced-motion: reduce) {
.btn.active { animation: none !important; transform: none !important; }
}

.btn.small {
padding: 6px 8px;     
font-size: 0.85rem;
border-radius: 6px;
}

.hotbar-selector-container {
  position: relative;
}

#hotbarDropdownBtn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between; 
  gap: 8px;
  padding: 0 10px;    
  font-size: 0.9rem;
  line-height: 1;
  height: 30px;
  min-height: 30px;
  box-sizing: border-box;
  border: 1px solid #666;
  border-radius: 4px;
  background-color: #555;
  color: #ddd;
  white-space: nowrap;      
}

#hotbarDropdownBtn:hover {
  background-color: #666;
}

.hotbar-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%) translateY(-2px);      
  background: linear-gradient(180deg, #1f1f1f, #171717);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  box-shadow: 0 6px 14px rgba(0,0,0,0.28);              
  z-index: 1000;
  min-width: 140px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.10s cubic-bezier(0.2,0,0.2,1),
              transform 0.10s cubic-bezier(0.2,0,0.2,1);   
}

.hotbar-dropdown.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hotbar-caret {
  width: 20px;              
  height: 20px;           
  object-fit: contain;
  flex-shrink: 0;
  filter: invert(1) brightness(2);  
  opacity: 0.95;
  transform-origin: center center;
  display: inline-block;
}


.hotbar-option {
  display: flex;               
  align-items: center;
  gap: 10px;                    
  padding: 8px 14px;        
  cursor: pointer;
  color: var(--text);
  transition: background 0.12s ease;
  font-size: 0.92rem;
  text-align: left;            
  justify-content: flex-start;  
  min-width: 140px;
}

.hotbar-option:hover {
  background: rgba(77,171,247,0.12);
}


.hotbar-option.active {
  background: rgba(77,171,247,0.15);
  color: var(--accent);
  font-weight: 600;
}

.success-notification {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: linear-gradient(135deg, #2d2d2d 0%, #1a1a1a 100%);
  color: #fff;
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 10px;
}

.success-notification::before {
  content: "";
  display: inline-block;
  width: 20px;
  height: 20px;
  background-color: #16a34a; 
  -webkit-mask: url('./icons/ui/check_mark.svg') center/contain no-repeat;
  mask: url('./icons/ui/check_mark.svg') center/contain no-repeat;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.success-notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.count-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.count-row.vertical {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.count-row.vertical label.small {
  margin-top: 4px; 
  margin-left: 2px;
  transform: translateY(1px); 
}

.count-controls {
  display: flex;
  align-items: center;
  gap: 4px; 
  width: 100%;
  min-width: 0;
}

.count-controls input[type="range"] {
  flex: 1;
  min-width: 0;
}

.count-badge-inline {
  transform: translateY(-2px); 
  font-size: 0.9em; 
}

.slot img {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.slot img.loaded {
  opacity: 1;
}

.slot .loading-spinner {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  z-index: 2;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.explanation-section {
  max-width: 1100px;
  margin: 24px auto 0;
  padding: 12px 16px 4px;
  background: linear-gradient(180deg, rgba(26,26,26,0.35), rgba(21,21,21,0.35));
  border: 1px solid rgba(255,255,255,0.02);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.explanation-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  background: rgba(255,255,255,0.008);
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.015);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.explanation-icon-wrapper {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #0f0f0f, #0a0a0a);
  border: 1.5px solid rgba(77,171,247,0.25);
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(77,171,247,0.1);
}

.explanation-icon {
  width: 24px;
  height: 24px;
  image-rendering: pixelated;
}

.explanation-icon-wrapper--triggers {
  width: 96px;
  height: 36px;
  gap: 4px;
  flex-direction: row;
}

a.triggers-link {
  color: #5bb5ff;
  text-decoration: none;
  border-bottom: 1px dashed #5bb5ff;
  padding-bottom: 3px;
  transition: color 0.14s ease, border-color 0.14s ease;
  outline: none;
}

a.triggers-link:focus-visible {
  box-shadow: 0 0 0 3px rgba(91,181,255,0.08);
  border-color: #5bb5ff;
}

.explanation-text {
  flex: 1;
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.4;
}

.explanation-text strong {
  color: var(--accent);
  font-weight: 600;
}

.explanation-footer {
  padding: 8px 12px 6px;
  margin-top: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
  border-top: 1px solid rgba(255,255,255,0.015);
}

@media (max-width:640px){
  .explanation-section {
    padding: 12px 14px;
    margin: 12px auto 0;
    gap: 8px;
  }
  
  .explanation-item {
    gap: 10px;
    padding: 7px 8px;
  }
  
  .explanation-icon-wrapper {
    width: 32px;
    height: 32px;
  }
  
  .explanation-icon {
    width: 22px;
    height: 22px;
  }
  
  .explanation-text {
    font-size: 0.82rem;
  }
  
  .explanation-footer {
    font-size: 0.78rem;
    padding: 8px 10px 6px;
  }
  
  .explanation-footer ol {
    padding-left: 18px;
  }
}

.explanation-readme {
  margin-top: 2px;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: left;
  line-height: 1.3;
  font-weight: 500;
  display: block;
}

.explanation-readme a {
  color: var(--accent);                    
  text-decoration: none;
  border-bottom: 1px dashed var(--accent);
  padding-bottom: 1px;
  transform: translateY(-0.6px);            
  transition: color 0.14s ease, border-color 0.14s ease, transform 0.12s ease;
  outline: none;
}

.explanation-readme a:focus-visible {
  box-shadow: 0 0 0 3px rgba(77,171,247,0.08);
  border-color: var(--accent);
}

.explanation-readme a:active {
  transform: translateY(0);
}

@media (max-width:640px) {
  .explanation-readme { font-size: 0.84rem; margin-top: 0; }
}

.drag-preview {
  position: fixed;
  pointer-events: none;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.15s ease;
  transform: translate(-50%, -50%);
  will-change: transform;
}

.drag-preview.active {
  opacity: 0.9;
}

.drag-preview img {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

.drag-preview .preview-count {
  position: absolute;
  right: -4px;
  bottom: -4px;
  background: rgba(0, 0, 0, 0.75);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--text);
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn.destructive {
background: #dc3545;
color: #fff;
border: 0;
transition: background 0.18s;
}

.btn.destructive:hover {
background: #c82333;
}

.btn.small:not(.ghost):not(.destructive):hover {
background: #5eb8ff;
}

.offhand-badge {
position: absolute;
top: 10px;
left: 50%;
transform: translateX(-50%);
background: var(--accent);
color: #000;
border-radius: 3px;
padding: 2px 6px;
font-size: 0.68rem;
font-weight: 800;
text-transform: uppercase;
letter-spacing: 0.4px;
z-index: 4;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
border: 1px solid rgba(0, 0, 0, 0.3);
pointer-events: none;
}

.offhand-badge-container {
position: absolute;
top: 6px;
left: 50%;
transform: translateX(-50%);
background: var(--accent);
color: #000;
border-radius: 3px;
padding: 1px 5px;
font-size: 0.58rem;
font-weight: 800;
text-transform: uppercase;
letter-spacing: 0.4px;
z-index: 4;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
border: 1px solid rgba(0, 0, 0, 0.3);
line-height: 1;
pointer-events: none;
}