:root {
  --bg-dark: rgba(15, 23, 42, 0.88);
  --bg-card: rgba(20, 30, 48, 0.94);
  --border: rgba(148, 163, 184, 0.28);
  --accent: #38bdf8;
  --accent-strong: #0284c7;
  --green: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --text: #f1f5f9;
  --muted: #94a3b8;
}

* { box-sizing: border-box; user-select: none; }

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden;
  overscroll-behavior: none;
  background: #0f172a; color: var(--text);
  font-family: 'Pretendard', 'Malgun Gothic', -apple-system, BlinkMacSystemFont, sans-serif;
}

#game-canvas { display: block; width: 100vw; height: 100vh; touch-action: none; }
.hidden { display: none !important; }

/* Login */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at top, rgba(30, 58, 138, 0.82), rgba(15, 23, 42, 0.94));
  backdrop-filter: blur(8px);
}
.login-card {
  width: min(460px, 92vw); padding: 28px 30px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.logo-badge {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  background: rgba(56, 189, 248, 0.16); border: 1px solid rgba(56, 189, 248, 0.45);
  color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: 1.5px;
}
.login-card h1 { margin: 10px 0 4px; font-size: 30px; letter-spacing: -0.5px; }
.subtitle { margin: 0 0 20px; color: var(--muted); font-size: 13.5px; }
#login-form label:not(.toggle-label) { display: block; font-size: 13px; color: #cbd5e1; margin-bottom: 6px; }
#login-form input:not([type="checkbox"]) {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.85); color: #fff; font-size: 15px; outline: none; user-select: text;
}
#login-form input:not([type="checkbox"]):focus { border-color: var(--accent); }
#login-form .toggle-label {
  display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: #cbd5e1; cursor: pointer;
}
#login-form input[type="checkbox"] {
  width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; flex-shrink: 0;
}
.masked-input { -webkit-text-security: disc; }
.admin-corner-hotspot {
  position: fixed; right: 0; bottom: 0; width: 52px; height: 52px;
  background: transparent; border: none; padding: 0; margin: 0;
  cursor: default; z-index: 105; opacity: 0;
}
.admin-login-modal {
  position: fixed; inset: 0; z-index: 110;
  display: flex; align-items: center; justify-content: center;
  background: rgba(2, 6, 23, 0.72); backdrop-filter: blur(4px);
}
.admin-login-box {
  width: min(360px, 90vw); padding: 20px 22px;
  background: var(--bg-card); border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 14px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65);
}
.admin-login-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 16px; font-weight: 800; color: #fde68a; margin-bottom: 14px;
}
#admin-login-form label { display: block; font-size: 13px; color: #cbd5e1; margin-bottom: 6px; }
#admin-login-form input {
  width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.85); color: #fff; font-size: 14.5px; outline: none; user-select: text;
}
#admin-login-form input:focus { border-color: var(--warn); }
.btn-primary {
  width: 100%; margin-top: 12px; padding: 12px; border: none; border-radius: 10px;
  background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff;
  font-size: 15px; font-weight: 700; cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.08); }
