* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #111; font-family: system-ui, sans-serif; color: #eee; }
canvas { display: block; cursor: crosshair; }

#panel { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); max-height: 86vh; overflow: auto;
  background: #1b1f1aee; border: 2px solid #4a5a3a; border-radius: 8px; padding: 14px 18px; min-width: 560px; user-select: none; }
#panel .hdr { display: flex; justify-content: space-between; align-items: center; }
#panel h2 { margin: 0 0 6px; font-size: 18px; }
#panel h3 { margin: 6px 0; font-size: 14px; color: #cdb; }
#panel small { color: #999; font-weight: normal; }
#panel .x { cursor: pointer; font-size: 18px; padding: 4px 8px; }
#panel .hint { color: #aaa; font-size: 12px; margin: 2px 0 8px; }
.cols { display: flex; gap: 20px; align-items: flex-start; }
.grid { display: grid; grid-template-columns: repeat(6, 58px); gap: 4px; }
.slot { position: relative; width: 58px; height: 58px; background: #0007; border: 1px solid #444; border-radius: 4px; cursor: pointer; font-size: 10px; }
.slot.hot { border-color: #776; }
.pad-focus { outline: 3px solid #ffd54a !important; outline-offset: 1px; } /* gamepad focus ring (ui.js) */
.slot.picked { border-color: #ff6; box-shadow: 0 0 6px #ff6; }
.slot .nm { position: absolute; bottom: 4px; width: 100%; text-align: center; }
.slot .n { position: absolute; top: 2px; right: 4px; color: #ff9; font-weight: bold; font-size: 11px; }
.slot .k { position: absolute; top: 2px; left: 4px; color: #888; }
.craft { display: flex; flex-direction: column; gap: 3px; min-width: 340px; }
.craft h4 { margin: 8px 0 2px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: #9a8; border-bottom: 1px solid #333; }
.recipe { display: flex; gap: 4px; align-items: stretch; }
.recipe .mk { flex: 1; display: flex; gap: 8px; align-items: center; text-align: left; padding: 3px 8px; background: #2a3326; color: #eee;
  border: 1px solid #4a5a3a; border-radius: 4px; cursor: pointer; font: inherit; font-size: 13px; }
.recipe .mk:hover:not([disabled]) { background: #3a4a33; border-color: #8c6; }
.recipe .mk[disabled] { cursor: default; }
.recipe.ok .mk { border-color: #6a9a4a; }
.recipe.poor .mk, .recipe.nobench .mk { opacity: 0.8; }
.recipe.locked .mk { opacity: 0.4; }
.recipe .rt { display: flex; flex-direction: column; gap: 2px; }
.ic { width: 30px; height: 30px; flex: none; }
.ci { width: 14px; height: 14px; vertical-align: -3px; margin-right: 2px; }
.si { position: absolute; top: 4px; left: 13px; width: 30px; height: 30px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 11px; padding: 1px 5px; border-radius: 3px; background: #0006; white-space: nowrap; }
.chip.ok { color: #7e7; }
.chip.short { color: #f88; }
.pin { width: 30px; background: #222; border: 1px solid #444; border-radius: 4px; cursor: pointer; opacity: 0.45; font-size: 13px; padding: 0; }
.pin:hover { opacity: 0.8; }
.pin.on { opacity: 1; background: #4a4020; border-color: #db4; }
.rsr { display: flex; gap: 6px; align-items: center; }
.good { color: #6d6 !important; }
.bad { color: #e88; font-size: 12px; }
.rs { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 6px 8px; border-bottom: 1px solid #333; }
.rs > div:first-child { display: flex; flex-direction: column; }
.rs.done { opacity: 0.6; }
.rs button { background: #5a4a9a; color: #fff; border: 0; padding: 6px 10px; border-radius: 4px; cursor: pointer; }
.rs button[disabled] { opacity: 0.4; cursor: default; }
.rbar { width: 140px; height: 10px; background: #000; border-radius: 3px; overflow: hidden; }
.rbar > div { height: 100%; width: 0; background: #a6f; }

#help { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #000c; overflow: auto; }
#help .box { margin: auto; max-width: 640px; background: #1b1f1a; border: 2px solid #4a5a3a; border-radius: 10px; padding: 20px 28px; line-height: 1.45; }
#help h1 { margin: 0 0 10px; color: #b4f05a; letter-spacing: 2px; }
#help h1 small { font-size: 14px; color: #888; letter-spacing: 0; }
#help table { border-collapse: collapse; margin: 10px 0; }
#help td { padding: 2px 14px 2px 0; }
#help td:first-child { color: #ff9; font-weight: bold; white-space: nowrap; }
#help .dim { opacity: 0.55; }
#help .go { text-align: center; color: #ff9; font-weight: bold; margin-bottom: 0; }
#help input { font: inherit; padding: 4px 8px; background: #0008; color: #fff; border: 1px solid #4a5a3a; border-radius: 4px; width: 190px; }
#help input[type=checkbox] { width: auto; }
#help .row { margin: 6px 0; }
#help .cards { display: flex; gap: 12px; margin: 8px 0; }
#help .card { flex: 1; background: #0005; border: 1px solid #333; border-radius: 6px; padding: 8px 12px; }
#help .card h3 { margin: 0 0 4px; font-size: 15px; color: #cdb; }
#help .small { font-size: 12px; color: #aaa; display: block; margin: 4px 0; }
#help a { color: #9cf; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.btn { background: #5a7a3a; color: #fff; border: 0; padding: 6px 14px; border-radius: 4px; cursor: pointer; font: inherit; font-weight: bold; }
.btn:hover { background: #6b8f45; }
.btn[disabled] { opacity: 0.5; cursor: default; }
#myRooms { font-size: 13px; }
#myRooms button { margin: 2px 6px 2px 0; background: #2a3326; color: #eee; border: 1px solid #4a5a3a; border-radius: 4px; padding: 3px 8px; cursor: pointer; }
#roomInfo .invite-row { display: flex; gap: 6px; }
#roomInfo .invite-row input { flex: 1; width: auto; }
#lobbyErr { min-height: 1em; margin: 4px 0; }
#help select { font: inherit; padding: 3px 6px; background: #0008; color: #fff; border: 1px solid #4a5a3a; border-radius: 4px; }
#help h1 .btn { float: right; font-size: 13px; letter-spacing: 0; margin-top: 6px; }
.btn.ghost { background: #2a3326; border: 1px solid #4a5a3a; font-weight: normal; }
.btn.ghost:hover { background: #3a4a33; }
#profileBox { margin: 0 0 12px; }
#profileBox .small-in { font-size: 13px; color: #aaa; font-weight: normal; }
#profileBox .big { font-size: 18px; color: #ff9; letter-spacing: 1px; margin: 0 6px; }
#profMsg { min-height: 1em; }
#perkList { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 10px; }
#perkList label { display: block; padding: 3px 6px; border: 1px solid #333; border-radius: 4px; cursor: pointer; font-size: 13px; }
#perkList label.on { border-color: #8c6; background: #2a3a1f; }
#perkList label.locked { opacity: 0.45; cursor: default; }
#perkList small { display: block; color: #aaa; font-size: 11px; }
#help #profMsg.bad { color: #e88; }
.slot.drag-src { opacity: 0.35; } /* drag and drop (ui.js) */
.slot.drop-on { border-color: #8f8; box-shadow: 0 0 6px #8f8; }
.drag-ghost { position: fixed; z-index: 20; pointer-events: none; transform: translate(-50%, -50%); opacity: 0.85; background: #1b1f1a; }
.drag-ghost.split::after { content: '½'; position: absolute; bottom: -6px; right: -6px; background: #ff9; color: #000; border-radius: 8px; padding: 0 4px; font-weight: bold; font-size: 11px; }
