@font-face {
  font-family: 'Minecraft';
  src: url('../assets/font/minecraft.ttf') format('truetype');
  font-display: block;
}

:root {
  --s: 2px;
  --text: #ffffff;
  --shadow: #3f3f3f;
  --dark: #404040;
  --gray: #a0a0a0;
  --yellow: #ffff55;
  --aqua: #55ffff;
  --red: #ff5555;
  --green: #55ff55;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: 'Minecraft', monospace;
  font-size: 16px;
  line-height: 18px;
  color: var(--text);
  text-shadow: var(--s) var(--s) 0 var(--shadow);
  background: #000;
  -webkit-font-smoothing: none;
  font-smooth: never;
  overflow-x: hidden;
}

img, canvas { image-rendering: pixelated; }

button, input, textarea, select { font: inherit; color: inherit; text-shadow: inherit; }

::selection { background: #0000ff; color: #fff; }

b { font-weight: normal; color: var(--yellow); }
i { font-style: normal; color: var(--aqua); }
code { font-family: inherit; color: var(--yellow); }
.gray { color: var(--gray); }

.panorama {
  position: fixed; inset: 0; overflow: hidden; z-index: -3;
}
.panorama-strip {
  position: absolute; top: -4vh; left: 0; height: 108vh; display: flex;
  animation: pan 240s linear infinite;
  filter: blur(5px);
}
.panorama-strip img { height: 108vh; width: 108vh; display: block; }
@keyframes pan { from { transform: translateX(0); } to { transform: translateX(-432vh); } }
.menu-shade {
  position: fixed; inset: 0; z-index: -2;
  background: url('../assets/gui/menu_background.png');
  background-size: calc(32 * var(--s));
  opacity: .55;
}
@media (prefers-reduced-motion: reduce) { .panorama-strip { animation: none; } }

.site-header { text-align: center; padding: 36px 16px 10px; }
.logo-wrap { position: relative; display: inline-block; }
.logo {
  margin: 0; font-weight: normal; font-size: 56px; line-height: 64px;
  color: #fff; text-shadow: 6px 6px 0 #3f3f3f;
  letter-spacing: 2px;
}
.subtitle { margin: 14px 0 0; }

.mc-panel {
  border: calc(4 * var(--s)) solid transparent;
  border-image: url('../assets/gui/panel.png') 4 fill / calc(4 * var(--s)) stretch;
  image-rendering: pixelated;
  color: var(--dark);
  text-shadow: none;
  padding: 10px 14px 16px;
}
.panel-title, .panel-subtitle { margin: 0 0 10px; font-weight: normal; font-size: 16px; color: var(--dark); }
.panel-subtitle { margin: 0; }

.mc-inset {
  border: var(--s) solid transparent;
  border-image: url('../assets/gui/slot.png') 1 fill / var(--s) stretch;
  image-rendering: pixelated;
}

.layout {
  display: grid; grid-template-columns: minmax(330px, 420px) minmax(0, 1fr);
  gap: 16px; max-width: 1400px; margin: 16px auto 0; padding: 0 16px; align-items: start;
}
.output-panel { max-width: 1400px; margin: 16px auto 0; width: calc(100% - 32px); }
@media (max-width: 960px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.layout > *, .output-grid > * { min-width: 0; }

.hint { margin: 6px 0 10px; }
.hint.dark { color: #555; }
.field-label { color: var(--dark); display: block; margin: 4px 0 2px; }

.mc-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: calc(20 * var(--s)); padding: 0 12px; min-width: 0;
  border: calc(3 * var(--s)) solid transparent;
  border-image: url('../assets/gui/button.png') 3 fill / calc(3 * var(--s)) stretch;
  image-rendering: pixelated;
  background: none; color: #fff; text-shadow: var(--s) var(--s) 0 var(--shadow);
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  user-select: none;
}
.mc-btn:hover, .mc-btn:focus-visible { border-image-source: url('../assets/gui/button_highlighted.png'); outline: none; color: #ffffa0; }
.mc-btn:disabled { border-image-source: url('../assets/gui/button_disabled.png'); color: var(--gray); text-shadow: none; cursor: default; }
.mc-btn.wide { width: 100%; }
.mc-btn.small { height: calc(14 * var(--s)); padding: 0 8px; font-size: 16px; }
.mc-btn img { width: 32px; height: 32px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .mc-btn { flex: 1 1 200px; }

.icon-btn {
  width: calc(14 * var(--s)); height: calc(14 * var(--s)); padding: 0; border: 0; cursor: pointer;
  background: url('../assets/gui/cross_button.png') 0 0 / 100% 100%; image-rendering: pixelated; flex: none;
}
.icon-btn:hover { background-image: url('../assets/gui/cross_button_highlighted.png'); }
.move-btn {
  width: 22px; height: 14px; padding: 0; border: 0; cursor: pointer; flex: none;
  background: url('../assets/gui/move_up.png') -36px -10px / 64px 64px no-repeat; image-rendering: pixelated;
}
.move-btn:hover { background-image: url('../assets/gui/move_up_highlighted.png'); }
.move-btn.down { background-image: url('../assets/gui/move_down.png'); background-position: -36px -40px; }
.move-btn.down:hover { background-image: url('../assets/gui/move_down_highlighted.png'); }
.move-btn:disabled { opacity: .25; cursor: default; }
.moves { display: flex; flex-direction: column; gap: 6px; flex: none; }

.mc-input, textarea#command {
  width: 100%; height: calc(20 * var(--s)); padding: 0 8px;
  border: var(--s) solid transparent;
  border-image: url('../assets/gui/text_field.png') 1 fill / var(--s) stretch;
  image-rendering: pixelated;
  background: none; color: #e0e0e0; outline: none;
  caret-color: #d0d0d0;
}
.mc-input:hover, .mc-input:focus { border-image-source: url('../assets/gui/text_field_highlighted.png'); }
.mc-input::placeholder { color: #707070; text-shadow: none; }
.mc-input.num { width: 72px; text-align: center; padding: 0 4px; }
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 10px; margin-top: 12px; }
.mc-check {
  display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--dark); text-shadow: none;
  user-select: none; min-height: 40px;
}
.mc-check .box {
  width: 40px; height: 40px; flex: none;
  background: url('../assets/gui/checkbox.png') 0 0 / 100% 100%; image-rendering: pixelated;
}
.mc-check:hover .box { background-image: url('../assets/gui/checkbox_highlighted.png'); }
.mc-check.on .box { background-image: url('../assets/gui/checkbox_selected.png'); }
.mc-check.on:hover .box { background-image: url('../assets/gui/checkbox_selected_highlighted.png'); }

.slot {
  position: relative; width: calc(18 * var(--s)); height: calc(18 * var(--s)); flex: none;
  background: url('../assets/gui/slot.png') 0 0 / 100% 100%; image-rendering: pixelated;
  display: inline-flex; align-items: center; justify-content: center;
}
button.slot { border: 0; padding: 0; cursor: pointer; }
.slot.selected::after, button.slot:hover::after {
  content: ''; position: absolute; inset: calc(-3 * var(--s));
  background: url('../assets/gui/slot_highlight_front.png') 0 0 / 100% 100%; image-rendering: pixelated;
  pointer-events: none;
}
.slot.empty-hint::before { content: '+'; color: #555; text-shadow: none; font-size: 16px; }

.item {
  position: relative; display: inline-block; width: 32px; height: 32px; flex: none;
  vertical-align: middle;
}
.item img { width: 32px; height: 32px; display: block; }
.item .count {
  position: absolute; right: -2px; bottom: -4px; color: #fff; text-shadow: var(--s) var(--s) 0 var(--shadow);
  font-size: 16px; line-height: 16px; pointer-events: none;
}
.item .glint {
  position: absolute; inset: 0; pointer-events: none;
  -webkit-mask-size: 100% 100%; mask-size: 100% 100%;
  background: url('../assets/gui/enchanted_glint_item.png');
  background-size: 128px 128px;
  mix-blend-mode: plus-lighter;
  opacity: .55;
  animation: glint 6s linear infinite;
  image-rendering: pixelated;
}
@keyframes glint { from { background-position: 0 0; } to { background-position: 128px -128px; } }
.item-inline { display: inline-block; vertical-align: middle; }
.item.small, .item.small img { width: 24px; height: 24px; }

.prof-grid { display: grid; grid-template-columns: repeat(7, calc(18 * var(--s))); gap: 4px; justify-content: center; }
.prof-label { text-align: center; margin: 8px 0 10px; color: var(--dark); }

.villager-row { display: flex; gap: 12px; align-items: stretch; }
.preview-box {
  width: 128px; flex: none; display: flex; align-items: flex-end; justify-content: center; padding: 8px 0;
  background-clip: padding-box;
}
#villagerCanvas { width: 96px; height: 204px; }
.villager-controls { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.villager-controls .mc-btn { width: 100%; }

.tabs { display: flex; gap: 2px; flex-wrap: wrap; margin-top: 12px; }
.tab {
  height: calc(12 * var(--s)); padding: 0 10px; cursor: pointer;
  border: calc(2 * var(--s)) solid transparent; border-bottom-width: 0;
  border-image: url('../assets/gui/tab.png') 2 2 0 2 fill / calc(2 * var(--s)) calc(2 * var(--s)) 0 calc(2 * var(--s)) stretch;
  image-rendering: pixelated; background: none; color: #fff; text-shadow: var(--s) var(--s) 0 var(--shadow);
}
.tab:hover { border-image-source: url('../assets/gui/tab_highlighted.png'); }
.tab.active { border-image-source: url('../assets/gui/tab_selected.png'); color: var(--yellow); }
.tab.active:hover { border-image-source: url('../assets/gui/tab_selected_highlighted.png'); }

.browse-list {
  max-height: 300px; overflow-y: auto; padding: 6px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 4px;
  background-color: transparent;
}
.browse-list .biome-note, .trade-row .biome-note { color: #e0e0e0; }

.offer {
  display: flex; align-items: center; gap: 6px;
  height: calc(20 * var(--s)); padding: 0 8px;
  border: calc(3 * var(--s)) solid transparent;
  border-image: url('../assets/gui/button.png') 3 fill / calc(3 * var(--s)) stretch;
  image-rendering: pixelated; cursor: pointer; color: #fff; text-shadow: var(--s) var(--s) 0 var(--shadow);
  background: none; width: 100%; text-align: left;
}
.offer:hover { border-image-source: url('../assets/gui/button_highlighted.png'); }
.offer .arrow { width: 20px; height: 18px; flex: none; }
.offer .plus-spacer { width: 32px; flex: none; }
.offer .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.offer .lvl { color: var(--yellow); }

.your-trades-head { display: flex; justify-content: space-between; align-items: center; margin: 18px 0 8px; }
.trade-list { display: flex; flex-direction: column; gap: 8px; }
.trade-list .empty { color: #555; padding: 10px; text-align: center; }

.trade-card { padding: 6px; }
.trade-card.excluded { opacity: .55; }
.trade-card .head { display: flex; align-items: center; gap: 6px; }
.trade-card .head .offer { flex: 1; min-width: 0; cursor: default; }
.trade-card .head .offer:hover { border-image-source: url('../assets/gui/button.png'); }
.trade-card .exclude-note { color: #ffaaaa; margin: 4px 2px 0; }
.editor { padding: 8px 4px 2px; display: flex; flex-direction: column; gap: 8px; color: #e0e0e0; text-shadow: var(--s) var(--s) 0 var(--shadow); }
.editor .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.editor .row > .lab { min-width: 92px; color: #fff; }
.editor .note { color: #bbb; }
.editor .note.warn-note { color: #ffcc66; }
.editor .stack-slots { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.editor .slot-col { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 16px; }
.editor .slot-col .cap { color: #ddd; }
.stack-editor { padding: 8px; display: flex; flex-direction: column; gap: 8px; }

.ench-list { display: flex; flex-direction: column; gap: 4px; }
.ench-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ench-row .name { min-width: 150px; color: #fff; }
.ench-row .name.curse { color: var(--red); }

.stepper { display: inline-flex; align-items: center; gap: 2px; }
.stepper .mc-btn { width: 32px; padding: 0; }

.dye-grid { display: flex; flex-wrap: wrap; gap: 2px; }
.dye-grid .slot.selected::after { content: ''; }
.swatch { width: 36px; height: 36px; display: inline-block; }

.mc-slider { position: relative; width: 260px; max-width: 100%; height: calc(20 * var(--s)); flex: none; }
.mc-slider .track {
  position: absolute; inset: 0; border: calc(2 * var(--s)) solid transparent;
  border-image: url('../assets/gui/slider.png') 2 fill / calc(2 * var(--s)) stretch; image-rendering: pixelated;
  display: flex; align-items: center; justify-content: center; color: #fff; pointer-events: none; z-index: 1;
}
.mc-slider .handle {
  position: absolute; top: 0; width: calc(8 * var(--s)); height: 100%;
  background: url('../assets/gui/slider_handle.png') 0 0 / 100% 100%; image-rendering: pixelated; pointer-events: none; z-index: 2;
}
.mc-slider:hover .handle { background-image: url('../assets/gui/slider_handle_highlighted.png'); }
.mc-slider .label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 3; pointer-events: none; color: #fff; }
.mc-slider input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; margin: 0; z-index: 4; }

.search-wrap, .ac-wrap { position: relative; }
.search-wrap { margin-top: 4px; }
.search-icon { position: absolute; left: 10px; top: 14px; width: 24px; height: 24px; z-index: 1; pointer-events: none; }
.mc-input.search { padding-left: 42px; }
.ac-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: 50;
  background: rgba(0, 0, 0, .86); max-height: 380px; overflow-y: auto; padding: 2px 0;
  color: var(--gray); text-shadow: var(--s) var(--s) 0 #2a2a2a;
}
.ac-item { display: flex; align-items: center; gap: 8px; padding: 3px 8px; cursor: pointer; min-height: 38px; }
.ac-item .sub { color: #707070; margin-left: auto; padding-left: 8px; white-space: nowrap; }
.ac-item .main { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-item .trade-mini { display: flex; align-items: center; gap: 2px; flex: none; }
.ac-item .trade-mini .arrow { width: 20px; height: 18px; }
.ac-item.active, .ac-item:hover { color: var(--yellow); background: rgba(255, 255, 255, .06); }
.ac-item mark { background: none; color: inherit; text-decoration: underline; }
.ac-empty { padding: 8px; color: #707070; }

.frenzy-only { display: none; margin-top: 8px; }
body.frenzy .frenzy-only { display: block; }
.frenzy-btn.on { color: var(--yellow); }

.output-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .output-grid { grid-template-columns: 1fr; } }
.command-box { margin-top: 12px; }
textarea#command {
  height: 200px; resize: vertical; padding: 8px; line-height: 18px; color: #fff;
  word-break: break-all; white-space: pre-wrap; display: block;
}
.command-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
#charCount { color: var(--dark); }
#charCount.long { color: #aa0000; }
.copy-btn { min-width: 220px; }
.warn { color: #aa0000; margin: 10px 0 0; line-height: 22px; }
.warn b { color: #aa0000; text-decoration: underline; }
.warn code, .warn i { color: #0000aa; }

.merchant-wrap { width: calc(276 * var(--s)); max-width: 100%; overflow: hidden; }
.merchant {
  position: relative; width: calc(276 * var(--s)); height: calc(166 * var(--s));
  background: url('../assets/gui/villager_container.png') 0 0 / calc(512 * var(--s)) calc(256 * var(--s)) no-repeat;
  image-rendering: pixelated; color: var(--dark); text-shadow: none; transform-origin: 0 0;
}
.merchant .m-title, .merchant .m-trades, .merchant .m-inv { position: absolute; top: calc(6 * var(--s)); white-space: nowrap; line-height: 16px; }
.merchant .m-inv { top: calc(72 * var(--s)); left: calc(107 * var(--s)); }
.merchant .m-list { position: absolute; left: calc(5 * var(--s)); top: calc(16 * var(--s)); width: calc(88 * var(--s)); height: calc(140 * var(--s)); overflow: hidden; }
.merchant .m-btn {
  position: absolute; left: 0; width: calc(88 * var(--s)); height: calc(20 * var(--s));
  border: calc(3 * var(--s)) solid transparent; padding: 0;
  border-image: url('../assets/gui/button.png') 3 fill / calc(3 * var(--s)) stretch; image-rendering: pixelated;
  background: none; cursor: pointer;
}
.merchant .m-btn:hover, .merchant .m-btn.sel { border-image-source: url('../assets/gui/button_highlighted.png'); }
.merchant .m-btn .item { position: absolute; top: calc(-1 * var(--s)); }
.merchant .m-btn .arrow { position: absolute; top: calc(2 * var(--s)); width: calc(10 * var(--s)); height: calc(9 * var(--s)); }
.merchant .m-scroll {
  position: absolute; left: calc(94 * var(--s)); width: calc(6 * var(--s)); height: calc(27 * var(--s));
  background: url('../assets/gui/trade_scroller.png') 0 0 / 100% 100%; image-rendering: pixelated;
}
.merchant .m-scroll.off { background-image: url('../assets/gui/trade_scroller_disabled.png'); }
.merchant .m-slot { position: absolute; }
.merchant .m-xp { position: absolute; left: calc(136 * var(--s)); top: calc(16 * var(--s)); width: calc(102 * var(--s)); height: calc(5 * var(--s)); background: url('../assets/gui/xp_bar_background.png') 0 0 / 100% 100%; }

.mc-tooltip {
  position: fixed; z-index: 1000; pointer-events: none; max-width: 440px;
  border: calc(9 * var(--s)) solid transparent;
  border-image: url('../assets/gui/tooltip_background.png') 9 fill / calc(9 * var(--s)) stretch; image-rendering: pixelated;
  margin: 0; padding: calc(3 * var(--s)) calc(4 * var(--s)) calc(2 * var(--s));
  color: #fff; text-shadow: var(--s) var(--s) 0 #3f3f3f;
}
.mc-tooltip::before {

  content: ''; position: absolute; inset: calc(-1 * var(--s)); background: rgba(16, 0, 16, .94); z-index: -1;
}
.mc-tooltip::after {
  content: ''; position: absolute; inset: calc(-10 * var(--s));
  border: calc(10 * var(--s)) solid transparent;
  border-image: url('../assets/gui/tooltip_frame.png') 10 / calc(10 * var(--s)) stretch; image-rendering: pixelated;
}
.mc-tooltip .tip-inner { position: relative; line-height: 20px; }
.mc-tooltip .t-name { margin-bottom: 4px; }
.mc-tooltip .t-line { color: #aaaaaa; }
.mc-tooltip .t-curse { color: var(--red); }
.mc-tooltip .t-blue { color: #5555ff; }
.mc-tooltip .t-id { color: #7a7a7a; }

.toast {
  position: fixed; right: 16px; top: 16px; z-index: 1001; min-width: 260px;
  border: calc(6 * var(--s)) solid transparent;
  border-image: url('../assets/gui/popup_background.png') 6 fill / calc(6 * var(--s)) stretch; image-rendering: pixelated;
  padding: 2px 6px; display: flex; gap: 10px; align-items: center; color: var(--yellow);
  animation: toastIn .25s ease-out;
}
.toast .t-sub { color: #fff; }
@keyframes toastIn { from { transform: translateX(120%); } to { transform: none; } }

.site-footer { text-align: center; padding: 28px 16px 40px; font-size: 16px; color: #fff; }
.site-credit { font-size: 16px; }

.credit-overlay {
  position: fixed; inset: 0; z-index: 1100; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(0, 0, 0, .72);
}
.credit-card { width: min(560px, 100%); color: var(--dark); }
.credit-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.credit-head .panel-title { margin-bottom: 0; }
.credit-card p { margin: 14px 0 0; }
.credit-link { display: inline-block; margin-top: 14px; color: #0000aa; text-shadow: none; }
.credit-link:hover, .credit-link:focus-visible { color: #0000ff; }

.browse-list::-webkit-scrollbar, .ac-list::-webkit-scrollbar, textarea::-webkit-scrollbar { width: 12px; }
.browse-list::-webkit-scrollbar-track, .ac-list::-webkit-scrollbar-track, textarea::-webkit-scrollbar-track { background: #000; }
.browse-list::-webkit-scrollbar-thumb, .ac-list::-webkit-scrollbar-thumb, textarea::-webkit-scrollbar-thumb {
  background: url('../assets/gui/scroller.png') 0 0 / 100% 100%; image-rendering: pixelated;
}

@media (max-width: 640px) {
  .logo { font-size: 36px; line-height: 44px; }
  .prof-grid { grid-template-columns: repeat(7, 1fr); }
  .prof-grid .slot { width: 100%; aspect-ratio: 1; height: auto; }
  .merchant { transform: scale(.6); margin-bottom: calc(-166 * var(--s) * .4); }
}