.error-text { min-height: 20px; margin-top: 8px; color: #fca5a5; font-size: 13px; }
.login-rules {
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; color: #cbd5e1; line-height: 1.45;
}

/* HUD */
.underwater-tint {
  position: fixed; inset: 0; pointer-events: none; z-index: 8;
  background: radial-gradient(circle at 50% 45%, rgba(14, 165, 233, 0.28), rgba(3, 105, 161, 0.56));
  box-shadow: inset 0 0 80px rgba(2, 132, 199, 0.55);
}
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.top-bar {
  position: fixed; top: 12px; left: 14px; right: 14px; z-index: 50;
  display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
}
.top-left, .top-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; pointer-events: auto; }
.brand-pill {
  padding: 6px 12px; border-radius: 8px;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  font-weight: 800; font-size: 13px; letter-spacing: 1px;
}
.info-pill {
  padding: 6px 10px; border-radius: 8px; background: var(--bg-dark);
  border: 1px solid var(--border); font-size: 12px; font-variant-numeric: tabular-nums;
}
.admin-pill {
  padding: 6px 10px; border-radius: 8px;
  background: rgba(245, 158, 11, 0.25); border: 1px solid rgba(245, 158, 11, 0.65);
  color: #fde68a; font-size: 12px; font-weight: 700;
}
.hud-btn {
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-dark); color: var(--text); font-size: 12px; font-weight: 600; cursor: pointer;
}
.hud-btn:hover { background: rgba(51, 65, 85, 0.92); }
.hud-btn.danger { border-color: rgba(239, 68, 68, 0.55); color: #fecaca; }

.player-list {
  position: fixed; top: 56px; right: 14px; display: flex; flex-direction: column; gap: 5px; min-width: 140px;
}
.player-chip {
  padding: 5px 10px; border-radius: 8px; background: rgba(15, 23, 42, 0.72);
  border: 1px solid var(--border); font-size: 12px; display: flex; align-items: center; gap: 6px;
}
.player-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

.bp-hud {
  position: fixed; top: 56px; left: 14px; width: 220px; padding: 10px 12px;
  border-radius: 10px; background: var(--bg-dark); border: 1px solid rgba(56, 189, 248, 0.5);
}
.bp-hud-title { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.bp-progress-bar { width: 100%; height: 8px; border-radius: 999px; background: rgba(148, 163, 184, 0.25); overflow: hidden; }
.bp-progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #38bdf8, #22c55e); transition: width 0.2s ease; }
.bp-hud-stats { margin-top: 5px; font-size: 11.5px; color: #cbd5e1; }

.crosshair {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 24px; font-weight: 300; color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.9); pointer-events: none;
}
.mine-bar-wrap {
  position: fixed; top: calc(50% + 22px); left: 50%; transform: translateX(-50%);
  width: 68px; height: 7px; border-radius: 999px;
  background: rgba(15, 23, 42, 0.8); border: 1px solid rgba(255, 255, 255, 0.45); overflow: hidden;
}
.mine-bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #facc15, #22c55e); }

.play-hint {
  position: fixed; bottom: 108px; left: 50%; transform: translateX(-50%);
  padding: 6px 14px; border-radius: 999px; background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border); font-size: 12px; color: #cbd5e1; white-space: nowrap;
}

.toast-container {
  position: fixed; top: 58px; right: 14px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px; z-index: 60;
  max-width: min(320px, 78vw);
}
.toast {
  padding: 8px 16px; border-radius: 10px; background: rgba(15, 23, 42, 0.94);
  border: 1px solid var(--border); font-size: 13px; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.toast.warn { border-color: var(--warn); color: #fde68a; }
.toast.error { border-color: var(--danger); color: #fecaca; }
.toast.success { border-color: var(--green); color: #bbf7d0; }

/* Draggable Chat / System Message Panel */
.chat-panel { position: fixed; left: 14px; bottom: 108px; width: min(360px, 42vw); pointer-events: auto; z-index: 20; }
.chat-drag-handle {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 8px; margin-bottom: 3px; border-radius: 8px;
  background: rgba(15, 23, 42, 0.72); border: 1px solid var(--border);
  font-size: 11px; font-weight: 700; color: #94a3b8;
  cursor: grab; touch-action: none;
}
.chat-drag-handle:active { cursor: grabbing; border-color: var(--accent); color: #e2e8f0; }
.chat-collapse-btn {
  border: none; background: transparent; color: #cbd5e1; font-size: 14px; font-weight: 700;
  cursor: pointer; padding: 0 4px; line-height: 1;
}
.sk-editing-banner {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 7px 10px; margin-bottom: 10px; border-radius: 8px;
  background: rgba(56, 189, 248, 0.16); border: 1px solid rgba(56, 189, 248, 0.45);
  font-size: 12.5px; color: #e0f2fe;
}
.chat-messages {
  max-height: 170px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px;
  padding: 8px 10px; border-radius: 10px; background: rgba(15, 23, 42, 0.56); font-size: 12.5px; line-height: 1.4;
}
.chat-msg.system { color: #93c5fd; font-style: italic; }
.chat-form { margin-top: 6px; }
.chat-form input {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--accent);
  background: rgba(15, 23, 42, 0.94); color: #fff; font-size: 13px; outline: none; user-select: text;
}
.chat-hint { margin-top: 4px; font-size: 11px; color: rgba(203, 213, 225, 0.78); }

/* Hotbar & Vitals */
.hotbar-wrap {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: auto;
}
.vitals-row { display: flex; align-items: center; gap: 10px; }
.vital-pill {
  padding: 2px 10px; border-radius: 999px; background: rgba(15, 23, 42, 0.78);
  border: 1px solid var(--border); font-size: 11.5px; font-weight: 700;
}
.vital-pill.hp { color: #fca5a5; }
.vital-pill.hunger { color: #fde68a; }
.hotbar-label {
  padding: 2px 12px; border-radius: 999px; background: rgba(15, 23, 42, 0.8);
  font-size: 12px; font-weight: 600; color: #e2e8f0;
}
.hotbar {
  display: flex; gap: 5px; padding: 6px; border-radius: 12px;
  background: var(--bg-dark); border: 1px solid var(--border);
}

.slot {
  position: relative; width: 52px; height: 52px; border-radius: 8px;
  background: rgba(30, 41, 59, 0.85); border: 2px solid rgba(148, 163, 184, 0.25);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.slot:hover { border-color: rgba(226, 232, 240, 0.65); }
.slot.active { border-color: #38bdf8; box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.35); }
.slot.tool-q-slot { border-color: rgba(250, 204, 21, 0.55); background: rgba(45, 36, 18, 0.82); margin-right: 4px; }
.slot.tool-q-slot.active { border-color: #facc15; box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.45); }
.slot.tool-q-slot .slot-key { color: #fde047; font-weight: 800; }
.slot.selected-move { border-color: #facc15; box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.45); }
.slot img { width: 34px; height: 34px; image-rendering: pixelated; pointer-events: none; }
.slot-key { position: absolute; top: 2px; left: 4px; font-size: 10px; color: var(--muted); }
.slot-count { position: absolute; bottom: 2px; right: 4px; font-size: 11px; font-weight: 800; text-shadow: 0 1px 3px #000; }

/* Modals */
.modal {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(2, 6, 23, 0.68); backdrop-filter: blur(4px);
}
.modal-box {
  width: min(560px, 94vw); max-height: 88vh; display: flex; flex-direction: column;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55); overflow: hidden;
}
.modal-wide { width: min(880px, 95vw); }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.modal-close { border: none; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; }
.modal-close:hover { color: #fff; }
.modal-body { padding: 16px 18px; overflow-y: auto; }

.badge-warn { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(245, 158, 11, 0.2); color: #fde68a; border: 1px solid rgba(245, 158, 11, 0.45); }
.badge-ok { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(34, 197, 94, 0.2); color: #bbf7d0; border: 1px solid rgba(34, 197, 94, 0.45); }
.section-title { font-size: 12.5px; font-weight: 700; color: #cbd5e1; margin-bottom: 8px; }

.bag-layout { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; }
.slot-grid { display: grid; grid-template-columns: repeat(9, 48px); gap: 5px; }
.slot-grid .slot { width: 48px; height: 48px; }
.supply-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-height: 290px; overflow-y: auto; }
.supply-item {
  display: flex; align-items: center; gap: 7px; padding: 6px 8px; border-radius: 8px;
  background: rgba(30, 41, 59, 0.85); border: 1px solid var(--border); cursor: pointer; font-size: 12px;
}
.supply-item:hover { border-color: var(--accent); }
.supply-item img { width: 24px; height: 24px; image-rendering: pixelated; }

/* Crafting */
.craft-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tab-btn {
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.85); color: #cbd5e1; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.tab-btn.active { background: var(--accent-strong); border-color: var(--accent); color: #fff; }
.craft-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; max-height: 55vh; overflow-y: auto; }
.craft-card {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 10px; background: rgba(30, 41, 59, 0.78);
  border: 1px solid var(--border);
}
.craft-card.batch-card { flex-direction: column; align-items: stretch; gap: 8px; }
.craft-card.can-craft { border-color: rgba(34, 197, 94, 0.65); background: rgba(20, 48, 38, 0.55); }
.craft-mult {
  display: inline-block; padding: 1px 5px; border-radius: 5px; font-size: 11px;
  background: rgba(250, 204, 21, 0.2); color: #fde68a; margin-left: 3px;
}
.craft-batch-row { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.craft-qty-btn { padding: 5px 9px; font-size: 13px; }
.craft-qty-val {
  min-width: 28px; text-align: center; font-size: 13px; font-weight: 800;
  padding: 4px 6px; border-radius: 6px; background: rgba(15, 23, 42, 0.8); border: 1px solid var(--border);
}
.craft-make-btn { flex: 1; min-width: 90px; }
.craft-info { display: flex; align-items: center; gap: 10px; }
.craft-info img { width: 32px; height: 32px; image-rendering: pixelated; }
.craft-name { font-size: 13px; font-weight: 700; }
.craft-reqs { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* Skin Customizer & Gallery */
.skin-layout { display: grid; grid-template-columns: 1fr 1.25fr; gap: 18px; }
.skin-controls { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; font-size: 12.5px; }
.skin-controls label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; border-radius: 8px; background: rgba(30, 41, 59, 0.78); border: 1px solid var(--border);
}
.skin-controls input[type="color"] { border: none; background: transparent; width: 32px; height: 22px; cursor: pointer; }
.skin-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 10px; max-height: 52vh; overflow-y: auto; }
.skin-card {
  padding: 10px; border-radius: 10px; background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.skin-avatar-mini {
  width: 54px; height: 70px; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.sk-m-hat { width: 26px; height: 7px; border-radius: 2px 2px 0 0; }
.sk-m-head { width: 24px; height: 22px; position: relative; border-radius: 2px; }
.sk-m-body { width: 30px; height: 22px; margin-top: 1px; border-radius: 2px; }
.sk-m-legs { width: 22px; height: 18px; margin-top: 1px; border-radius: 0 0 2px 2px; }
.skin-card-name { font-size: 13px; font-weight: 700; text-align: center; }
.skin-card-author { font-size: 11px; color: var(--muted); }

.chest-meta { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; font-size: 12.5px; color: var(--muted); }
.chest-rename-row, .input-row, .pos-row, .btn-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chest-columns { display: flex; flex-direction: column; gap: 14px; }

input[type="text"], input[type="password"] {
  padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.85); color: #fff; font-size: 13px; user-select: text;
}
.btn-sm {
  padding: 7px 11px; border-radius: 8px; border: 1px solid var(--border);
  background: rgba(51, 65, 85, 0.9); color: #fff; font-size: 12px; font-weight: 600; cursor: pointer;
}
.btn-sm:hover { filter: brightness(1.12); }
.btn-sm:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm.accent { background: var(--accent-strong); border-color: var(--accent); }
.btn-sm.danger { background: rgba(185, 28, 28, 0.85); border-color: var(--danger); }

.item-list { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
.list-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px; background: rgba(30, 41, 59, 0.78);
  border: 1px solid var(--border); font-size: 13px;
}
.list-meta { font-size: 11.5px; color: var(--muted); }
.divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.pos-label { font-size: 12px; color: #93c5fd; margin-right: 8px; }
.small-note { font-size: 12px; color: var(--muted); margin: 6px 0; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.toggle-label { font-size: 12px; color: #cbd5e1; display: flex; align-items: center; gap: 5px; cursor: pointer; }
.bp-controls { margin-top: 12px; padding: 10px; border-radius: 10px; background: rgba(15, 23, 42, 0.55); border: 1px solid rgba(56, 189, 248, 0.35); }

/* Pixel Skin Editor & Furnace */
.pixel-editor-layout { display: grid; grid-template-columns: 384px 1fr; gap: 16px; align-items: start; }
.pixel-canvas {
  width: 384px; height: 384px; border-radius: 10px; border: 2px solid var(--border);
  cursor: crosshair; image-rendering: pixelated; background: #1e293b;
}
.px-palette { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; }
.pal-swatch {
  width: 100%; height: 26px; border-radius: 6px; border: 2px solid rgba(255,255,255,0.22); cursor: pointer;
}
.pal-swatch:hover { transform: scale(1.08); border-color: #fff; }
.skin-pixel-thumb { width: 64px; height: 64px; image-rendering: pixelated; border-radius: 6px; background: #1e293b; }

.furnace-station {
  display: flex; align-items: center; justify-content: center; gap: 36px; padding: 14px;
  border-radius: 12px; background: rgba(15, 23, 42, 0.55); border: 1px solid var(--border);
}
.furnace-col { display: flex; flex-direction: column; align-items: center; }
.furnace-slot { width: 58px; height: 58px; }
.furnace-mid { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.furnace-flame { font-size: 30px; opacity: 0.25; transition: opacity 0.2s, transform 0.2s; }
.furnace-flame.burning { opacity: 1; transform: scale(1.15); }
.furnace-arrow { font-size: 24px; color: var(--accent); }

.select-sm {
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.9); color: #fff; font-size: 12.5px;
}
.range-row {
  display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: #e2e8f0;
}
.range-row input[type="range"] { width: 100%; accent-color: var(--accent); cursor: pointer; }
.img-builder-box {
  padding: 10px; border-radius: 10px; background: rgba(15, 23, 42, 0.55); border: 1px solid rgba(56, 189, 248, 0.35);
}
.img-builder-preview-row { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.img-preview-canvas {
  width: 128px; height: 128px; border-radius: 8px; border: 1px solid var(--border);
  background: #0f172a; image-rendering: pixelated; flex-shrink: 0;
}

.world-mode-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px;
}
.mode-card {
  padding: 10px 8px; border-radius: 12px; border: 2px solid var(--border);
  background: rgba(15, 23, 42, 0.72); color: var(--text); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center;
}
.mode-card:hover { border-color: rgba(56, 189, 248, 0.6); }
.mode-card.active {
  border-color: var(--accent); background: rgba(2, 132, 199, 0.24);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}
.mode-icon { font-size: 22px; }
.mode-title { font-size: 13px; font-weight: 800; }
.mode-desc { font-size: 11px; color: var(--muted); }

.job-order-hud {
  position: fixed; top: 56px; left: 14px; width: min(275px, 68vw);
  padding: 10px 12px; border-radius: 12px; pointer-events: auto;
  background: rgba(15, 23, 42, 0.88); border: 1px solid rgba(250, 204, 21, 0.65);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.job-hud-top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 700; color: #fde68a; }
.job-score-pill { padding: 2px 7px; border-radius: 999px; background: rgba(250, 204, 21, 0.2); font-size: 11px; }
.job-order-name { margin-top: 6px; font-size: 15px; font-weight: 800; color: #ffffff; }
.job-order-reqs { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.req-chip {
  padding: 2px 7px; border-radius: 6px; font-size: 11px;
  background: rgba(51, 65, 85, 0.85); color: #cbd5e1; border: 1px solid var(--border);
}
.req-chip.have { background: rgba(22, 163, 74, 0.3); color: #bbf7d0; border-color: rgba(34, 197, 94, 0.65); }

.top-right-wrap {
  position: relative; pointer-events: auto;
  display: flex; align-items: center; gap: 6px;
}
.top-right-pinned { display: flex; align-items: center; gap: 6px; order: 2; }
.mobile-menu-btn { display: none; }
.fullscreen-btn {
  font-size: 15px; line-height: 1; padding: 6px 9px;
}

/* Mobile / Tablet Touch Controls */
.touch-controls {
  position: fixed; inset: 0; pointer-events: none; z-index: 15;
}
.touch-joystick {
  position: fixed; left: 20px; bottom: 96px;
  width: 118px; height: 118px; border-radius: 50%;
  background: rgba(15, 23, 42, 0.48); border: 2px solid rgba(148, 163, 184, 0.45);
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto; touch-action: none;
}
.touch-joy-knob {
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(56, 189, 248, 0.72); border: 2px solid #e0f2fe;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}
.touch-actions {
  position: fixed; right: 16px; bottom: 96px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  pointer-events: auto; touch-action: none;
}
.touch-mini-row, .touch-main-row { display: flex; gap: 8px; }
.t-mini-btn {
  width: 42px; height: 42px; border-radius: 10px;
  background: rgba(15, 23, 42, 0.72); border: 1px solid rgba(148, 163, 184, 0.45);
  color: #fff; font-size: 17px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; touch-action: none;
}
.t-mini-btn.active { background: rgba(2, 132, 199, 0.85); border-color: #38bdf8; }
.t-act-btn {
  width: 68px; height: 62px; border-radius: 14px;
  background: rgba(15, 23, 42, 0.76); border: 2px solid rgba(148, 163, 184, 0.5);
  color: #fff; font-size: 20px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  cursor: pointer; touch-action: none;
}
.t-act-btn span { font-size: 10.5px; color: #e2e8f0; }
.t-act-btn.mine { border-color: rgba(245, 158, 11, 0.75); }
.t-act-btn.use { border-color: rgba(34, 197, 94, 0.75); }
.t-act-btn.jump { border-color: rgba(56, 189, 248, 0.75); }
.t-act-btn.pressed, .t-act-btn:active { transform: scale(0.93); background: rgba(56, 189, 248, 0.38); }

@media (max-width: 920px) {
  .top-right-wrap { width: auto; }
  .top-right-pinned { width: auto; }
  .mobile-menu-btn { display: inline-flex; align-items: center; gap: 4px; }
  #hud-mode { display: none; }
  .top-right {
    display: none;
    position: fixed; top: 52px; right: 12px; left: auto;
    flex-direction: column; align-items: stretch; min-width: 185px;
    max-width: calc(100vw - 24px); max-height: calc(100vh - 110px); overflow-y: auto;
    padding: 8px; border-radius: 12px; gap: 6px;
    background: var(--bg-card); border: 1px solid var(--border);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.72); z-index: 95;
  }
  .top-right.mobile-open { display: flex; }
  .top-right .hud-btn { text-align: left; padding: 8px 10px; font-size: 13px; white-space: nowrap; }
  .play-hint { max-width: 92vw; white-space: normal; text-align: center; font-size: 11px; bottom: 86px; }
  .hotbar { gap: 3px; padding: 4px; max-width: 96vw; }
  .hotbar .slot { width: clamp(32px, 9.4vw, 44px); height: clamp(32px, 9.4vw, 44px); }
  .hotbar .slot img { width: 70%; height: 70%; }
  .player-list { top: 48px; right: 10px; min-width: 100px; }
  .chat-panel {
    top: 84px; right: 10px; left: auto; bottom: auto;
    width: min(235px, 60vw);
  }
  .chat-messages { max-height: 110px; font-size: 11.5px; padding: 6px 8px; }
  .chat-hint { text-align: right; font-size: 10.5px; }
  .toast-container { top: 84px; right: 10px; }
  .info-pill { font-size: 11px; padding: 4px 7px; }
}

@media (max-width: 920px) and (max-height: 520px) {
  .top-right.mobile-open {
    display: grid;
    grid-template-columns: repeat(2, minmax(125px, 1fr));
    top: 48px; right: 12px;
    max-height: calc(100vh - 76px);
  }
  .top-right .hud-btn { padding: 6px 8px; font-size: 12px; }
}

@media (max-width: 780px) {
  .bag-layout, .skin-layout, .pixel-editor-layout { grid-template-columns: 1fr; }
  .pixel-canvas { width: 100%; height: auto; }
  .slot-grid { grid-template-columns: repeat(9, 1fr); }
  .slot-grid .slot { width: 100%; height: 42px; }
}
