:root { --bg: #1b2531; --square: #3a3f47; --square-hi: #454a52; --edge: #6b7a8a; --mist: #4a1a3e; --gold: #b99a5b; --text: #e7e2d6; }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: radial-gradient(ellipse at top, #2a1730 0%, var(--bg) 55%); color: var(--text); font-family: system-ui, "Segoe UI", sans-serif; user-select: none; -webkit-user-select: none; }
header { display: flex; align-items: center; gap: 16px; padding: 12px 16px 4px; }
header .chest { width: 96px; border-radius: 10px; box-shadow: 0 0 24px #5a1a4a88; }
h1 { font-size: 1.3rem; margin: 0 0 6px; color: var(--gold); letter-spacing: .02em; }
select { background: #11161d; color: var(--text); border: 1px solid #39424e; border-radius: 6px; padding: 4px 8px; max-width: 100%; }
#hint { margin: 4px 16px 8px; font-size: .85rem; opacity: .75; }
#grid { --size: min(110px, calc((100vw - 32px - 9 * 8px) / 10)); display: grid; grid-template-columns: repeat(10, var(--size)); gap: 8px; padding: 8px 16px 24px; justify-content: center; }
.square { position: relative; width: var(--size); height: var(--size); border-radius: 12%; background: linear-gradient(180deg, var(--square-hi), var(--square)); border-bottom: 2px solid var(--edge); box-shadow: inset 0 1px 0 #ffffff14, 0 2px 4px #0006; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.square.target { outline: 2px solid var(--gold); outline-offset: 1px; }
.square .item { position: relative; width: 86%; height: 86%; display: flex; align-items: center; justify-content: center; cursor: pointer; touch-action: none; }
.square .item img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; image-rendering: auto; }
.square .item .name { font-size: max(9px, calc(var(--size) * .12)); text-align: center; line-height: 1.1; overflow: hidden; }
.square .qty { position: absolute; right: 6%; bottom: 3%; font-weight: 700; font-size: max(10px, calc(var(--size) * .17)); text-shadow: 0 0 3px #000, 0 0 3px #000, 0 0 2px #000; pointer-events: none; }
.square.dragging .item { opacity: .25; }
.ghost { position: fixed; z-index: 10; pointer-events: none; width: var(--size); height: var(--size); transform: translate(-50%, -50%) scale(1.08); filter: drop-shadow(0 6px 10px #000a); }
.ghost img { width: 100%; height: 100%; object-fit: contain; }
#status { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); background: #0d1117ee; border: 1px solid #39424e; padding: 8px 14px; border-radius: 8px; font-size: .9rem; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; }
#status.show { opacity: 1; }
#dialog, #close-dialog { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; z-index: 20; }
#dialog[hidden], #close-dialog[hidden] { display: none; }
.panel { background: linear-gradient(180deg, #232c38, #1a212b); border: 1px solid #4a3a52; box-shadow: 0 0 40px #4a1a3e; border-radius: 14px; padding: 18px 22px; width: min(440px, 92vw); max-height: 92vh; overflow: auto; text-align: center; }
.panel img { max-width: 100%; max-height: 50vh; object-fit: contain; }
.panel h2 { margin: 10px 0 4px; font-size: 1.2rem; }
.panel a { color: #8fb8ff; }
.panel input { width: 8em; margin-left: 6px; padding: 4px 6px; background: #11161d; color: var(--text); border: 1px solid #39424e; border-radius: 6px; }
.buttons { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
button { background: #4e5058; color: #fff; border: 0; border-radius: 6px; padding: 7px 14px; font-weight: 600; cursor: pointer; }
button.primary { background: #5865f2; } button.success { background: #248046; } button.danger { background: #da373c; }
#close-inv { margin-left: auto; align-self: flex-start; }
button:disabled { opacity: .5; cursor: default; }

.hq-overlay { position: absolute; inset: 0; width: 100% !important; height: 100% !important; max-width: none !important; max-height: none !important; object-fit: fill !important; pointer-events: none; }
.hq-overlay[hidden] { display: none; }
#d-art { position: relative; display: inline-block; max-width: 100%; line-height: 0; }
